Libraryless. Click here for Pure Java version (127L/1K).
1 | static IBWImage posterizeIBWImage(int brightnessLevels, IBWImage img) { |
2 | if (brightnessLevels >= 256 || img == null) ret img; |
3 | int w = img.getWidth(), h = img.getHeight(); |
4 | |
5 | ret new IBWImage { |
6 | public int getWidth() { ret w; } |
7 | public int getHeight() { ret h; } |
8 | |
9 | public float getFloatPixel(int x, int y) { |
10 | ret (float) quantizeToNLevelsBetweenZeroAndOne_stretch( |
11 | brightnessLevels, img.getFloatPixel(x, y)); |
12 | } |
13 | }; |
14 | } |
Began life as a copy of #1022982
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033573 |
Snippet name: | posterizeIBWImage |
Eternal ID of this version: | #1033573/3 |
Text MD5: | 293852658bc2e9e49f0dcaba481647ff |
Transpilation MD5: | 2da8b067a2cc25769885a5cfcd2fba04 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-11-03 20:04:38 |
Source code size: | 464 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 148 / 216 |
Version history: | 2 change(s) |
Referenced in: | [show references] |