I want to take an RGB image and convert it to a black and white RGB image, where a pixel is black if its HSV value is between a certain range and white otherwise.
Currently I create a new image, then create a list of new pixel values by iterating through its data, then .putdata()
that list to form the new image.
It feels like there should be a much faster way of doing this, e.g. with .point()
, but it seems .point()
doesn't get given pixels but values from 0 to 255 instead. Is there a .point()
transform but on pixels?
Best Answer
Ok, this does work (fixed some overflow errors):
It is based on the Wikipedia's definition of HSV. I'll look it over as I get more time. There are definitely speedups and maybe bugs. Please let me know if you find any. cheers.
Results:
starting with this colorwheel:
I get these results:
Hue:
Value:
Saturation: