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

Matlab coding http://courses.washington.edu/am301/hw/pics.mat Download a library

ID: 3845140 • Letter: M

Question

Matlab coding

http://courses.washington.edu/am301/hw/pics.mat

Download a library of 40 faces (Resolution 96 times 64) from http://courses.washington.edu/am301/hw/pics.mat However DO NOT upload pics.mat to Scorelator. Use load to import the data to Matlab The first 10 faces are for j = 1:10 subplot (2, 5, j):pcolor (pics (:,:, j)): shading interp:colormap (gray): end a. Calculate the "average" face of the 40 faces. Save the average face as a 96 times 64 matrix in Al.dat using the "save ascii" command. b. Subtract the average face from all 40 images. The resultant 40 images are thus the anomalous faces. Save the first anomalous face as a 96 times 64 matrix in A2. dat using the "save -ascii" command.

Explanation / Answer

The following code does the required job -

p=load("pics.mat");
pics = p(1).pics;
av=zeros(96,64);
for k=1:40
   av=av+pics(:,:,k);
end
av = av/40
save a1.dat -ascii av
for j=1:40
   ano_face = pics(:,:,j) - av;
if(j==1)
   save a2.dat -ascii ano_face
end
end