How do I fix the result of the code?.

3 visualizaciones (últimos 30 días)
Tobechukwu Ejike
Tobechukwu Ejike el 1 de Oct. de 2018
Comentada: JohnGalt el 1 de Oct. de 2018
images = readFiles();
%Changing directory to code folder to run all fns
% cd 'C:\Users\Deval\Desktop\Face Recognition\Code\'
error_plot = zeros(1,30);
%Selecting 1 to 30 eigenvectors for recognizing the face to plot and find optimal subspace dimensionality
%Optimal subspace dimensionality is a subspace beyond which your face recognition improve very minimally(negligible) or
%we can say that the minimum no of eigenvectors that represents your eigenfaces basis and detects image accurately.
%Here loop runs 1 to 30 selecting no of eigenvectors to plot and find optimal subspace dimensionality.
for no_of_eigenvectors = 1:1:30
%Face Recognition fn applied on training set of images
[u,A,mean_face] = faceRecognition(images,no_of_eigenvectors);
%Flattens the test image matrix into vector
test_image = flatten_image('image_0021.jpg');
%Subtracting average face from test image
test_minus_mean = test_image - mean_face;
%Calculating weights of Training Images
weights_images = weights(A,u,1);
%Calculating weights of Test Images
weights_test_image = weights(test_minus_mean,u,0);
%Finding no of images in training dataset
iter = size(weights_images,2);
%Array to store difference in weights between test image and training images to find best match
err = [];
for i = 1:iter
err(i) = norm(weights_test_image - weights_images(:,i));
end
%Storing min error which is our best match
[error,image_no] = min(err);
%Displaying error values as we increase no of eigenvectors
j= no_of_eigenvectors;
fprintf('No of eigen components %d --> Error %d --> Image No %d\n',error,image_no);
error_plot(j) = error;
%Display image is function to display the image it recognized closest to the person after calculating error
%display_image(A(:,image_no));
end
%Plot of error analysis to check after how many eigenvectors the results are more or less the same
%See the plot and find no of eigenvectors for which error decrease very minimally and recognizes face accurately
x = 1:1:30;
figure;
plot(x,error_plot)
title('Error Analysis')
xlabel('No of eigenvectors')
ylabel('Error')
I am trying to create a graph that shows an error analysis for the number of eigenvectors but my result comes out like this: No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No No of eigen components 0 --> Error 21 --> Image No
  1 comentario
JohnGalt
JohnGalt el 1 de Oct. de 2018
the line:
fprintf('No of eigen components %d --> Error %d --> Image No %d\n',error,image_no);
has 3 integers (%d) but only 2 arguments at the end... are you missing a j? that is, should the line be:
fprintf('No of eigen components %d --> Error %d --> Image No %d\n',j,error,image_no);

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by