如何去除小黑点并使数字更清晰,完整和清晰?

时间:2019-07-21 12:32:58

标签: c++ opencv3.0

我试图编写一个程序从图像中删除徽标,请先清洁徽标,然后再将其发送到Ocr程序。这是输入图像:

enter image description here

我对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);

enter image description here

现在,我在最后一个阶段遇到了2个未解决的查询:

  1. 消除小黑点(黑色)
  2. 使数字(例如0、2、6、8、9等)和文字NA更完整,清晰和可读性

请提出建议,非常感谢...

0 个答案:

没有答案