问题描述
我正在尝试使用 C++ 在 OpenCV 中检测椭圆内核.我尝试获得 Canny 边缘,然后在边缘上使用 fitEllipse() 函数.虽然这会发现椭圆,但当图像有噪声或有很多边缘时,精度会很差.
我意识到要走的路是检测椭圆,而不是拟合它们.也许像霍夫圆之类的东西,但对于椭圆?我也不知道椭圆的长度,因为它因图像而异.
有人可以帮我开始吗?所有相关的答案都很模糊,我只想知道从哪里开始.
如你所见,你不需要椭圆拟合,而是椭圆检测.p>
您可以在 我的其他答案 中找到两篇包含 C++ 代码的论文.为了完整起见,我会在这里报告:
L.Libuda,I. Grothues,K.-F.Kraiss,数字图像中的椭圆检测使用几何特征的数据,在:J. Braz、A. Ranchordas、H. Arajo、J. Jorge (Eds.),计算机图形学和计算机视觉的进展,计算机和信息科学通信第 4 卷,施普林格柏林海德堡,2007 年,第 229-239 页.链接, 代码
M.Fornaciari, A. Prati, R. Cucchiara,用于嵌入式视觉应用的快速有效的椭圆检测器",模式识别,2014 链接, 代码
移植到 OpenCV 也相当容易 这个matlab脚本用两篇论文执行:
- 一种新的高效椭圆检测方法"(谢强永红,季强/2002)
- 使用结果聚类进行椭圆检测的随机 Hough 变换"(CA Basca,M Talos,R Brad/2005)
另一个非常有趣的算法是:
- Dilip K. Prasad,K.H. 市长Leung 和 Siu-Yeung Cho,基于边缘曲率和凸度的椭圆检测方法",模式识别,2012 年.
Matlab 代码可以在这里找到
直接应用 Hough 变换对于椭圆是不可行的,因为您将在 5 维参数空间中工作.这将非常缓慢,而且不准确.所以提出了很多算法.这里提到的:
- Xie and 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:
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() 的情况下检测图像中的椭圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!