Simple Eye Color Detection

To detect the eye color of close-up images of eyes we use the fact that the iris (which determines the eye color) surrounds the pupil and that the pupila tends to be very dark and circular. The general idea is thus to locate the pupil in the image and extract the pixel surrounding the pupil and then analyse the colors of those surrounding pixels.

There are various ways to detect the pupil. An easy method is to do simple pixel thresholding and thus removing all pixels that are above a chosen threshold. Since the pupil is very dark compared to other structures in the image we remove all bright pixels. To remove noise we run a median filter over the image as a pre-processing step as well as compute a brightness spectrum and the size of the image to estimate what our thresholds for brightness and distance and size of shapes in later stages should be.

Input image after thresholding
Output image after thresholding.

This method alone is not perfect as the use of dark make-up may result in additional areas also being visible after thresholding.

Input image after thresholding
Output image after thresholding showing other visible regions due to dark make-up and some noise.

To remove isolated pixels in the output image after thresholding and to remove non-circular structures we compute bounding rectangles of the black areas and remove the ones that we consider to be too small to represent the pupil as well as removing the ones where the ratio of \(\frac{\text{width}}{\text{height}}\) is not \(\approx 1 \pm \varepsilon\). As the last step we compute the outline of the pupil in the threshold image and select all pixels from the input image that are near this outline. Then, we compute the average color of those pixels.

Bounding rectangles Image after removal of shapes Pixel selection near outline of the pupil.
1st image: Image showing the bounding rectangles. 2nd image: Image after removing non-circular shapes and noise. 3rd image: Selected pixels near the outline of the pupil.