% Scoring
%
%  If required image is not displayed (but everything else ok), -2.


% Script GangnamSVD
% Displays a 2-by-3 image where each "tile" is based on a low-rank
% approximation of the Gangnam matrix.

% Compute the SVD of the Gangnam matrix...
fName = 'Gangnam.jpg'; 
A = double(rgb2gray(imread(fName)));
[U,S,V] = svd(A);

% Store the required low-rank approximations in a 2x3 cell array...
i = 0;
C = cell(2,2);
for r = [5 10 20 40 80 160]
   i = i+1;
   C{i} = uint8(U(:,1:r)*S(1:r,1:r)*V(:,1:r)');
end
GangnamArray = [C{1} C{2} C{3} ; C{4} C{5} C{6}];
imshow(GangnamArray)
shg

