Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [m A eigenfaces pr_img] = eigenface_core(database_path)
- c = 1;
- d = 1;
- for i = 1:10
- path = strcat(database_path,'/');
- number = num2str(i);
- path = strcat(path, number);
- path = strcat(path,'.jpg');
- matrix = double(rgb2gray(imread(path)));
- [a b] = size(matrix);
- for k = 1:a
- for l = 1:b
- T(c,d) = matrix(k,l);
- c++;
- endfor
- endfor
- d++;
- c = 1;
- endfor
- [e f] = size(T);
- for i = 1:e
- m(i) = sum(T(i,:))/f;
- A(i,:) = T(i,:) - m(i);
- endfor
- AUX = A' * A;
- [B C] = eig(AUX);
- diagC = diag(C);
- g = size(diagC);
- h = 1;
- for i = 1:g
- if (diagC(i) > 1)
- V(:,h) = B(:,i);
- h++;
- endif
- endfor
- eigenfaces = A * V;
- pr_img = eigenfaces' * A;
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement