matlab - Eigen faces using PCA -


i trying implement principal component analysis (pca) extract features image in matlab. have implemented following code.

[rows, columns] = size(x);  % find size of input matrix m=mean(x);                  % find mean of input matrix y=x-ones(size(x,1),1)*m;    % normalise subtracting mean c=cov(y);                   % find covariance matrix [v,d]=eig(c);               % find eigenvectors (v) , eigenvalues (d) of covariance matrix [d,idx] = sort(diag(d));    % sort eigenvalues in descending order first diagonalising eigenvalue matrix, idx stores order use when ordering eigenvectors d = d(end:-1:1)'; v = v(:,idx(end:-1:1));     % put eigenvectors in order correspond eigenvalues v2d=v(:,1:200);        % (significant principal components use, outputsize input variable) prefinal=v2d'*y'; final=prefinal';            % final normalised data projected onto eigenspace imshow(final); 

i want know how can check 1st eigen faces,2nd eigen faces.. etc

edit: here input image , eigen image eigen image

the first eigenface first eigenvector!

my guess, code:

eigenface1=reshape(v(:,1),rows,cols); 

as, if code right, each eigenvector should same size input images, unrolled. assuming rows , cols size of image.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -