应用霍夫变换后在图像上绘制圆圈?

时间:2014-03-29 15:44:42

标签: c# asp.net image-processing aforge

我正在使用AForge的HoughCircleTransformation类来检测圆圈。我想在检测到圆圈的图像上绘制圆圈(以突出显示原始图像上的圆圈)。我如何修改'foreach循环'来做到这一点?

 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;
    }

1 个答案:

答案 0 :(得分:0)

你有X,Y和半径。

要在Bitmap上绘图,请使用System.Drawing.Graphics。

e.g。

  var g = Graphics.FromBitmap(bmp); 
  g.DrawEllipse(...);