I have a uint8 image and a mask of it (float32).
The mask has ones where the object I want to keep is, and zeros for the background.
I want to make a new image that shows the real colored object instead of the ones, and keep the background zeros.
I tried to multiply both images but it says that the mask has 3 dimensions and the colored image 4 dimensions.
You seem to have an RGBA image, which may be converted to 3-channel rgb/bgr via cv2.cvtColor() function. Also i believe that it would be more clear to do masking with cv2.bitwise_and().
cv2.cvtColor()
cv2.bitwise_and()
1.4m articles
1.4m replys
5 comments
56.9k users