Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't know why you're having this problem, but I have a couple of suggestions.

First, replace the addWeighted with bitwise_or. It's just more descriptive of what you want done, and quicker. Also it might possibly have a problem when you add 255+255, I dunno.

Second, get rid of the masked variable. Just convert src to gray and then use the setTo method. You can use this with a mask to set every "on" pixel to white. That means you need to do this with a non-negated red_hue_mask, so get rid of the bitwise_not.

Imgproc.cvtColor(src, mBlacked, Imgproc.COLOR_RGB2GRAY);
mBlacked.setTo(new Scalar(255,255,255), red_hue_mask);

That should bypass whatever weirdness is going on with cvtColor. Let me know if that doesn't work.