バックグラウンド
これが、画像を取得してその中にある円を描くための私のEmgu.CVコードです(主にEmgu.CVのShapeDetectionプロジェクトからのコード。EmguCVダウンロードに付属のサンプルソリューション):
//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);
これが画像です:
質問
OK、それで私はのしきい値が何であるかを知ってい
ThresholdBinary
ます。グレースケール画像からバイナリ画像を取得しているので、それは画像のグレーの強度です。これは、写真のグレースケール円の強度が150〜185であるため、機能します。これは、の最初の引数でも同じであると思いますHoughCircles
。私が知らないのは、circleAccumulatorThreshold、アキュムレータの解像度、および最小距離(2番目、3番目、および4番目の引数から
HoughCircles
)、またはそこに配置する値です。写真の円が正しく「ハフ」されていないため、明らかに正しい値がありません。私の2番目の質問は、円を見つけるためのより良い方法はありますか?多くの種類の光でこの円を検出し(つまり、円の色の強度が80以下のように低い場合があります)、写真でその寸法を取得できる必要があります。円を一致させるための最良の方法は何ですか?円を別の色にして、元の画像でその色を探す必要がありますか?他のアイデアはありますか?
ありがとう