我的图像有一个"光反射",图像上的两个第一个零点与图像的其余部分有一些不同.当我将其转换为二进制图像时,这部分变为白色,我需要获得数字的确切轮廓并且这会阻碍.我可以通过使用OpenCV来解决这个问题吗?
原始图片https://docs.google.com/file/d/0BzUNc6BOkYrNNlE3U04wWEVvVE0/edit?usp=sharing
二进制版本https://docs.google.com/file/d/0BzUNc6BOkYrNeEE0U3NvOElqa1E/edit?usp=sharing
如果我增加阈值,我会丢失图像右侧的数字.我的代码:
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main ( int argc, char **argv )
{
Mat im_gray = imread("img2.jpg",CV_LOAD_IMAGE_GRAYSCALE);
Mat im_rgb = imread("img2.jpg");
cvtColor(im_rgb,im_gray,CV_RGB2GRAY);
Mat img_bw = im_gray > 90;
imwrite("image_bw2.jpg", img_bw);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
阴影和眩光并不是容易处理的问题。但只要做好一些工作,这些问题就可以克服。
另一个步骤是使用阈值图像作为掩模来获取另一个阈值图像。以下是一些对我有用的标准:
| 归档时间: |
|
| 查看次数: |
6505 次 |
| 最近记录: |