在将图像转换为 YCrCb 图像空间后,我试图对 JPEG 图像进行腐蚀。使用以下代码
YCrCbMin.val[0] = 0;
YCrCbMin.val[1] = 131;
YCrCbMin.val[2] = 80;
YCrCbMax.val[0] = 255;
YCrCbMax.val[1] = 185;
YCrCbMax.val[2] = 135;
imshow("img",Img);// Img is the JPEG image I load off the disk.
waitKey(0);
Mat YCrCbImg;
cvtColor(Img, YCrCbImg, CV_BGR2YCrCb);
Mat erodedImg;
inRange(YCrCbImg, YCrCbMin, YCrCbMax, erodedImg);
Mat InterMediateImg = YCrCbImg;
IplConvKernel* element = new IplConvKernel();
element->nCols = 12; element->nRows = 12; element->anchorX = 6; element->anchorY = 6;
cvErode(&erodedImg, &InterMediateImg, element, 1);
element->nCols = 6; element->nRows = 6; element->anchorX = 3; element->anchorY = 3;
cvDilate(&InterMediateImg, &erodedImg, element, 2);
在第一次侵蚀时,我收到以下错误,如屏幕截图所示。
我已使用以下图像作为输入
我在这里做错了什么?