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_datafinal.m
clear

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\FaceData\lefteye' num2str(i) '.tif']);
    data1{i+2} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data1(i,:) = temp(:); 
    %data1(i+2,:) = temp2(:);
end;

for i = 3:4
    data2{i-2} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data2{i} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data2(i-2,:) = temp(:); 
    %data2(i,:) = temp2(:);
end;

for i = 5:6
    data3{i-4} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data3{i-2} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data3(i-4,:) = temp(:); 
    %data3(i-2,:) = temp2(:);
end;

for i = 7:8
    data4{i-6} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data4{i-4} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data4(i-6,:) = temp(:); 
    %data4(i-4,:) = temp2(:);
end;

for i = 9:10
    data5{i-8} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data5{i-6} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data5(i-8,:) = temp(:); 
    %data5(i-6,:) = temp2(:);
end;

for i = 11:12
    data6{i-10} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data6{i-8} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data6(i-10,:) = temp(:); 
    %data6(i-8,:) = temp2(:);
end;

for i = 13:14
    data7{i-12} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data7{i-10} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data7(i-12,:) = temp(:); 
    %data7(i-10,:) = temp2(:);
end;

for i = 15:16
    data8{i-14} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data8{i-12} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data8(i-14,:) = temp(:); 
    %data8(i-12,:) = temp2(:);
end;

for i = 17:18
    data9{i-16} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data9{i-14} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data9(i-16,:) = temp(:); 
    %data9(i-14,:) = temp2(:); 
end;

for i = 19:20
    data10{i-18} = imread(['C:\images\FaceData\lefteye' num2str(i) '.tif']);
    data10{i-16} = imread(['C:\images\FaceData\righteye' num2str(i) '.tif']);
    %temp = imresize(temp,[rez rez]);
    %temp2 = imresize(temp2,[rez rez]);
    %data10(i-18,:) = temp(:); 
    %data10(i-16,:) = temp2(:); 
end;


%-------------------\\\Train training set///----------------
hd=10;
lr=.25;
ep=20;

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;

W=zeros(900+1,10);
Z=rand(10+1,4);
winit=W;
zinit=Z;
save wint winit;
save zint zinit;
save wq W;
save zq Z;

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


out_etrain1 = O1(1,:);
out_etrain2 = O2(1,:);
out_etrain3 = O3(1,:);
out_etrain4 = O4(1,:);
out_etrain5 = O5(1,:);
out_etrain6 = O6(1,:);
out_etrain7 = O7(1,:);
out_etrain8 = O8(1,:);
out_etrain9 = O9(1,:);
out_etrain10 = O10(1,:);



outeTrain = [out_etrain1;out_etrain2;out_etrain3;out_etrain4;...
             out_etrain5;out_etrain6;out_etrain7;out_etrain8;...
             out_etrain9;out_etrain10];

save AREA1;

Contact us