背景在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