Code covered by the BSD License  

Highlights from
Morphological Shared-Weight Neural Network for Face Recognition

image thumbnail

Morphological Shared-Weight Neural Network for Face Recognition

by

 

31 Dec 2004 (Updated )

MSNN has the ability to learn feature extraction and perform classification at the same time.

eyesearch(dataleft,dataright,probelefteye,proberighteye)
function [eyeleft,eyeright,mergeface] = eyesearch(dataleft,dataright,probelefteye,proberighteye) 

 
 % Detect left and right eyes
 [eyeleft,ltxl,ltyl,rbxl,rbyl] = convolution(dataleft,probelefteye);
 [eyeright,ltxr,ltyr,rbxr,rbyr] = convolution(dataright,proberighteye);
 
 [row1,col1] = size(ltxl);
 [row2,col2] = size(ltyl);
 [row3,col3] = size(ltxr);
 [row4,col4] = size(ltyr);
 [row5,col5] = size(rbxl);
 [row6,col6] = size(rbyl);
 [row7,col7] = size(rbxr);
 [row8,col8] = size(rbyr);
 
 if (col8~=0) & (col8~=1)
 % if col1>1|col2>1|col3>1|col4>1|col5>1|col6>1|col7>1|col8>1
 ltxl = ltxl(1);
 ltyl = ltyl(1);
 rbxl = rbxl(1);
 rbyl = rbyl(1);
 ltxr = ltxr(1);
 ltyr = ltyr(1);
 rbxr = rbxr(1);
 rbyr = rbyr(1);
 end;
 
 % Recombine face image and determine centers of both eyes
 mergeface = [eyeleft eyeright];
 
 col_center = round(abs(ltxl-rbxl)/2);
 row_center = round(abs(ltyl-rbyl)/2);
 
 centerpoint_y = ltyl + row_center;
 
 rcol_center = round(abs(ltxr-rbxr)/2);
 rrow_center = round(abs(ltyr-rbyr)/2);
 rcenterpoint_x = length(dataleft) + rcol_center;
 rcenterpoint_y = ltyr + rrow_center;
 
 line_rightx = length(dataleft) + rcol_center + ltxr; 
 line_leftx = ltxl + col_center; 
 
 line_righty = ltyr + rrow_center; 
 line_lefty = ltyl + row_center;
 
 imshow(mergeface);
 pause(2);
 
 % Display final image and output Euclidean distance
 % if (col8~=0) & (col8~=1)
 Fin = imline(mergeface,line_leftx,line_lefty,line_rightx,line_righty);
 euclidist_detected = sqrt((line_leftx-line_rightx).^2+(line_lefty-line_righty).^2);
 disp(['The Euclidean distance between the eyes is ', num2str(euclidist_detected)]);
 imshow(Fin);
 
 save spot;

Contact us