Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<p>I am currently tryn to run a program to use eigenfaces for face recognition o

ID: 3636438 • Letter: #

Question

<p>I am currently tryn to run a program to use eigenfaces for face recognition on Matlab.<br />The code so far is this<br /><br />clear all<br />input_dir = 'C:/Users/David/Desktop/Hdip Project/Sample Mathlab Code/Images';<br />image_dims = [108, 117];<br /><br />filenames = dir(fullfile(input_dir, '*.pgm'));<br /><br />num_images = numel(filenames);<br />images = [];<br />for n = 1:num_images<br /> filename = fullfile(input_dir, filenames(n).name);<br /> img = imread(filename);<br /> img = rgb2gray(img);<br /> %img = imresize(img, image_dims); <br /> if n == 1<br /> images = zeros(prod(image_dims), num_images);<br /> end<br /> images(:, n) = img(:);<br />end<br /><br />mean_face = mean(images, 2);<br />shifted_images = images - repmat(mean_face, 1, num_images);<br /><br />[evectors, score, evalues] = princomp(images');<br /><br />num_eigenfaces = 10;<br />evectors = evectors(:, 1:num_eigenfaces); ***<br />features = evectors' * shifted_images;<br /><br />feature_vec = evectors' * (input_image(:) - mean_face);<br />similarity_score = arrayfun(@(n) 1/(1+norm(features(:,n) - feature_vec)), 1:num_images);<br />[match_score, match_ix] = max(similarity_score);<br />figure, imshow([input_image reshape(images(:,match_ix), image_dims)]);<br />title(sprintf('matches %s, score%f', filenames(match_ix).name, match_score));</p>
<p>I keep getting an error at the line indicated with ***. The problem is " index exceeds matrix dimensions".</p>
<p>If anybody can help, I will provide xtra points.</p>

Explanation / Answer

01 while (!fin.eof()) 02 { 03 //Input names and place them in outfile 04 fin>>names[count_n]; 05 fout>names[count_n]; 08 fout>coord[count_c+2]; 12 fin>>coord[count_c+4]; 13 fin>>coord[count_c+6]; 14 fin>>coord[count_c+8]; 15 //Find y coordinates 16 fin>>coord[count_c+1]; 17 fin>>coord[count_c+3]; 18 fin>>coord[count_c+5]; 19 fin>>coord[count_c+7]; 20 fin>>coord[count_c+9]; 21 //Output names and coordinates neatly 22 fout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote