load clowndata.mat; % This file is downloaded from class website % At this point, you should have a matrix X and matrix "map". whos % This is just to look at some of the matrix values in X X(1:10,1:10) % Show the image of the clown (change the "colormap") image(X) colormap(map) % You can type: help colormap % to see the different names of the built-in color schemes available. % For example, colormap('jet') % Or back to the one for the clown: colormap(map) [U,S,V]=svd(X) % Inspect the singular values plot(log(diag(S))) % Create a rank-50 approximation (and the error) N=50; PartialRecon=U(:,1:N)*S(1:N,1:N)*V(:,1:N)'; image(PartialRecon) M=N+1; Leftover=U(:,M:end)*S(M:end,M:end)*V(:,M:end)'; imagesc(Leftover) %If you add the images, you get the clown back again image(round(PartialRecon+Leftover))