如何用Java实现霍夫圆

发布于 2025-01-01 05:32:23 字数 123 浏览 0 评论 0原文

我想找到一个圆形物体(眼睛的虹膜,我使用了 Haar Cascase 和中提琴琼斯算法)。所以我发现霍夫圆是正确的方法。谁能解释一下如何在 Java 中实现霍夫圆或任何其他简单的实现来用 Java 查找虹膜。

谢谢,

i want to find a circular object(Iris of eye, i have used Haar Cascase with viola Jones algorithm). so i found that hough circle would be the correct way to do it. can anybody explain me how to implement Hough circle in Java or any other easy implementation to find iris with Java.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡水深流 2025-01-08 05:32:23

Duda 和 Hart (1971) 对霍夫变换有非常清晰的解释,并给出了一个可行的方法例子。直接从该论文生成实现并不困难,因此这是您开始的好地方。

Duda and Hart (1971) has a pretty clear explanation of the Hough transform and a worked example. It's not difficult to produce an implementation directly from that paper, so it's a good place for you to start.

回心转意 2025-01-08 05:32:23

ImageJ 提供了一个Hough Circle 插件。我过去已经玩过几次了。
如果您想要或需要修改它,您可以查看源代码。

ImageJ provides a Hough Circle plugin. I've been playing around with it several times in the past.
You could take a look at the source code if you want or need to modify it.

╭⌒浅淡时光〆 2025-01-08 05:32:23

如果你想找到虹膜,你应该直截了当地告诉你。您所寻找的虹膜部分实际上称为角膜缘。另请注意,角膜缘的对比度远低于瞳孔的对比度,因此如果图像分辨率允许,瞳孔是更好的目标。 Java 在这里作为编程语言并不是一个好的选择,因为 1. 当处理密集时它很慢; 2. 由于经典霍夫圆需要 3D 累加器,而 Java 可能意味着使用手机,因此内存要求会很严格。

您可以做的是利用图像中可能只有一个(或只有几个)边缘的事实。首先要做的是通过使用定向边缘将问题的维度从 3 降到 2:提取共同表示边缘方向的水平和垂直边缘(它们可以被视为边缘向量的水平和垂直分量)。简单的想法是边缘向量的主要交集是边缘的中心。要找到交点,您只需要两个定向边,而不是定义圆的三个点。因此,维数从 3 降为 2。

您也不需要使用带有巨大累加器的经典霍夫圆变换和大量计算来找到这个交点。随机霍夫会快得多。它的工作原理如下(〜RANSAC):随机选择最小数量的定向边(在您的情况下为2),找到交集,然后找到在大致相同位置相交的所有边。这些都是内幕。您只需迭代 10-30 次,选择 2 条边的不同随机样本即可确定具有最大内点数的集合。希望这些内线位于边缘。内点射线交点的中值将为您提供圆的中心,并且从中心到内点的中值距离是半径。

在下图中,明亮的颜色对应于内点,方向用小线段显示。原始边集显示在中间(仅水平)。原始边缘位于椭圆上,而霍夫边缘通过仿射变换进行变换,使属于边缘的边缘位于圆形上。另请注意,边缘方向非常嘈杂。

在此处输入图像描述

If you want to find an iris you should be straightforward about this. The part of the iris you are after is actually called a limbus. Also note that the contrast of the limbus is much lower than the one of the pupil so if image resolution permits pupil is a better target. Java is not a good option as programming language here since 1. It is slow while processing is intense; 2. Since classic Hough circle requires 3D accumulator and Java probably means using a cell phone the memory requirements will be tough.

What you can do is to use a fact that there is probably a single (or only a few) Limbuses in the image. First thing to do is to reduce the dimensionality of the problem from 3 to 2 by using oriented edges: extract horizontal and vertical edges that together represent edge orientation (they can be considered as horizontal and vertical components of edge vector). The simple idea is that the dominant intersection of edge vectors is the center of your limbus. To find the intersection you only need two oriented edges instead of three points that define a circle. Hence dimensionality reduction from 3 to 2.

You also don’t need to use a classical Hough circle transform with a huge accumulator and numerous calculations to find this intersection. A Randomized Hough will be much faster. Here is how it works (~ to RANSAC): you select a minimum number of oriented edges at random (in your case 2), find the intersection, then find all the edges that intersect at approximately the same location. These are inliers. You just iterate 10-30 times choosing a different random sample of 2 edges to settle in a set with maximum number of inliers. Hopefully, these inliers lie on the limbus. The median of inlier ray intersections will give you the center of the circle and the median distance to the inliers from the center is the radius.

In the picture below bright colors correspond to inliers and orientation is shown with little line segment. The set of original edges is shown in the middle (horizontal only). While original edges lie along an ellipse, Hough edges were transformed by an Affine transform to make those belonging to limbus to lie on a circle. Also note that edge orientations are pretty noisy.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文