% Script TrySVD.m % load the clown and try some different levels of compression % via fewer and fewer singular values close all; clear all; load clown; size(X) colormap(gray); image(X) [U,S,V] = svd(X); imdiff = []; for j = 160:-25:10 Y = U(:,1:j)*S(1:j,1:j)*V(:,1:j)'; % note that you need that ' at end! figure colormap(gray) image(Y) imdiff = [imdiff norm(X-Y)/norm(X)]; end disp('Pay careful attention to fine details like the hair.')