Libraryless. Click here for Pure Java version (14694L/85K).
srecord noeq PosterizeBWImage(int brightnessLevels, BWImage img) is PixelPreservingImageOpResult<BWImage> { BWImage result; run { if (brightnessLevels >= 256 || img == null) ret with result = img; byte[] pixels = img.getBytes(); int w = img.getWidth(), h = img.getHeight(), n = pixels.length; byte[] pixels2 = new[n]; var posterizer = cachePosterizer(SinglePixelPosterizer(brightnessLevels)); for i to n: pixels2[i] = (byte) posterizer.get(ubyteToInt(pixels[i])); result = new BWImage(w, h, pixels2); } public BWImage pixelPreservingSrcImage() { ret img; } BWImage get() { if (result == null) run(); ret result; } }
Began life as a copy of #1033678
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033935 |
Snippet name: | PosterizeBWImage |
Eternal ID of this version: | #1033935/9 |
Text MD5: | 93ca3bc00ea2a7c3782b20bcfbcf6db6 |
Transpilation MD5: | 8f8063eb9c0383ea0a5b17353bf3fbaa |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-17 21:48:52 |
Source code size: | 691 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 177 / 346 |
Version history: | 8 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) #1034527 - ScaledBWImageFromBWIntegralImage - improved meta-aware procedure #1035253 - PosterizeBufferedImage |