2

I have got a known problem with iris and pupil detection in images. I've already read some topics (such as:

What are the correct usage/parameter values for HoughCircles in OpenCV for Iris detection? pupil Detection and cvHoughCircles? Using HoughCircles to detect and measure pupil and iris HoughCircles Parameters to recognise balls

about this issue, but still can't find solution of my problem.

I've got a eye image and what I want to do is detect iris and pupil. My problem is that, I can't select good parameter values.

This is my input sample picture: Input picture And this is my output: enter image description here

My code is posted below.

 Mat src = Highgui.imread("in.jpg", Highgui.CV_LOAD_IMAGE_GRAYSCALE);       
 Mat des = new Mat(src.rows(), src.cols(), src.type());
 Imgproc.GaussianBlur(src,src, new Size(3,3),0,0); 
 Imgproc.Canny(src, dst,  5, 10);
 Mat circles = new Mat();
 Imgproc.HoughCircles(source, circles, Imgproc.CV_HOUGH_GRADIENT, 1.0, 20.0, 70.0, 30.0, 3, 100);
 //draw circles code here

I want to have a circled pupil and iris. Can somebody post correct values for my circle detection?
I also have few questions:

1) Is better to use Canny or Sobel filter?

2) Can I do this detection better, more flexible?

3) Can you simple explain me what exacly means HoughCircles parameters - (from OpenCV javadoc)

* @param dp Inverse ratio of the accumulator resolution to the image
  * resolution. For example, if <code>dp=1</code>, the accumulator has the same
  * resolution as the input image. If <code>dp=2</code>, the accumulator has half
  * as big width and height.
* @param param1 First method-specific parameter. In case of <code>CV_HOUGH_GRADIENT</code>,
  * it is the higher threshold of the two passed to the "Canny" edge detector
  * (the lower one is twice smaller).
* @param param2 Second method-specific parameter. In case of <code>CV_HOUGH_GRADIENT</code>,
  * it is the accumulator threshold for the circle centers at the detection
  * stage. The smaller it is, the more false circles may be detected. Circles,
Community
  • 1
  • 1
Araneo
  • 477
  • 2
  • 9
  • 25
  • your canny thresholds are much too low. Try to display your intermediate images, you'll see something very "noisy" ;) – Micka Nov 11 '14 at 15:07
  • your conceptual problem might be, that the edge strength of iris boundary and pupil boundary are very different, so you will detect the pupil quite easily, but iris might be more difficult. – Micka Nov 11 '14 at 15:11
  • @Micka Based on some topics which I've found at stacoverflow, I've add automatic calculation of threshold, something like: maxThreshold = Imgproc.threshold(source, tmp, 0, 255, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU); And minThreshold is 5.0*maxThres for me. It detects pupil properly, but I still I have to many circles. What's more, it does not detect the iris. What more can I change? – Araneo Nov 11 '14 at 21:12
  • If you have color images too, try to detect circles in HSV H channel. No idea what else to do, didnt find simple thresholds for the iris myself... – Micka Nov 11 '14 at 22:27
  • How did you end up solving this? I'm having the same problem is creating an OpenCV pupil detection. Getting a lot of random false circles. What threshold values did you use? I saw in another post you posted very clean images so it looks like you succeeded! – LearningSwift Feb 14 '18 at 22:39
  • 1
    I will try to find the source code of this application, but honestly I am worried, that I won't find it. – Araneo Feb 19 '18 at 14:20

1 Answers1

1

Hough circles is not a very good method for iris/pupil detection. It is not very reliable and you'll always end up tuning too many parameters than you should.

After some basic thresholding or canny edge detection, feature detection methods like MSER work better in these cases. Here is a similar question with a solution.

Since you have a good resolution image, if you are looking to measure them or want something very accurate, I would suggest this blog. It has detailed explanation on the steps involved.

Community
  • 1
  • 1
Vasanth
  • 1,238
  • 10
  • 14