Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My image is gray scale image which i have converted to binary by smoothing and then edge detection method. Now i want to place the circle /ellipse on edge detected. I don't know how to proceed further. I am using visual C++ and gdal libraries for image processing and Qt for GUI. I should get the output as shown in reference image i have attached.enter image description here

share|improve this question
2  
This question is answered at mathematica.stackexchange.com/questions/11725/…. You will find relevant links in related threads at mathematica.stackexchange.com/questions/23560/… and mathematica.stackexchange.com/questions/23932/…. Could you please explain why this question should appear on a GIS site? –  whuber May 12 '13 at 16:25
    
Have you looked into 2-D Spatial Wavelet Analysis? Wavelets are used in a number of fields (e.g. forestry, astronomy, medical, etc) to automatically detect circular objects from digital images. wiki.landscapetoolbox.org/doku.php/… –  Aaron May 12 '13 at 18:15
    
the link you have provided uses Matlab which already contains predefined functions. I am only using c++. so getting difficulty in finding centroid first as image is in binary form. I have posted this question here because i was unable to post at stackexchange. –  Hardik May 13 '13 at 11:29

2 Answers 2

You might try looking at OpenCV library. It is better suited for such tasks.

http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html

share|improve this answer
    
your link gives me some hope to get output in c++. I will try to integrate opencv with vc++ to get the code working. Thank you so much and yes i will get back to you soon if i get stuck in between. –  Hardik May 13 '13 at 11:32

I tried the following code to detect circle. It misses some circle and the size of the circle is same in the image. Please help me out . I am not understanding the argument (specially the threshold). Is canny edge detection is performed internally in houghcircle?

using namespace cv;

int main(int, char** argv)
{
   Mat src, src_gray;

   /// Read the image
   src = imread("D:\\hardik\\crater8.tif");
          if( src.empty() )
     { return -1; }

   /// Convert it to gray
    cvtColor( src, src_gray, CV_BGR2GRAY );

   /// Reduce the noise so we avoid false circle detection
    GaussianBlur( src_gray, src_gray, Size(9, 9), 2, 2 );


    vector<Vec3f> circles;

   /// Apply the Hough Transform to find the circles
    HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT,2.0,100.0,128, 64,1, 60 );

   /// Draw the circles detected
    for( size_t i = 0; i < circles.size(); i++ )
    {
         Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
         int radius = cvRound(circles[i][2]);
         // circle center
         circle( src, center,3, Scalar(0,255,0), -1, 8, 0 );
         // circle outline
         circle( src, center, 30, Scalar(0,255,255),2, 8, 0 );
    }

   /// Show your results
    namedWindow( "Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE );
    imshow( "Hough Circle Transform Demo", src );
//  imwrite("C:\\Test2\\val1.jpg",src);
    waitKey(0);

    src.release();
    src_gray.release();

    return 0;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.