I have a binary Mat obtained by thresholding. I need to apply this binary Mat on a rgb Mat. Is there a method in opencv to apply a binary mask on a rgb image?
Asked
Active
Viewed 4,435 times
0
-
1You mean like this? --> http://stackoverflow.com/questions/11532924/opencv-bitwise-and-mask – maditya Apr 18 '13 at 07:15
-
I do not understand, what you are trying to accomplish. Can you be more specific? Do you want to perform a convolution? Do you want to use the binary mat as a mask/alpha channel? – bjoernz Apr 18 '13 at 07:15
-
I obtained the binary mask by obtaining the threshold(distance, mask, 35, 255, THRESH_BINARY); – suresh Apr 18 '13 at 15:17
1 Answers
3
Just use bitwise_and function:
Mat dest;
bitwise_and(rgbMat, binaryMat, dest);
it should work, but if not, just use cvtColor function to convert binaryMat
to BGR:
cvtColor(binaryMat, binaryMat, CV_GRAY2BGR); //but this before bitwise_and function

cyriel
- 3,522
- 17
- 34