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.

traineyes_testSHIFT.m
clear

% gray-level shift
u=0.2; % add noise
lowin=0.1; highin=0.9;
lowout=0.4; highout=0.6;
rez=100;


T1=[0 1 1 0;0 1 1 0;0 1 1 0;0 1 1 0];
T2=[1 1 0 0;1 1 0 0;1 1 0 0;1 1 0 0];
T3=[1 1 1 0;1 1 1 0;1 1 1 0;1 1 1 0];
T4=[0 1 1 1;0 1 1 1;0 1 1 1;0 1 1 1];
T5=[1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0];
T6=[0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1];
T7=[1 0 1 0;1 0 1 0;1 0 1 0;1 0 1 0];
T8=[0 1 0 1;0 1 0 1;0 1 0 1;0 1 0 1];
T9=[1 0 0 1;1 0 0 1;1 0 0 1;1 0 0 1];
T10=[0 0 1 1;0 0 1 1;0 0 1 1;0 0 1 1];

for i = 1:2
    data1{i} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data1{i+2} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data1(i,:) = temp(:); 
    %data1(i+2,:) = temp2(:);
end;

for i = 3:4
    data2{i-2} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data2{i} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data2(i-2,:) = temp(:); 
    %data2(i,:) = temp2(:);
end;

for i = 5:6
    data3{i-4} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data3{i-2} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data3(i-4,:) = temp(:); 
    %data3(i-2,:) = temp2(:);
end;

for i = 7:8
    data4{i-6} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data4{i-4} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data4(i-6,:) = temp(:); 
    %data4(i-4,:) = temp2(:);
end;

for i = 9:10
    data5{i-8} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data5{i-6} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data5(i-8,:) = temp(:); 
    %data5(i-6,:) = temp2(:);
end;

for i = 11:12
    data6{i-10} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data6{i-8} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data6(i-10,:) = temp(:); 
    %data6(i-8,:) = temp2(:);
end;

for i = 13:14
    data7{i-12} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data7{i-10} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data7(i-12,:) = temp(:); 
    %data7(i-10,:) = temp2(:);
end;

for i = 15:16
    data8{i-14} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data8{i-12} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data8(i-14,:) = temp(:); 
    %data8(i-12,:) = temp2(:);
end;

for i = 17:18
    data9{i-16} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data9{i-14} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data9(i-16,:) = temp(:); 
    %data9(i-14,:) = temp2(:); 
end;

for i = 19:20
    data10{i-18} = imread(['C:\images\unseen\lefteye' num2str(i) '.tif']);
    data10{i-16} = imread(['C:\images\unseen\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %temp = imnoise(temp,'salt & pepper',u);
    %temp = imadjust(temp,[lowin highin],[lowout highout]);
    %temp2 = imnoise(temp2,'salt & pepper',u);
    %temp2 = imadjust(temp2,[lowin highin],[lowout highout]);
    %data10(i-18,:) = temp(:); 
    %data10(i-16,:) = temp2(:); 
end;

for rec=1:4
data1{rec} = imresize(data1{rec},[100 100]);
data2{rec} = imresize(data2{rec},[100 100]);
data3{rec} = imresize(data3{rec},[100 100]);
data4{rec} = imresize(data4{rec},[100 100]);
data5{rec} = imresize(data5{rec},[100 100]);
data6{rec} = imresize(data6{rec},[100 100]);
data7{rec} = imresize(data7{rec},[100 100]);
data8{rec} = imresize(data8{rec},[100 100]);
data9{rec} = imresize(data9{rec},[100 100]);
data10{rec} = imresize(data10{rec},[100 100]);
end;



hd=10;
lr=.25;
ep=20;


%SS = who('-file','zq');
%TT = who('-file','wq');
%if SS{1}=='Z'
 %   load zq;
  %  ZX=Z;
   % save zq ZX;
   %end;
    

%if TT{1}=='W'
 %   load wq;
  %  WX=W;
  %  save wq WX;
  %end;
    


load wint;load zint;
WX=winit;ZX=zinit;

save wq WX;
save zq ZX;
%-------------------

%WX=zeros(900+1,10);
%ZX=rand(10+1,4);
%winit=WX;
%zinit=ZX;
%save wint winit;
%save zint zinit;
%save wq WX;
%save zq ZX;
%---------------
%load zp;load wp;
%load wq;load zq;
%WX = W;
%ZX = Z;
%save wq WX;
%save zq ZX;

tic
[WX,ZX,O1,E1]=msnn2(T1,data1,hd,lr,ep);
[WX,ZX,O2,E2]=msnn2(T2,data2,hd,lr,ep);
[WX,ZX,O3,E3]=msnn2(T3,data3,hd,lr,ep);
[WX,ZX,O4,E4]=msnn2(T4,data4,hd,lr,ep);
[WX,ZX,O5,E5]=msnn2(T5,data5,hd,lr,ep);
[WX,ZX,O6,E6]=msnn2(T6,data6,hd,lr,ep);
[WX,ZX,O7,E7]=msnn2(T7,data7,hd,lr,ep);
[WX,ZX,O8,E8]=msnn2(T8,data8,hd,lr,ep);
[WX,ZX,O9,E9]=msnn2(T9,data9,hd,lr,ep);
[WX,ZX,O10,E10]=msnn2(T10,data10,hd,lr,ep);
toc
timerTrainSet=toc;


out_etest1 = O1(1,:);
out_etest2 = O2(1,:);
out_etest3 = O3(1,:);
out_etest4 = O4(1,:);
out_etest5 = O5(1,:);
out_etest6 = O6(1,:);
out_etest7 = O7(1,:);
out_etest8 = O8(1,:);
out_etest9 = O9(1,:);
out_etest10 = O10(1,:);



outeTest = [out_etest1;out_etest2;out_etest3;out_etest4;...
            out_etest5;out_etest6;out_etest7;out_etest8;...
            out_etest9;out_etest10];

save AREA3;

Contact us