How to extract eye from a facial image?
3 views (last 30 days)
Show older comments
Zahra kamkar
on 15 Mar 2014
Commented: Image Analyst
on 25 Sep 2020
Hi. I have a big problem. I wanna extract eyes from a facial image an I've written some codes for it. Unfortunately, the result is not reasonable. for the first step, I need to choose the eye's region. The result of this stage must be at the line 50, means subplot(4,4,10). But it's not acceptable and I don't have the eye region. Would any one please tell me what's the problem here?
if true
% i=imread('pic8.jpg');
subplot(4,4,1)
imshow(i)
title('original image');
iycbcr=rgb2ycbcr(i);
iycbcr = im2double(iycbcr);
subplot(4,4,2)
imshow(iycbcr)
title('YCBCR space');
y=iycbcr(:,:,1);
cb=iycbcr(:,:,2);
cr=iycbcr(:,:,3);
ccb=cb.^2;
subplot(4,4,3)
imshow(ccb)
title('CB^2');
ccr=(1-cr).^2;
subplot(4,4,4)
imshow(ccr)
title('(1-CR)^2');
cbcr=ccb./cr;
subplot(4,4,5)
imshow(cbcr)
title('CB/CR');
igray=rgb2gray(i);
subplot(4,4,6)
imshow(igray)
title('Gray space');
g=1./3;
l=g*ccb;
m=g*ccr;
n=g*cbcr;
eyemapchr=l+m+n;
subplot(4,4,7)
imshow(eyemapchr)
title('Chrom Eyemap');
J=histeq(eyemapchr);
subplot(4,4,8)
imshow(J)
title('Equalized image');
SE=strel('disk',15,8);
o=imdilate(igray,SE);
p=1+imerode(igray,SE);
eyemaplum=o./p;
subplot(4,4,9)
imshow(eyemaplum)
title('Lum Eyemap');
%the eye region
cc=and(J,eyemaplum);
subplot(4,4,10)
imshow(cc)
title('AND of Lum&Chrom');
end
3 Comments
Accepted Answer
Image Analyst
on 15 Mar 2014
You're making us work blind (pun intended). You forgot to attach pic8.jpg.
Also, it's not so obvious where the boundaries of the eye are. Different people may have different definitions of "eye" and draw outlines in different locations. Do you mean just the "wet" part or are you including the eyelid, eye socket, or eyebrow? Speaking of which, can you just have your user draw the eye region with imfreehand()? See attached demos of imfreehand().
1 Comment
Image Analyst
on 18 Mar 2014
Regarding your comment elsewhere. Correct, because your algorithm is not very robust and you fine tuned it to work on just one particular image. You need to make a more robust algorithm that works for more images, like the people who have published papers on the subject have successfully done. Go here to see their papers http://iris.usc.edu/Vision-Notes/bibliography/people898.html#Finding%20Facial%20Features,%20Eye%20Detection Pick one and code it up and see if it does better than yours. Also read the FAQ on that.
More Answers (4)
Zahra kamkar
on 15 Mar 2014
2 Comments
Image Analyst
on 16 Mar 2014
You still forgot. Please don't add "Answers" to your question. Add comments to our Answers.
Zahra kamkar
on 16 Mar 2014
2 Comments
Image Analyst
on 16 Mar 2014
Maybe people are waiting for you to attach the image so they can run your code. Use the image icon or the paperclip icon or both.
Mohsin Raza
on 24 Sep 2020
In this project you have to write a MATLAB code that takes the provided image “plain.jpg” as input. You have to implement Bug Eye Algorithm on the input image. Your output should be similar to the sample output image that is given below
1 Comment
Image Analyst
on 25 Sep 2020
How is this an answer to Zahra's 6 year old question? He did not provide a "plain.jpg" image. So why do you think this Bug Eye Algorithm you heard of, and suggested he use, will work with his image?
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!