Prev: Logical Indexing
Next: GUI: creation / delete buttons
From: Rabab Alkasah on 29 Jun 2010 07:43 This code for face detection, I got this image http://img94.imageshack.us/img94/5027/45920477.jpg I want to get the eyes' coordinate, could you help me If you have any Idea,please? close all; I = imread('c:\darwin\working\face.jpg'); % No faces at the beginning Faces=[]; numFaceFound=0; I=double(I); H=size(I,1); W=size(I,2); R=I(:,:,1); G=I(:,:,2); B=I(:,:,3); %%%%%%%%%%%%%%%%%% LIGHTING COMPENSATION %%%%%%%%%%%%%%% YCbCr=rgb2ycbcr(I); Y=YCbCr(:,:,1); %normalize Y minY=min(min(Y)); maxY=max(max(Y)); Y=255.0*(Y-minY)./(maxY-minY); YEye=Y; Yavg=sum(sum(Y))/(W*H); T=1; if (Yavg<64) T=1.4; elseif (Yavg>192) T=0.6; end if (T~=1) RI=R.^T; GI=G.^T; else RI=R; GI=G; end C=zeros(H,W,3); C(:,:,1)=RI; C(:,:,2)=GI; C(:,:,3)=B; figure,imshow(C/255); title('Lighting compensation'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%% EXTRACT SKIN %%%%%%%%%%%%%%%%%%%%%% YCbCr=rgb2ycbcr(C); Cr=YCbCr(:,:,3); S=zeros(H,W); [SkinIndexRow,SkinIndexCol] =find(10<Cr & Cr<45); for i=1:length(SkinIndexRow) S(SkinIndexRow(i),SkinIndexCol(i))=1; end figure,imshow(S); title('skin'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% REMOVE NOISE %%%%%%%%%%%%%%%%%%%%%%%%%%%% SN=zeros(H,W); for i=1:H-5 for j=1:W-5 localSum=sum(sum(S(i:i+4, j:j+4))); SN(i:i+5, j:j+5)=(localSum>12); end end figure,imshow(SN); title('skin with noise removal'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%% FIND SKIN COLOR BLOCKS %%%%%%%%%%%%%%%%% L = bwlabel(SN,8); BB = regionprops(L, 'BoundingBox'); bboxes= cat(1, BB.BoundingBox); widths=bboxes(:,3); heights=bboxes(:,4); hByW=heights./widths; lenRegions=size(bboxes,1); foundFaces=zeros(1,lenRegions); rgb=label2rgb(L); SE=strel('disk',4); %UP=imdilate(rgb,SE); DOWN=imerode(rgb,SE); figure,imshow(DOWN); title('face candidates'); S1=rgb2gray(DOWN); threshold=graythresh(S1); bw=im2bw(S1,threshold); figure,imshow(bw); title('binary image');
From: Maxx on 29 Jun 2010 09:51 Not sure if it helps, but when we work with microscope slides in Raman Imaging we first define an origin somewhere on the slide (top left corner). These values are set to (0,0,0) and we work from that. You may be able to find some code/reference material from Veriface, which is similar software. Maxx
|
Pages: 1 Prev: Logical Indexing Next: GUI: creation / delete buttons |