背景在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);
以下是图像:
的问题
好的,所以我知道
ThresholdBinary
的阈值是多少。由于我从灰度图像获取二值图像,因此图像中灰度的强度。这是因为图片中灰度圆的强度为150到185。我认为这与HoughCircles
的第一个参数相同。我不知道的是circleAccumulatorThreshold,累加器的分辨率和最小距离(第二,第三和第四个参数为
HoughCircles
)是或应该到那里的值。我显然没有正确的值,因为图中的圆圈不正确。我的第二个问题是,有没有更好的方法来找到圆?我需要能够在许多类型的光线中检测到这个圆圈(即圆圈的颜色强度可能很低,如80或更低),并在图片中获得它的尺寸。匹配一个圈子的最佳方式是什么?我应该让这个圆圈变成另一种颜色,并在原始图像中寻找那种颜色?任何其他想法?
感谢
你有什么建议删除的背景是什么? @Oliver – 2017-11-17 05:48:58