I have an image loaded with opencv with img.shape = (208, 117, 3)
. I also have a boolean numpy array with mask.shape = (208, 117)
. How to I make all pixels in the img
(0,0,0)
wherever the mask
has False, otherwise leave the pixels as they are?
Answer is
img[~mask,:] = [0,0,0]
That ,:
takes care of the other dimension so you don't get mismatch issues.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.