[Image-SIG] threshold cutoff
Douglas Bagnall
douglas at paradise.net.nz
Thu Jun 21 09:42:27 CEST 2007
Noah.org wrote:
> How can I set the absolute white or black level of an image?
> I want all pixels above or below a certain value clipped.
> For example, I want all pixels brighter than 200 to be set to 255
> (assuming an 8-bit gray-scale image).
It sounds to me like you want the image point method.
http://effbot.org/imagingbook/image.htm#Image.point
Something like this will expand the middle range of an image and clip
the extremes:
t = [min(255, max(0, x + x/4 - 32)) for x in range(256)]
im_clipped = im.point(t)
douglas
More information about the Image-SIG
mailing list