Recognizing Eyes Color
Let’s learn to recognize the eye's color in a face image.
Introduction
It’s been said that the eyes are the doorway to the heart and the window to the soul, that our eyes are a reflection of our inner self and emotions. Just as every person has a unique fingerprint, no one has the exact same eye color.
But what gives eyes their color? The amount of melanin pigmentation determines the iris color. The more pigment there is, the darker the iris will be. Blue, gray, and green eyes are lighter because there is less melanin inside the iris.
Objective
This lesson aims to develop a lightweight utility through Python-based modulen that automatically detects faces in a digital image and recognizes the color of the eyes.
Dependencies
We’ll be using the following Python external libraries.
Library | Version |
MediaPipe | 0.8.9 |
opencv-python | 4.4.0.46 |
scikit-learn | 1.0.1 |
NumPy | 1.19.4 |
webcolors | 1.11.1 |
filetype | 1.0.7 |
Let’s code the functions!
Let’s take a look at the core functions of this utility.
The extract_dominant_colors
function
This function is used to gather the dominant colors of a chosen image. The function leverages machine learning by using an unsupervised clustering algorithm (k-means clustering) to cluster the image pixels data based on their RGB values. We perform the following steps using this function:
-
Line 14 maintains a copy of the image for further processing.
-
Line 17 converts the image loaded using the
OpenCV
...