2011-04-01 63 views
1

背景在Emgu.CV中这些阈值是什么意思,是否有更好的方法来检测一个圆?

这里是我的(从Emgu.CV.Examples溶液ShapeDetection项目与EmguCV下载传来大多代码)获得的图像和绘画中就发现圆Emgu.CV代码:

//Load the image from file 
Image<Bgr, Byte> img = new Image<Bgr, byte>(myImageFile); 

//Get and sharpen gray image (don't remember where I found this code; prob here on SO) 
Image<Gray, Byte> graySoft = img.Convert<Gray, Byte>().PyrDown().PyrUp(); 
Image<Gray, Byte> gray = graySoft.SmoothGaussian(3); 
gray = gray.AddWeighted(graySoft, 1.5, -0.5, 0); 

Image<Gray, Byte> bin = gray.ThresholdBinary(new Gray(149), new Gray(255)); 

Gray cannyThreshold = new Gray(149); 
Gray cannyThresholdLinking = new Gray(149); 
Gray circleAccumulatorThreshold = new Gray(1000); 

Image<Gray, Byte> cannyEdges = bin.Canny(cannyThreshold, cannyThresholdLinking); 

//Circles 
CircleF[] circles = cannyEdges.HoughCircles(
    cannyThreshold, 
    circleAccumulatorThreshold, 
    4.0, //Resolution of the accumulator used to detect centers of the circles 
    15.0, //min distance 
    5, //min radius 
    0 //max radius 
    )[0]; //Get the circles from the first channel 

//draw circles (on original image) 
foreach (CircleF circle in circles) 
    img.Draw(circle, new Bgr(Color.Brown), 2); 

以下是图像:

Image of circles

的问题

  1. 好的,所以我知道ThresholdBinary的阈值是多少。由于我从灰度图像获取二值图像,因此图像中灰度的强度。这是因为图片中灰度圆的强度为150到185。我认为这与HoughCircles的第一个参数相同。

    我不知道的是circleAccumulatorThreshold,累加器的分辨率和最小距离(第二,第三和第四个参数为HoughCircles)是或应该到那里的值。我显然没有正确的值,因为图中的圆圈不正确。

  2. 我的第二个问题是,有没有更好的方法来找到圆?我需要能够在许多类型的光线中检测到这个圆圈(即圆圈的颜色强度可能很低,如80或更低),并在图片中获得它的尺寸。匹配一个圈子的最佳方式是什么?我应该让这个圆圈变成另一种颜色,并在原始图像中寻找那种颜色?任何其他想法?

感谢

回答

3
  • 累加器是多少分,必须要考虑“收集”一 圈。数字越高意味着检测到的圈数越少
  • 决议是如何 关闭点必须是建议的圈子。基本上是 像素的“大小”。
  • MinDistance是多么接近圆是允许 彼此。在你的例子中,你有3个圈子,都非常接近 。增加最小距离可以防止重叠圆圈,而只是绘制一个圆圈。

至于你的答案两个数字,图像模糊,转换为灰度图像,然后门槛消除照明差异是通常的解决

1

虽然这个问题是“很多”的时候,我想提出一个回答问题2对于那些谁可能会遇到类似的问题的好处。

你可以做的是:

  1. 阈值的图像以去除背景,
  2. 检测物体的图像中,
  3. 计算圆(http://en.wikipedia.org/wiki/Shape_factor_(image_analysis_and_microscopy))的圆,它应该是1如果它是一个圆圈。使用方法FindContours(在emgucv中)提供了需要为区域和圆的周长计算的所有信息。然后,您可以使用这些信息来获取检测到的圈子的维度。
+0

你有什么建议删除的背景是什么? @Oliver – 2017-11-17 05:48:58