Reputation: 6119
I'm using OpenCV
in C++
. I have two single channel matrices, one with values of either 0 or 2
, the other with either with values 0 or 3
for each element. I want to combine the two to use as a mask in the grabCut
function.
I would like to merge them such that my new combined matrix contains either 0, 2, or 3, where appropriate. I tried a bitwise OR operation, but it seems that this only gives me a matrix with values 0 or 255 exclusively where a 3 or 2 is.
combined = (greenMaskForGrabcut == 3) | (redMaskForGrabcut == 2);
How can I preserve the 3 or 2 values for each element? Thanks
Upvotes: 2
Views: 153
Reputation: 31953
OpenCV has a bitwise_or operation specifically for arrays:
http://docs.opencv.org/modules/core/doc/operations_on_arrays.html
void bitwise_or(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray())
Upvotes: 2