How do I fill in reflections with an eye Image?

2 views (last 30 days)
HI There, I am trying to localize and fill in the reflections within an eye. Below is the function which should Localize the reflections: (Input: eye Image, Output: Eye Image with Localize reflections)
function [eyeClose] = findReflections(eye);
%Since Images are already greyscale, no need to convert them.
%Average Intensity Value of image
iAve = mean2(eye);
%*Maximum Intensity Value of image calculated*%
%Gets the 0.04% of the Total amount of pixels in the image
iMaxS = 300*400*0.04;
%Sort the values in descending order
[sortedValues,sortIndex] = sort(eye(:),'descend');
%Get a linear index into Eye image of the iMaxS largest values
highValues = sortedValues(1:iMaxS);
%Fixed amount of Brighest Pixels averaged
iMaxB = mean(highValues);
%P (fixed proportion) is between 0 to 1
%After trial and error 0.8 seems to gather the best of the reflections in
%the Iris
P = 0.8;
%Intensity Threshold
tRef = iAve + P*(iMaxB-iAve)
indicies = uint8(double(eye <=tRef));
eyeTref = eye.*indicies;
%creates a nonflat, ball-shaped structuring element (actually an ellipsoid)
%whose radius in the X-Y plane is R and whose height is H.
se = strel('ball',5,45);
%Dilation Operator
eyeMorph = imdilate(eyeTref,se);
%Closure Operator
eyeClose = imclose(eyeMorph,se);
I am duplicating an algorithm from a scientific paper called " Reliable Algorithm for Iris Segmentation in eye image" by Wojciech Sankoski. Any help would be greatly appreciated
here is the image of the eye:
%

Accepted Answer

Image Analyst
Image Analyst on 14 Aug 2015
I don't think that's a good algorithm because it's masking the non-specular-reflection part of the image and doing a dilation and then closing on it. The dilation will "fill in" the holes where the specular reflections were, however it's doing that on the whole image, not just where the reflections were. And the closing is just another dilation followed by an erosion so I don't know what the purpose of that is - it will just destroy the "good" parts of the image even more.
I think what you should do is to use the dilated image to fill in just the masked out parts of the image. This will leave the good parts of the image untouched:
out = eyeImage; % Initialize
out(~indicies) = eyeMorph(~indicies); % Replace specular reflections with dilated.
Notice that I renamed your eye (which is a built-in function) with eyeImage so as to not destroy the built-in image.
Even better would be to just use roifill() which is meant for this kind of thing. The holes in the reflections will be filled in with a weighted average of the surrounding gray levels instead of the max value, which is what imdilate does.
  5 Comments
Image Analyst
Image Analyst on 15 Aug 2015
You can do it like you had - the syntax looks correct, though I don't know why you need to forge connections between nearby reflections when no reflection is there yet. I mean, wouldn't this just make it worse?
Yannick Mermet
Yannick Mermet on 15 Aug 2015
Edited: Yannick Mermet on 15 Aug 2015
Oh so there isn't a need to use it then because the imdilate fills in the reflections?

Sign in to comment.

More Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!