How to create a binary image mat?
Whats the right way to create a binary image?
I'm trying to convert an ordinary image mat to grayscale and apply a threshold afterwards like this:
// first convert the image to grayscale
cvtColor(imageMat, grayscaleMat, CV_RGB2GRAY);
// then adjust the threshold to actually make it binary
threshold(grayscaleMat, binaryMat, 100, 255, CV_THRESH_BINARY);
Shouldn't that create a mat that does only have 0s and 255s (as uchar
s) in it? At least that's how I understand it. Unfortunately, its not only 0s and 255s.
What am I doing wrong?
Thanks a lot!