Bitmap/Histogram: Difference between revisions
Content added Content deleted
(add JAVA 8 algo) |
m (→{{header|zkl}}: tweak) |
||
Line 1,407: | Line 1,407: | ||
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl |
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl |
||
<lang zkl>fcn histogram(image){ |
<lang zkl>fcn histogram(image){ |
||
hist:=(256 |
hist:=List.createLong(256,0); // array[256] of zero |
||
image.data. |
image.data.howza(0).pump(Void,'wrap(c){ hist[c]+=1 }); // byte by byte loop |
||
hist; |
hist; |
||
} |
} |
||
Line 1,427: | Line 1,427: | ||
// stream bytes from orginal, convert to black/white, write to new image |
// stream bytes from orginal, convert to black/white, write to new image |
||
// each pixel is 24 bit RGB |
// each pixel is 24 bit RGB |
||
img.data.pump( |
img.data.pump(bw.data.clear(),'wrap(c){ if(c>median) 0xff else 0 }); |
||
bw.write(File("foo.ppm","wb"));</lang> |
bw.write(File("foo.ppm","wb"));</lang> |