简体   繁体   English

如何在Java中实现Hough Circle

[英]How to implement Hough Circle in Java

i want to find a circular object(Iris of eye, i have used Haar Cascase with viola Jones algorithm). 我想找一个圆形物体(眼睛的虹膜,我使用Haar Cascase和中提琴琼斯算法)。 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. 任何人都可以解释我如何在Java中实现霍夫圈或任何其他简单的实现来用Java找到虹膜。

Thanks, 谢谢,

Duda and Hart (1971) has a pretty clear explanation of the Hough transform and a worked example. 杜达和哈特(1971)对霍夫变换和一个有效的例子有一个非常明确的解释。 It's not difficult to produce an implementation directly from that paper, so it's a good place for you to start. 直接从该论文中生成实现并不困难,因此它是您开始的好地方。

ImageJ provides a Hough Circle plugin . ImageJ提供了Hough Circle插件 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. 如果您想要或需要修改源代码,可以查看源代码。

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; Java从1开始就不是编程语言的好选择。它在处理过程中很慢; 2. Since classic Hough circle requires 3D accumulator and Java probably means using a cell phone the memory requirements will be tough. 2.由于经典的Hough圈需要3D累加器,而Java可能意味着使用手机,因此内存需求将很难。

What you can do is to use a fact that there is probably a single (or only a few) Limbuses in the image. 你可以做的是使用图像中可能只有一个(或只有几个)Limbuses的事实。 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). 首先要做的是通过使用定向边缘将问题的维数从3减少到2:提取水平和垂直边缘,它们一起表示边缘方向(它们可以被视为边缘向量的水平和垂直分量)。 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. 因此维数从3减少到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. 以下是它的工作原理(〜至RANSAC):随机选择最小数量的定向边(在您的情况下为2),找到交点,然后找到在大致相同位置相交的所有边。 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. 您只需迭代10-30次,选择2个边缘的不同随机样本,即可在具有最大内点数的集合中进行定位。 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. 另请注意,边缘方向非常嘈杂。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM