放大黑线的阈值 [英] Threshold to amplify black lines

查看:132
本文介绍了放大黑线的阈值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个图像(像下面给出的),我需要将其转换为二进制图像(仅黑色和白色像素)。这听起来很容易,我已经尝试过两个阈值函数。问题是我不能得到完美的边缘使用这些功能。任何帮助将非常感激。

Given an image (Like the one given below) I need to convert it into a binary image (black and white pixels only). This sounds easy enough, and I have tried with two thresholding functions. The problem is I cant get the perfect edges using either of these functions. Any help would be greatly appreciated.

我尝试的过滤器是在RGB和HSV空间中的欧氏距离。

The filters I have tried are, the Euclidean distance in the RGB and HSV spaces.

示例图片:

这是运行RGB阈值过滤器之后。 (此后为40%更多artefects)

Here it is after running an RGB threshold filter. (40% it more artefects after this)

这里是运行HSV阈值过滤器之后。 (在30%的路径变得几乎看不见,但由于噪音显然无法使用)

Here it is after running an HSV threshold filter. (at 30% the paths become barely visible but clearly unusable because of the noise)

我使用的代码非常简单。将输入图像更改为适当的颜色空间,并使用黑色检查欧氏距离。

The code I am using is pretty straightforward. Change the input image to appropriate color spaces and check the Euclidean distance with the the black color.

sqrt(R*R + G*G + B*B)



since I am comparing with black (0, 0, 0)

推荐答案

您的问题似乎是扫描图像上的光照变化,这表明局部自适应阈值法会给您更好的结果

Your problem appears to be the variation in lighting over the scanned image which suggests that a locally adaptive thresholding method would give you better results.

Sauvola方法基于原始图像的窗口中的像素的平均值和标准偏差来计算二值化像素的值。这意味着如果图像的区域通常较暗(或较亮),则将针对该区域调整阈值,并且(可能)在二值化图像中给予较少的黑斑或清除线。

The Sauvola method calculates the value of a binarized pixel based on the mean and standard deviation of pixels in a window of the original image. This means that if an area of the image is generally darker (or lighter) the threshold will be adjusted for that area and (likely) give you fewer dark splotches or washed-out lines in the binarized image.

http://www.mediateam.oulu.fi /publications/pdf/24.p

我还发现了一个Shafait等人的方法。其实现具有更大时间效率的索沃拉方法。缺点是必须计算原始图像的两个积分图像,一个以每像素8位,另一个可能是每像素64位,这可能会带来内存限制的问题。

I also found a method by Shafait et al. that implements the Sauvola method with greater time efficiency. The drawback is that you have to compute two integral images of the original, one at 8 bits per pixel and the other potentially at 64 bits per pixel, which might present a problem with memory constraints.

http:// www .dfki.uni-kl.de /〜shafait / papers / Shafait-efficient-binarization-SPIE08.pdf

我没有尝试过方法,但它们看起来很有前途。我发现两个的Java实现与粗略的谷歌搜索。

I haven't tried either of these methods, but they do look promising. I found Java implementations of both with a cursory Google search.

这篇关于放大黑线的阈值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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