Ellipse Detection using Hough Transform

前端 未结 4 1659
南笙
南笙 2020-12-06 06:49

using Hough Transform, how can I detect and get coordinates of (x0,y0) and \"a\" and \"b\" of an ellipse in 2D space?

This is ellipse01.bmp:

相关标签:
4条回答
  • 2020-12-06 07:25

    If your ellipse is as provided, being a true ellipse and not a noisy sample of points; the search for the two furthest points gives the ends of the major axis, the search for the two nearest points gives the ends of the minor axis, the intersection of these lines (you can check it's a right angle) occurs at the centre.

    0 讨论(0)
  • 2020-12-06 07:26

    If you use circle for rough transform is given as rho = xcos(theta) + ysin(theta) For ellipse since it is enter image description here

    You could transform the equation as rho = axcos(theta) + bysin(theta) Although I am not sure if you use standard Hough Transform, for ellipse-like transforms, you could manipulate the first given function.

    0 讨论(0)
  • 2020-12-06 07:37

    Although this is an old question, perhaps what I found can help someone.

    The main problem of using the normal Hough Transform to detect ellipses is the dimension of the accumulator, since we would need to vote for 5 variables (the equation is explained here):

    ellipse equation

    There is a very nice algorithm where the accumulator can be a simple 1D array, for example, and that runs in O3. If you wanna see code, you can look at here (the image used to test was that posted above).

    0 讨论(0)
  • 2020-12-06 07:43

    If you know the 'a' and 'b' of an ellipse then you can rescale the image by factor of a/b in one direction and look for circle. I am still thinking about what to do when a and b are unknown.

    If you know that it is circle then use Hough transform for circles. Here is a sample code:

    int accomulatorResolution  = 1;  // for each pixel
        int minDistBetweenCircles  = 10; // In pixels
        int cannyThresh            = 20;
        int accomulatorThresh      = 5*_accT+1;
        int minCircleRadius        = 0;
        int maxCircleRadius        = _maxR*10;
        cvClearMemStorage(storage);
        circles = cvHoughCircles( gryImage, storage,
                                  CV_HOUGH_GRADIENT, accomulatorResolution, 
                                  minDistBetweenCircles,
                                  cannyThresh , accomulatorThresh,
                                  minCircleRadius,maxCircleRadius );    
        // Draw circles
        for (int i = 0; i < circles->total; i++){
            float* p = (float*)cvGetSeqElem(circles,i);
            // Draw center
            cvCircle(dstImage, cvPoint(cvRound(p[0]),cvRound(p[1])),
                               1, CV_RGB(0,255,0), -1, 8, 0 );
            // Draw circle
            cvCircle(dstImage, cvPoint(cvRound(p[0]),cvRound(p[1])),
                               cvRound(p[2]),CV_RGB(255,0,0), 1, 8, 0 );
        }    
    
    0 讨论(0)
提交回复
热议问题