2014-03-29 33 views
0

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

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

回答

0

你有X,Y和半径。

要在位图上使用System.Drawing.Graphics。

例如

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