Skip to content Skip to sidebar Skip to footer

How To I Use PIL Image.point(table) Method To Apply A Threshold To A 256 Gray Image?

I have 8-bit greyscale TIFF images that I want to convert to Monochrome using a 75% white (decimal 190) threshold. In the Image.convert(mode) method section, the PIL manual says:

Solution 1:

I found the complete solution in this answer "Write TIFF file in python from String". The function must include "and 255"

threshold = 191  
im = im.point(lambda p: p > threshold and 255)  

Solution 2:

Try im.point(lambda p: p > 190) and post the results.


Post a Comment for "How To I Use PIL Image.point(table) Method To Apply A Threshold To A 256 Gray Image?"