我该怎么做才能消除“反射光"?图片?使用OpenCV [英] What can I do for eliminate a "reflection light" of a image? using OpenCV

查看:244
本文介绍了我该怎么做才能消除“反射光"?图片?使用OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的imagem具有光反射",图像上的前两个零与其余图像的光有些不同.当我将其转换为二进制图像时,该部分变为白色,并且我需要获取数字的确切轮廓,这会受到阻碍.我可以使用OpenCV解决此问题吗?

My imagem has a "light reflection", the two first zeros on the image has some light different of the rest of the image. Whe I convert this to a binary image, this part becomes white, and I need to get the exact contour of the number and this hinders. ow I could solve this by using OpenCV?

原始图像 https://docs.google.com/file /d/0BzUNc6BOkYrNNlE3U04wWEVvVE0/edit?usp = sharing

二进制版本 https://docs.google.com/file /d/0BzUNc6BOkYrNeEE0U3NvOElqa1E/edit?usp = sharing

如果增加阈值,则会丢失图像右侧的数字.我的代码:

If I increase the value of the threshold, I lose the numbers on the right side of the image. My code:

#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;
}  

推荐答案

阴影和眩光不是容易解决的问题.但是通过一些出色的工作,就可以克服它们.

Shadows and glares are not easy problems to work with. But with some good work, they are possible to overcome.

另一步骤是使用您的阈值图像作为蒙版,以获取另一个阈值图像.以下是一些对我有用的条件:

Another step is to use your thresholded image as a mask to get another thresholded image. Here are some criteria that have worked for me:

  • 限制中间阈值图像(现在具有的阈值)的直方图中包含的像素中除主峰以外的所有峰
  • 使用导数查找边界(cvSobel可能会有所帮助)
  • 结合使用严格的自适应阈值和自由硬阈值来考虑图像不同部分的照度变化

这篇关于我该怎么做才能消除“反射光"?图片?使用OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆