There are many answers related to avoid brute force RGB opencv image loop in python by using numpy. I checked many of them but none seems to answer completely my needs:
Given a image, I need to compare pixel-wise and create a mask based in the result. Is something like:
# image contains a jpg regular image
data = np.asarray(image)
# Separate each channel
blue, green, red = data.T
print(blue.shape)
#(1024, 1024)
So far so good.
I need a "white" mask of this image like the following:
->A pixel is white if its red_value > 80 AND red_value-green_value > 20 AND red_value-blue_value > 20
So after research I came to this:
white = ((red > 80).all and (red-green > 20).all and (red-blue > 20).all)
But after this operation I can´t read white values.
I tried many things like:
print(white.shape)
Gets: AttributeError: 'builtin_function_or_method' object has no attribute 'shape'
w = np.asarray(white)
Gets: array ( "<" built-in method all of numpy.ndarray object at 0x0408ED68">", dtype=object)
Any suggestions? Thanks.