On Thu, Apr 23, 2009 at 12:58 AM, Eduardo Ismael <ei...@hotmail.com> wrote: > Hi! > I wonder if it is possible to do something like the following with the > Python Imaging library: > > for pixel in image: > get how close to black it is > register what would be the darkest shade found in the image > delete pixels lighter than the darkest.
to get the darkest color in the image, use: lo, hi = im.getextrema() you can then create a lookup table that maps everything above lo plus a small margin to white: lut = [0]*256 # all black for ix in range(lo + 10, 256): lut[ix] = 255 # make everything from lo+10 to 255 white and use the "point" method to translate the whole image: im = im.point(lut) tweak as necessary. </F> _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig