How to extract eye from a facial image?

11 Ansichten (letzte 30 Tage)
Zahra kamkar
Zahra kamkar am 15 Mär. 2014
Kommentiert: Image Analyst am 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 Kommentare
Zahra kamkar
Zahra kamkar am 17 Mär. 2014
Salam. I changed a part of the codes and thankfully I obtained a reasonable result. I don't know whether it is right or not because it only responds to the image "pic8.jpg" and for other images, its result is not acceptable!
Zahra kamkar
Zahra kamkar am 17 Mär. 2014
to get the image i=imread('pic8.jpg'); subplot(4,4,1) imshow(i) title('original image'); %to transmit the image to YCBCR color space iycbcr=rgb2ycbcr(i); %to have a correct range for y and cb and cr iycbcr = im2double(iycbcr); subplot(4,4,2) imshow(iycbcr) title('YCBCR space'); %to obtain the values of y and cb and cr y=iycbcr(:,:,1); cb=iycbcr(:,:,2); cr=iycbcr(:,:,3); %these are the parts of the formula for chrominance eyemap 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'); %to transmit the image to gray scale space igray=rgb2gray(i); igray=~igray; subplot(4,4,6) imshow(igray) title('Gray space'); g=1./3; l=g*ccb; m=g*ccr; n=g*cbcr; %% %this is the formula for chrominance eyemap eyemapchr=l+m+n; subplot(4,4,7) imshow(eyemapchr) title('Chrom Eyemap'); %to obtain better result, we'd better get a histogram equalization from chrominance eyemap J=histeq(eyemapchr); subplot(4,4,8) imshow(J) title('Equalized image'); %the parts of formula for obtaining luminance eyemap 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'); %as the paper had said, in this section, we must perform AND on the afformentioned eyemaps(lum and chr), now we have the eye approximate refion as a mask cc=and(J,eyemaplum); subplot(4,4,10) imshow(cc) title('AND of Lum&Chrom'); %% subplot(4,4,11) %In this section, we wanna apply the mask (and of lum and chr eyemaps) on the original image to see only the exact eyes imshow(i); i=im2double(i); title('original image'); R=i(:,:,1); G=i(:,:,2); B=i(:,:,3); %because our image is 3D, we should use repmat command to multiply the mask by the original image newi=i.*repmat(cc,[1,1,3]); subplot(4,4,12) imshow(newi) title('Multiplication');

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 15 Mär. 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 Kommentar
Image Analyst
Image Analyst am 18 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (4)

Zahra kamkar
Zahra kamkar am 15 Mär. 2014
Yea, I forgot to send the Image. I wanna detect the eye with eyelids. I used this algorithm: eyemaplum=dilation/(erosion+1). eyemaplchr=(1/3(cb^2+(255-cr)^2+(cb/cr)).eye region(I used cc instead)=AND(eyemaplum,eyemapchr).
  2 Kommentare
Image Analyst
Image Analyst am 16 Mär. 2014
You still forgot. Please don't add "Answers" to your question. Add comments to our Answers.

Melden Sie sich an, um zu kommentieren.


Zahra kamkar
Zahra kamkar am 15 Mär. 2014
I sent you the region I need to detect. Thank you in advance

Zahra kamkar
Zahra kamkar am 16 Mär. 2014
Isn't there anyone to help me? Please!!!
  2 Kommentare
Image Analyst
Image Analyst am 16 Mär. 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.
Zahra kamkar
Zahra kamkar am 18 Mär. 2014
Hi, This is the pic I used. Unfortunately I can only use my codes on this image. My codes don't work on other images. http://www.mediafire.com/view/zaawemny6yg4bim/pic8.jpg

Melden Sie sich an, um zu kommentieren.


Mohsin Raza
Mohsin Raza am 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 Kommentar
Image Analyst
Image Analyst am 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?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by