如何在 opencv 中不使用 fitEllipse() 检测图像中的椭圆? [英] How to detect ellipses in image without using fitEllipse() in opencv?

查看:26
本文介绍了如何在 opencv 中不使用 fitEllipse() 检测图像中的椭圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 C++ 在 OpenCV 中检测椭圆内核.我尝试获取 Canny 边缘,然后在边缘上使用 fitEllipse() 函数.虽然这找到了椭圆,但当图像有噪点或边缘很多时,精度会很糟糕.

我意识到要走的路是检测椭圆,而不是拟合它们.也许像霍夫圆,但对于椭圆?我也不知道椭圆的长度,因为它因图像而异.

有人可以帮我开始吗?所有相关的答案都非常模糊,我只想指出从哪里开始.

解决方案

正如你已经知道的,你不需要椭圆拟合,而是椭圆检测.>

您可以在我的其他答案中找到两篇提供 C++ 代码的论文.为了完整性,我将在此处报告:

<块引用>

  1. L.Libuda, I. Grothues, K.-F.Kraiss,数字图像中的椭圆检测使用几何特征的数据,见:J. Braz, A. Ranchordas, H. Arajo,J. Jorge (Eds.), Advances in Computer Graphics and Computer Vision,计算机和信息科学中的通信第 4 卷,Springer Berlin Heidelberg,2007 年,第 229-239 页.链接代码

  2. M.Fornaciari, A. Prati, R. Cucchiara,用于嵌入式视觉应用的快速有效的椭圆检测器",模式识别,2014 link, 代码

移植到 OpenCV 也相当容易这个matlab脚本附上两篇论文的实现:

  • 一种新的高效椭圆检测方法"(Yonghong Xie Qiang, Qiang Ji/2002)
  • 使用结果聚类进行椭圆检测的随机霍夫变换"(CA Basca、M Talos、R Brad/2005)

另一个非常有趣的算法是:

  • Dilip K. Prasad、Maylor K.H.Leung 和 Siu-Yeung Cho,基于边缘曲率和凸度的椭圆检测方法",模式识别,2012 年.

可以在此处

找到 Matlab 代码<小时>

直接应用霍夫变换对于椭圆是不可行的,因为您将在 5 维参数空间中工作.这将非常缓慢,而且不准确.所以提出了很多算法.其中提到的:

  • Xie 和 Ji 的方法很有名而且很容易(但仍然很慢)
  • 巴斯卡等人.方法更快,但可能不准确
  • 普拉萨德等人.方法很快,而且非常准确.
  • Libuda 等人.方法非常快速和准确
  • Fornaciari 等人.方法是最快的,但在特定情况下可能不准确.

关于椭圆检测的最新参考书目,您可以参考this 页面.

I am trying to detect elliptical kernels, in OpenCV using C++. I have tried obtaining Canny edges, and then using fitEllipse() function on the edges. Though this finds ellipses, the accuracy is horrid when the image is noisy, or if there are many edges.

I have realised that the way to go is detecting ellipses, and not fitting them. Maybe something like Hough circles, but for ellipses? I also do not know the length the ellipses could be, as it varies between images.

Can anybody help me get started on that? All related answers are very vague, and I just want pointers on where to start.

解决方案

As you already got, you don't need ellipse fitting, but ellipse detection.

You can find in my other answer two papers with C++ code available. I'll report here for completeness:

  1. L. Libuda, I. Grothues, K.-F. Kraiss, 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 of Communications in Computer and Information Science, Springer Berlin Heidelberg, 2007, pp. 229-239. link, code

  2. M. Fornaciari, A. Prati, R. Cucchiara, "A fast and effective ellipse detector for embedded vision applications", Pattern Recognition, 2014 link, code

It's also fairly easy to port to OpenCV this matlab script with the implementation of the two papers:

  • "A New Efficient Ellipse Detection Method" (Yonghong Xie Qiang , Qiang Ji / 2002)
  • "Randomized Hough Transform for Ellipse Detection with Result Clustering" (CA Basca, M Talos, R Brad / 2005)

Another very interesting algorithm is:

  • Dilip K. Prasad, Maylor K.H. Leung and Siu-Yeung Cho, "Edge curvature and convexity based ellipse detection method," Pattern Recognition, 2012.

Matlab code can be found here


Directly applying Hough Transform is not feasible for an ellipse, since you'll work in a 5 dimensional parameter space. This will be really slow, and not accurate. So a lot of algorithms have been proposed. Among the ones mentioned here:

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

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

这篇关于如何在 opencv 中不使用 fitEllipse() 检测图像中的椭圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆