1 | % script Arch1.m |
---|
2 | % Finds ICA representation of train and test images under Architecture I, |
---|
3 | % described in Bartlett & Sejnowski (1997, 1998), and Bartlett, Movellan & |
---|
4 | % Sejnowski (2002): In Architecture I, we load N principal component |
---|
5 | % eigenvectors into rows of x, and then run ICA on x. |
---|
6 | % |
---|
7 | % Put the aligned training images in the rows of C, one image per row. |
---|
8 | % In the following examples, there are 500 images of aligned faces of size |
---|
9 | % 60x60 pixels, so C is 500x3600. |
---|
10 | % |
---|
11 | % You can use the following matlab code to create C: |
---|
12 | % markFeatures.m collects eye and mouth positions. |
---|
13 | % align_Faces.m crops, aligns, and scales the face images. |
---|
14 | % loadFaceMat.m loads the images into the rows of C. |
---|
15 | % |
---|
16 | % This script also calls the matrix of PCA eigenvectors organized in |
---|
17 | % the columns of V (3600x499), created by [V,R,E] = pcabigFn(C'); |
---|
18 | % |
---|
19 | % The ICA representation will be in the rows of F (called B in Bartlett, |
---|
20 | % Movellan & Sejnowski, 2002): |
---|
21 | |
---|
22 | function [F, Ftest] = arch (C, Ctest); |
---|
23 | |
---|
24 | [V,R,E] = pcabigFn(C'); |
---|
25 | |
---|
26 | x = V(:,1:3)'; |
---|
27 | runica |
---|
28 | |
---|
29 | F = R(:,1:3) * inv(w*wz); |
---|
30 | |
---|
31 | Dtest = zeroMn(Ctest')'; % For proper testing, subtract the mean of the |
---|
32 | % training images not the test images: |
---|
33 | % Dtest = Ctest-ones(500,1)*mean(C); |
---|
34 | Rtest = Dtest*V; |
---|
35 | %Ftest = Rtest(:,1:200) * inv(w*wz); |
---|
36 | Ftest = Rtest(:,1:3) * inv(w*wz); |
---|
37 | |
---|