Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Need help after cropping the face what is the next move to crop the eye region?

Subject: Need help after cropping the face what is the next move to crop the eye region?

From: john john

Date: 1 Feb, 2013 06:48:08

Message: 1 of 1

Need help after cropping the face what is the next move to crop the eye region? any method can do it? i tried some algo not working maybe i missed something.. ty for help =)

this is the input image <http://i648.photobucket.com/albums/uu201/myjonas13/46_zps2e1b0ca2.jpg> this is the result i used to crop the region of the face <http://i648.photobucket.com/albums/uu201/myjonas13/resultss_zpsf429db89.jpg>

now this is the code I used..

%%%%% Reading of a RGB image
wa = imread('46.jpg');
G = wa;
I=rgb2gray(G);
BW=im2bw(I);
% minimisation of background portion
[n1 n2]=size(BW);
r=floor(n1/10);
c=floor(n2/10);
x1=1;x2=r;
s=r*c;
for i=1:10
    y1=1;y2=c;
    for j=1:10
        if (y2<=c | y2>=9*c) | (x1==1 | x2==r*10)
            loc=find(BW(x1:x2, y1:y2)==0);
            [o p]=size(loc);
            pr=o*100/s;
            if pr<=100
                BW(x1:x2, y1:y2)=0;
                r1=x1;r2=x2;s1=y1;s2=y2;
                pr1=0;
            end
          end
              y1=y1+c;
              y2=y2+c;
      end
   x1=x1+r;
   x2=x2+r;
  end
%TRACE THE FACE
L = bwlabel(BW,8);
BB = regionprops(L, 'BoundingBox');
BB1=struct2cell(BB);
BB2=cell2mat(BB1);
[s1 s2]=size(BB2);
mx=0;
for k=3:4:s2-1
    p=BB2(1,k)*BB2(1,k+1);
    if p>mx & (BB2(1,k)/BB2(1,k+1))<1.8
        mx=p;
        j=k;
    end
end
%figure,imshow(I);
%hold on;
%rectangle('Position',[BB2(1,j-2),BB2(1,j-1),BB2(1,j),BB2(1,j+1)],'EdgeColor','r' )
%CROP THE INTEREST IMAGE
I2 = imcrop(G,[BB2(1,j-2),BB2(1,j-1),BB2(1,j),BB2(1,j+1)]);
imshow(I2)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us