Filter löschen
Filter löschen

Matrix deminatation are not agree error in this code.error in Minus ?temp = ( norm( ProjectedTestImage - q ) )^2;

2 Ansichten (letzte 30 Tage)
img = imread('2.jpg');
img = rgb2gray(img);
[irow icol] = size(img);
temp = reshape(img',irow*icol,1); % Reshaping 2D images into 1D image vectors
m = mean(temp,2); % Computing the average face image m = (1/P)*sum(Tj's) (j = 1 : P)
Train_Number = size(img,2);
temp =Train_Number - m;
L = temp'*temp; % L is the surrogate of covariance matrix C=A*A'.
[V D] = eig(L); % Diagonal elements of D are the eigenvalues for both L=A'*A and C=A*A'.
L_eig_vec = [];
L_eig_vec = [L_eig_vec V];
Eigenfaces = Train_Number * L_eig_vec;
ProjectedImages = [];
Train_Number = size(Eigenfaces,2);
temp = Eigenfaces'*Train_Number; % Projection of centered images into facespace
ProjectedImages = [ProjectedImages temp];
temp = Eigenfaces'*Train_Number; % Projection of centered images into facespace
ProjectedImages = [ProjectedImages temp];
%%%%%%%%%%%%%%%%%%%%%%%% Extracting the PCA features from test image InputImage = imread('2.jpg'); img = rgb2gray(InputImage);
temp = img(:,:,1);
[irow icol] = size(temp); InImage = reshape(temp',irow*icol,1); inputImage = size(InImage,2); Difference = double(inputImage)-m;% Centered test image ProjectedTestImage = Eigenfaces'*Difference; % Test image feature vector
Euc_dist = [];
q = ProjectedImages(:);
temp = ( norm( ProjectedTestImage - q ) )^2;
Euc_dist = [Euc_dist temp];
[Euc_dist_min , Recognized_index] = min(Euc_dist); OutputName = strcat(int2str(Recognized_index),'.jpg');

Antworten (0)

Kategorien

Mehr zu Eigenvalues finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by