I have an image img. I also have a mask with value 255 at all the places where I want to retain the pixel values of img are 0 at all other places.
I want to use these two images viz. the mask and img such that I create a matrix with original img values at places where the mask is 255, and the value -1 at all places where mask is 0.
So, far, I have written this:
maskedImg = cv2.bitwise_and(img, mask)
but the maskedImg has 0 at all the places where the mask has 0. How can I get the value -1 instead of 0 at all the other places using a fast bitwise operation?