How to detect ellipses in an image without using fitEllipse () in opencv?

I am trying to detect elliptical kernels in OpenCV using C ++. I tried to get the Canny edge, and then using the fitEllipse () function on the edges. Although it finds ellipses, accuracy is terrible when the image is noisy, or if there are many edges.

I realized that the way is to detect the ellipses and not fit them. Maybe something like Hough circles, but for ellipses? I also do not know the length that ellipses can be, as it varies between images.

Can someone help me get started with this? All related answers are very vague, and I just want to indicate where to start.

Mounted Ellipses on Canny Edges

+4
source share
1 answer

As you already managed, you do not need the installation of an ellipse, but the detection of an ellipse.

You can find in my other answer two articles with C ++ code. I will report here for completeness:

  • l Libuda, I. Grothues, K.-F. Kreis, ellipse detection in digital image data using geometric features, in: J. Braz, A. Ranchordas, H. Arajo, J. Jorge (Eds.), Advances in Computer Graphics and Computer Vision, Volume 4 Communications in Computer and Information Technology, Springer Berlin Heidelberg, 2007, p. 229-239. link , code

  • M

    . Fornaciari, A. Prati, R. Cucchiara, "Fast and efficient ellipse detector for applications with built-in vision", Pattern Recognition, 2014 link , code

It is also quite easy to port this matlab script to OpenCV with the implementation of two articles:

  • "A new effective method for detecting an ellipse" (Yonghong Xie Qiang, Qiang Ji / 2002).
  • "A randomized Hough transform for detecting an ellipse with clustering results" (CA Basca, M Talos, R Brad / 2005)

Another very interesting algorithm:

  • Dilip K. Prasad, Maylor K.H. Leung and Siu-Yeung Cho, "Method for determining an ellipse based on curvature and convexity on the edge", "Pattern Recognition", 2012

Matlab code can be found here


Direct application of the Hough Transform for an ellipse is impractical, since you will work in a 5-dimensional parameter space. It will be very slow and inaccurate. Therefore, many algorithms have been proposed. Among those mentioned here:

  • The approach of Xie and Ji is quite famous and very simple (but still slow).
  • Basca et al. The approach is faster, but may be inaccurate.
  • Prasad et al. The approach is very fast and very accurate.
  • Libuda et al. The approach is very fast and accurate.
  • Fornaciari et al. the approach is the fastest, but may be inaccurate in specific cases.

For an up-to-date bibliography for ellipse detection, you can refer to this page .

+7
source

Source: https://habr.com/ru/post/1262289/


All Articles