In processing an image, I would like to ignore all white pixels. I figure the best way to do this is to set the mask array to change the mask array where there are white pixels as soon as I initialize it. To do this I use the method described on the last line of the following code.
with PIL.Image.open(picture) as im:
pix = numpy.array(im, dtype=numpy.float)
[height, width, _] = pix.shape
mask = numpy.zeros((height,width))
mask[numpy.argwhere(pix == [255,255,255])] = 1
However, this line generates the following error:
File "C:\Users\Alec\zone_map.py", line 19, in zone_map
mask[numpy.argwhere(pix == [255,255,255])] = 1
IndexError: index 5376 is out of bounds for axis 0 with size 4000
How can I change this to accomplish the desired result?