【发布时间】:2014-05-17 13:10:16
【问题描述】:
我正在尝试使用 C# 和 AForge 霍夫变换线检测来检测一条线是否穿过图像。在相同的上下文中,我正在考虑一种更好的解决方案,即检测图像是否清晰(无线条)然后返回错误值,反之亦然。我有下面的图片,我想检查线是否通过它,我会返回true,否则返回false:
http://s10.postimg.org/3sn8wari1/image.png
我使用下面的代码来获取行数,但似乎不准确或者我使用的算法不好。
AForge.Imaging.Image.FormatImage(ref SEChild);
// lock the source image
BitmapData sourceData = SEChild.LockBits(
new System.Drawing.Rectangle(0, 0, SEChild.Width, SEChild.Height),
ImageLockMode.ReadOnly, SEChild.PixelFormat);
// binarize the image
UnmanagedImage binarySource = filter.Apply(new UnmanagedImage(sourceData));
HoughLineTransformation lineTransform = new HoughLineTransformation();
lineTransform. = 10;
// apply Hough line transofrm
lineTransform.ProcessImage(binarySource);
HoughLine[] lines = lineTransform.GetLinesByRelativeIntensity(0.5);
if (lines.Count() > 0)
{
Result += "NW: Yes!\n";
}
else
{
Result += "NW: No!\n";
}
【问题讨论】:
标签: c# image-processing aforge hough-transform