OpenCV - Apply color mask to color image

asked 2017-10-24 08:46:59 -0600

TheStrangeQuark gravatar image

I'm trying to apply a color mask to a color image. The color mask is an outline that I want to apply to the color image. The mask is all black except for the outline which is pink ( BGR = [180, 105,255]). Oddly, I am able to apply an outline that is cyan [227,230,49] using the following method:

Let the color image be imgColor and the cyan outline be maskCyan. Again, this mask is all black [0,0,0] except for the pixels that are part of the outline which are [227,230,49]. Then I can apply this over the image by just doing imgColor_with_cyan_outline = cv2.bitwise_or(imgColor, maskCyan). When I do this same this with maskPink which has pink pixels instead of cyan using imgColor_with_pink_outline = cv2.bitwise_or(imgColor, maskPink) then I am returned the original image without any mask or outline applied to it. I think I'm just misunderstanding how cv2.bitwise_or() works, but I'm not sure.

Is there any other way to apply a color mask to a color image?

edit retag flag offensive close merge delete

Comments

Can you show the piece of code for making masks? Maybe there is something wrong.

moHe gravatar imagemoHe ( 2017-10-24 10:51:19 -0600 )edit