Mask Dimensions from thresholding don't match?
Hi everyone, I have the following code producing this error:
Mat imgMasked, mask;
threshold(backprojOut, mask, 128, 255, THRESH_BINARY);
image.copyTo(imgMasked, mask);
OpenCV Error: Assertion failed (mask.depth() == CV_8U && (mcn == 1 || mcn == cn)) in copyTo
Can anyone provide me with some advice as to what is causing this? I've tried:
mask = Mat::zeros(image.rows, image.cols, CV_8U);
but that wasn't it.
Thanks.
EDIT: To clarify I'm trying to take my output from back projection on a HSV image (which is grayscale) and turn it into a binary Mat so I can apply it as a mask. Also trying the following doesn't work:
threshold(backprojOut, mask, 128, 255, THRESH_BINARY);
mask.convertTo(mask, CV_8U);
image.copyTo(imgMasked, mask);
EDIT 2: Mask has 3 channels and my image has 4, hence the error. Threshold is giving me a Mat I can't use. How can I get a single channel out of threshold?