The infinite extent of the ocean of human imagination has led to the genesis of many technologies, biometric identification is one of them. Iris is the part of the eye which contains pigment (melanin) to provide color to the eye and also controls the amount of light entering the eye by contracting and dilating the pupils in bright and dim lights respectively.
Iris contains the beautiful identity of every individual. These colorful patterns contain so much within them that a particular pattern can tell you what is going on inside your body. I was interested in doing a computer vision project. As a beginner, iris recognition was the best to start but during the whole research work I came across many other wonders about these patterns can also imply. Iridology an ancient Chinese technique that relates each pattern in a region of your iris with a particular organ is an interesting topic that I have mentioned below. Some scientists are actually fascinated by the idea and working on this.
Why work on Iris:
Before working on the iris recognition project I was interested in projects like detecting the refractive power of the eyes just through a smartphone. But this is a comparatively difficult and research-based task not suitable for a beginner as the refractive error is related to the retina which is inside the eyes.
Secondly, glaucoma detection and diabetes detection using deep learning are some of the hottest topics in optical artificial intelligence and big companies like Microsoft and IBM are working on it. You can read about how to use deep learning for detection of diabetic eyes.
These projects are very much beneficial for the society but working on them will require a very good team and knowledge of the disease conditions and how it affects the images to find patterns.
However, Iris can be worked upon easily and very good for a beginner in computer vision and deep learning. Iris has some interesting features as:
- Iris is unique for each and every individual that is why it is considered an important biometric.
- The patterns are nearly constant throughout life because Iris is also a protected part of the eye.
- Fingerprints may be changed or manipulated but Iris is very hard to be manipulated making it excellent for biometrics and hence security surveillance.
The consistency of Iris Patterns yet an externally visible organ makes it the best for biometric recognition.
- Limited genetic penetrance.
How Iris Recognition Works:
The Iris patterns are extremely complex than other biological patterns distinct even for left and right eyes of the same person. Even twins have different iris textures.
The process of iris recognition goes through a series of following steps.
- Capture a good quality image of the eyes. More than 250 pixels is very good.
- Segment out the iris portion.
- Detect the patterns within the iris portion using Gabor wavelets.
- Create a generalized code for patterns so that you can compare with other codes of other people.
- The iris code is a code of binary numbers as published by Dougman who was the first person to develop an algorithm on iris recognition.
Detecting circular part of the eyes:
The Iris dataset is available on IIT DELHI website and available on request. We are using the dataset by the website. : CASIA IRIS DATABASE.
The very first step is to remove the noise from the image. A simple Gaussian filter or median blur milter would remove the noise from the open CV library.
A Gaussian filter both blurs the image and better preserves the edges of the image. The Gaussian kernel is center-weighted, i.e. we are prioritizing pixels in the middle. The farther we move from the concerned pixel, the less weight we have in the combined average. Hence where there is a sharp change in intensity (edge), it won’t be taking in too many pixels and so it doesn’t blur the edges as much.
It is applied using the function cv2.GaussianBlur ().
Now detecting the circular part is the main task. The circles are not perfectly concentric for the iris and the pupil.
Two popular approaches for segmenting iris:
- Daugman’s Integro-Differential operator for circular detection: This algorithm gives very good results however is computationally expensive. You can read about it here.
- Hough Transform is a popular edge detection technique that is computationally very faster with good results. We are using Hough Transforms for circles for iris segmentation.
Hough transform uses a very simple mathematical concept. If you are familiar with the general equation of a line that is x cos θ+y sin θ=p. For different values of theta different lines are possible. But they have one thing common. All the lines though inclined differently but will have the same perpendicular distance from the origin.
This equation contains all the possible line at a distance p from the origin. Hough Transform is just using this logic.
At every point in the image, infinite lines are possible. If we take the center of the image as the origin, we can create a matrix of slopes of all possible lines passing through a point along with the value p. Two points lying on the same line will definitely have a safe slope and intercept.
Similar is the logic for Hough Transforms for circular edge detection only the equation changes to a circle equation. Hough transform is very easily implementable using open cv library. By adjusting the parameters one can get the desired edges.
By adjusting the parameters for this dataset we found:
The returned value in circles is the centers and radius of the detected circles. However, since the detected circles are not perfectly concentric it becomes difficult to detect both circles simultaneously. I used the biological relationship that the outer radius of the Iris is nearly the same for every eye. And it worked well for the whole database.
Hence for the second circle, I used the same center detected for the smaller circle and changed the radius parameter to 105.
cv2.circle(mask,(circles,circles),105,(255,255,255),-1) cv2.imshow('detected circles',mask)The example in the image clearly shows even when the eyelids are occurring, over function is estimating a good circle. On trying different images of the dataset the results are much better as eyelid occurrence is high in this image.
The next task is to crop this image out to a circular iris image. The cropping part is best done through masking. Masking is a technique where we create a mask of what porting of the image we want and the mask is applied to the image. In results, we obtain the cropped portion in the mask.
mask=np.zeros((height,width),np.uint8) circles=circles.reshape(3,-1) cv2.circle(mask,(circles,circles),105,(255,255,255),-1) masked_data = cv2.bitwise_and(img,img, mask=mask) _,thresh = cv2.threshold(mask,1,255,cv2.THRESH_BINARY) contours = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) x,y,w,h = cv2.boundingRect(contours) # Crop masked_data crop = masked_data[y:y+h,x:x+w]
The above code simply works by creating a mask and plotting the circles we have detected on to that mask. Then this mask is applied to the original image to extract the region. Note that the extracted part is not from the Gaussian image as it was only to detect circles. Once we have the parameter of the circle we can apply them on the original image. Below is an example of the best segmentation possible among all images of the dataset. In this image, there was no eyelid occlusion hence it was perfectly cropped.
Once we have cropped the iris out of the original image, many things can be done with this image. Iris Recognition for biometrics is the most explored technology nowadays. However medical science is still researching how well you can use this data for more information also. For example, by checking the lower eyelid as shown in the image one can predict whether the person is iron deficient or not.
Professors in the Stanford university built a deep learning model that extracted this region of the eyes and used the color as a feature parameter. The redness of the color predicted whether the person is anemic or not. Soon this technology will be available for the masses. Similarly, Diabetic Retinopathy is a trending technology that relates to eyes with diabetes.
An interesting thing to understand is patterns exist all over the body that contains a bigger meaning. I will discuss an interesting aspect of patterns in the Iris at the end. Now for capturing the patterns we are left with a few more steps. The most difficult aspect of this project is eyelash occlusion. Eyelashes will definitely occur in images no matter how good the image be. You can read this paper about eyelash removal.
But going out for traditional image processing can be time consuming and results may not be always fruitful. Masking is a way of eyelash removal but the eyelashes are so diverse in different images that results are not always good as one expects. Also in some eyes, the circle also captures the lower parts of the eyes that we don’t want. Using an annotation tool is the best solution for this problem. By annotating around 500 images, and training it on an object detection algorithm like YOLO, the results will always be much better than traditional image processing.
Now the main part of the whole project: How to segment out patterns from the Iris?
The Gabor Wavelet Transform for pattern detection:
Gabor Transform is a very special case of Fourier transform to analyze small parts of a signal in a particular period of time. A Gaussian function is multiplied by the signal to be analyzed that acts as a window. The window is slide throughout the signal and at a time only the window part is analyzed.
A Gabor filter is nothing but a sinusoidal signal with a particular orientation and this signal is modulated by a Gaussian wave.
Now every image is a combination of high frequency and low-frequency features. This means that a sharp change in the value of pixels represents a particular frequency, in fact, every change in the patterns of pixels can be represented by a frequency. Gabor filters are designed to capture these high and low-frequency changes.
For example, if we have to detect patterns in the rose image given below:
Important parameters of the Gabor filter:
- ksize-> size of the filter
- sigma- Standard deviation of the gaussian function
- lambda-wavelength of the sinusoidal wave.
for theta in np.arange(0, np.pi, np.pi / 8):
kern = cv2.getGaborKernel((ksize, ksize), 4.0, theta, 10.0, 0.5, 0, ktype=cv2.CV_32F)
Here in this piece of code, we find different Gaussian filters at different angles with wavelentgh=10 and standard deviation=4.0. The corresponding filters are shown below:
The corresponding images produced for each filter applied are:
The best image is with most detected textures:
This is what Gabor filter does it finds features of that particular frequency at different orientations of the filter.
Why use Gabor Transform for this project?
Gabor filters work exceptionally well when the dataset is small. In this dataset, only 3 to 4 images are present for each person. Hence by rotating the filters for each image we are actually generating more features at different angles. Here 8 filters are applied to each rose image.
Similarly, we will work for the iris images to detect patterns:
By varying the parameters one can create a feature map for different wavelengths and lambda.
After this one can flatten the circular section into a rectangle as shown in the top of the article.
The flattened image act as the features for iris recognition model in which the pupil is removed. Further:
- These features are normalized and principal component analysis is performed.
- Some values are positive and some are negative after performing this statistical operation.
- The positive values are assigned 1 and negative ones 0 converting this pattern to a binary code called the IRIS CODE.
- The IRIS CODE finally acts as the individuality for each person.
- Hamming distance is used to compare the eyes. It compares the similar bits between two iris codes. Even the most similar iris have a hamming distance of 0.4 making Iris an extremely unique identity of a person.
A brief of iris recognition:
The main challenges for this project are:
- Eyelashes occlusion: Occurance of eyelashes is the biggest challenge in this project. There is no hard and fast rule to remove eyelashes because they are completely random and differ from image to image. One of the best ways to avoid this problem is by switching to manual annotation.
- Finding the iris region: The iris region may be detected in most of the cases by Hough transform but the pupil size is not always constant. It varies as the number of light changes through the eyes.
- Not all people have perfectly opened their eyes in the dataset which limits the possibility of generating patterns of their IRIS.
If one switches to deep learning, the results may be more fruitful as our models will be continuously learning with the entry of data from new people. Also, deep learning is far better than digital image processing in segmenting sections of images.
Do the iris patterns have a more significant meaning?
Patterns in data are the key to data science and machine learning. In fact, patterns are everywhere and life revolves around these patterns. It’s just how well one can decode these patterns. Oriental Diagnosis, an ancient technique is continued to be practiced by famous doctors and psychologists nowadays. In oriental diagnosis, doctors look at the symptoms on our physical body and relate them to diseases present in our internal body.
Yellow eyes are the symptoms of jaundice or liver-related diseases, the yellowish face is a symptom of anemia and swelling in eyes or on the face is a symptom of water retention and hence kidney diseases. The idea behind oriental diagnosis is whatever happens inside the body is reflected on its surface.
For example, an app based on machine learning which uses multivariate linear regression to check hemoglobin levels of a person is being tested nowadays. It captures the image of your nails and by the color of your nail, it judges the hemoglobin level. Because of melanin content in nails is significantly low, they are the best source for estimating hemoglobin levels.
This app will solve the problem of millions of people who are suffering from anemia and go regularly for blood testing. The main highlight is a lack of hemoglobin affects the nail color and that can be estimated by machine learning. There is a pattern and relation between hemoglobin levels and anemia.
Iridology: The study of iris patterns
The most basic application is already depicted how iris patterns can be used for biometrics. Iris patterns can also be used for detecting the gender of a person.
But the most interesting part of these iris patterns is being explored nowadays. Iridology an ancient technique that shows how each internal organ is connected to a specific region of the iris. Any problem in that organ will affect that section of the iris.
This chart shows how each section of the iris is linked to some internal part of the body. The intersection of machine learning and Iridology has taken this area of research forward about this ancient technique.
Recently research is being done on finding whether a person is diabetic or not just by analyzing the iris of the person. For that, all the steps till the Gabor wavelet transform are same as iris recognition process. Neural networks are further used for classification of the features.
You can read this paper about diagnosing kidney disease using machine learning techniques and iridology.
Medical AI is going to be the leading sections of artificial intelligence for the next 20 decades. Furthermore, deep learning has surprised everyone by giving exceptional results like diagnosing cancer and tumor better than a professional doctor. Medical AI does not decorate the lives but it is actually solving problems which makes it an inspiriting field to pursue. Topics like iridology are exploring and interesting topics. If you are interested, then you can read books about iridology. Further, once you have decided which problem to work upon start working with any dataset available using the techniques mentioned above. Iris segmentation techniques follow the same principle in almost iris related problems. Read about Artificial Intelligence career path to explore new and trending fields in AI.
Stay tuned at NeuralAI for more deep learning and artificial intelligence projects.