Bitmap/Histogram: Difference between revisions

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