本文介绍了应用霍夫变换后在图像上绘制圆圈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用AForge的HoughCircleTransformation类来检测圆圈。我想在检测到圆圈的图像上绘制圆圈(以突出显示原始图像上的圆圈)。我如何修改'foreach循环'来做到这一点?
I'm using HoughCircleTransformation class of AForge to detect circles. I want to draw circles on the image where the circles are detected (to highlight the circles on the original image). How can i modify the 'foreach loop' to do that?
public Bitmap hough(Bitmap bmp)
{
HoughCircleTransformation circleTransform = new HoughCircleTransformation(35);
// apply Hough circle transform
circleTransform.ProcessImage(bmp);
Bitmap houghCirlceImage = circleTransform.ToBitmap();
// get circles using relative intensity
HoughCircle[] circles = circleTransform.GetCirclesByRelativeIntensity(0.5);
int numCircles = circleTransform.CirclesCount;
MessageBox.Show("Number of circles found : " + numCircles.ToString());
foreach (HoughCircle circle in circles)
{
//code to draw circle
}
return bmp;
}
推荐答案
MessageBox.Show("Number of circles found : " + numCircles.ToString());
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
foreach (HoughCircle circle in circles)
{
g.DrawEllipse(Pens.Green, circle.GetTheThingsCoordinates());
//code to draw circle
}
这篇关于应用霍夫变换后在图像上绘制圆圈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!