Thursday, 12 September 2013

Convert RGB to black OR white

Convert RGB to black OR white

How would I take an RGB image in Python and convert it to black OR white?
Not black AND white, I want each pixel to be either fully black (0, 0, 0)
or fully white (255, 255, 255).
Is there any built-in functionality for this in the popular Python image
processing libraries? If not, would the best way be just to loop through
each pixel, see if it's closer to white or black, and if it's closer to
white set it to white, if it's closer to black set it to black?

No comments:

Post a Comment