# 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.

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

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.