I have an image on which there is a full-red (b, g, r = 0, 0, 255) shape that I wish to isolate.
I am currently doing the following to change to black all the non-red pixels.
im = image.copy()
b1, g1, r1 = 0, 0, 255
b2, g2, r2 = 0, 0, 0
# Separate the channels from image
b, g, r = im[:, :, 0], im[:, :, 1], im[:, :, 2]
mask = (b != b1) & (g != g1) & (r != r1)
im[:, :, :3][mask] = [b2, g2, r2]
But even though the only red part in image is the red shape added programatically, some pixels are not becoming red and stays black.
So the question is how this could be possible ? Shouldn't them match the mask ?
Here is the image of what I get (I need a black and red image instead)