I googled a lot about this problem, but I can't solve it.
So, I should convert 16-bit 3-channel image to 8-bit 1-channel image. I use this binary image in cv::inpaint
function. maskBGR
, which has only two colors - black and white, is my source image.
So, there is the code:
Mat mask;
maskBGR.convertTo(mask, CV_8UC1);
inpaint(image, mask, dst, 8, cv::INPAINT_TELEA);
After that my program crashed. That was wrote in command line:
OpenCV Error: Unsupported format or combination of formats (The mask must be
8-bit 1-channel image) in unknown function, file ..\..\..\src\opencv\modules\
photo\src\inpaint.cpp, line 747
In inpaint.cpp, line 747:
if( CV_MAT_TYPE(inpaint_mask->type != CV_8UC1 )
CV_ERROR( CV_StsUnsupportedFormat, "The mask must be 8-bit 1-channel image" );
What I doing wrong?
convertTo() only changes the type of the channels, not the number of channels.
for an 8bit, 3channel it would be:
cvtColor(maskBGR, mask, CV_BGR2GRAY);
if your maskBGR is really 16 bits, 3 channels, you need 2 steps:
maskBGR.convertTo(maskBGR, CV_8U);
cvtColor(maskBGR, mask, CV_BGR2GRAY);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With