A = imread(['Oxford-University-square-logo.jpg']); % load image A = im2double(rgb2gray(A)); % image to matrix clf,figure(1), subplot(2,2,1) imshow(A), title('original image') subplot(2,2,3:4) semilogy(svd(A),'.-'),ylim([1e-15 norm(A)]),grid on xlabel('rank r') title('singular values') %% now do low-rank approximation r = 40; % rank [U,S,V] = svd(A); Ar = U(:,1:r)*S(1:r,1:r)*V(:,1:r)'; % truncated SVD subplot(2,2,2) imshow(Ar); title(['rank ',num2str(r),' approximation'])