how to get eigenfaces from eigen values?

2 Ansichten (letzte 30 Tage)
archana
archana am 4 Jun. 2014
hello,i have wrote following code for getting eigenvalues of some facial images.now what i want to do is i want to obtain the eigenfaces of same but i really dont know how to get the eigenvectors and how to use same for getting eigenfaces.please do guide me for same.thnks.
clc; close all; clear all;
%I) READ IMAGES for i = 1:9 img{i} = imread(['C:\Users\shree\Desktop\archana\target\' num2str(i) '.jpg']); end
%II) CONVERTING TO GRAY SCALE gray_img=cellfun(@rgb2gray,img,'uniformoutput',false);
%III) RESIZING GRAY IMAGES res_img = cellfun(@(x)(imresize(x, [50, 50])), gray_img, 'UniformOutput', false);
figure,imshow(img{2}); figure,imshow(gray_img{2}); figure,imshow(res_img{2});
%DISPLAYING ALL IMAGE D=[res_img{1} res_img{2} res_img{3} res_img{4} res_img{5} res_img{6} res_img{7} res_img{8} res_img{9}]; figure, imshow(D);
%iv) MEAN IMAGE
mean_img=(res_img{1}+res_img{2}+res_img{3}+res_img{4}+res_img{5}+res_img{6}+res_img{7}+res_img{8}+res_img{9})/9;
figure,imshow(mean_img);
%v)SINGLE VECTOR CONVERSION vect_img= cellfun(@(x)((x(:))), res_img, 'UniformOutput', false);
%MEAN OF SINGLE VECTOR mean_vect=(vect_img{1}+vect_img{2}+vect_img{3}+vect_img{4}+vect_img{5}+vect_img{6}+vect_img{7}+vect_img{8}+vect_img{9})/9;
%DEVIATION MATRIX dev_mat=cellfun(@(x) ((x)-mean_vect),vect_img,'uniformoutput',false); figure,imshow(dev_mat{1})
U=[dev_mat{1} dev_mat{2} dev_mat{3} dev_mat{4} dev_mat{5} dev_mat{6} dev_mat{7} dev_mat{8} dev_mat{9} ] figure ,imshow(U);
%vi)COVARIENCE MATRIX C=[double(U')*double(U)]/9;
%VARIENCE v=var(C)
%EIGEN VALUES lambda = eig(C) [V,D] = eig(C) % eigenvalues (D) & eigenvectors (V),=> A*V = V*D size(lambda);
% EXTRACT DIGONAL OF MATRIX VECTOR V = diag(V)
%SORT VARIENCE ACC.DECREASING ORDER [junk, rindices] = sort(-1*V); V = V(rindices) D = D(:,rindices)
sort(lambda,'descend')

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by