我试图编写一个程序从图像中删除徽标,请先清洁徽标,然后再将其发送到Ocr程序。这是输入图像:
我对Opencv和VC ++中的代码完全陌生,到目前为止,我在以下各种来源的有效代码中进行了Google搜索和合并:
im = imread(fpath + ".jpg", IMREAD_GRAYSCALE);
// make a copy & approximate the background
bg = im.clone();
// get the structure & apply morphology
kernel2 = getStructuringElement(MORPH_RECT, Size(2 * 5 + 1, 2 * 5 + 1));
morphologyEx(im, bg, CV_MOP_CLOSE, kernel2);
// threshold the difference image
threshold(dif, bw, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
// threshold the background image so we get dark region
threshold(bg, dark, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
// threshold the dark region so we get the darker pixels inside it
threshold(darkpix, darkpix, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);
// Clean image to make more readable and clear
adaptiveThreshold(bw, dst, 75, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, 3, -15);
image_out = bw - dst;
imshow("Final", image_out);
现在,我在最后一个阶段遇到了2个未解决的查询:
请提出建议,非常感谢...