I have an image with a missing part that I know has been coloured in green (first image). What is the most pythonic way of generating another "boolean" image that shows white for the missing parts and black for the non-missing parts (second image)?
Is it possible to do it without a for-loop, but just with array slicing?
My image is a numpy array of shape [height, width, 3]
. I would like the following code to assign a two-dimensional array of booleans showing whether the value of each pixel is green ([0, 255, 0]
) or not.
mask = image[:, :] == [0, 255, 0]
However, it returns an array of the same shape as the image ([height, width, 3]
), showing if red, green, or blue values of the pixels are 0, 255, or 0, respectively. Could I perhaps use any()
or all()
method here somehow?