function demo1(filename)


I = imread(filename);
red = double(I(:,:,1));
green = double(I(:,:,2));
blue = double(I(:,:,3));
figure
imshow(I);
title('Original image');
% compression using k rank approximation
k = [10 30 60];


for i = 1 : length(k)
    % svd for the red 
    [u_r s_r v_r] = svds(red,k(i));
    red_k = uint8(u_r * s_r * transpose(v_r));
    % svd for the green 
    [u_g s_g v_g] = svds(green,k(i));
    green_k = uint8(u_g * s_g * transpose(v_g));
    % svd for the blue
    [u_b s_b v_b] = svds(blue,k(i));
    blue_k = uint8(u_b * s_b * transpose(v_b));
    im(:,:,1) = red_k;
    im(:,:,2) = green_k;
    im(:,:,3) = blue_k;
    figure
    imshow(im)
    mytitle = strcat('Rank k=',int2str(k(i)));
    title(mytitle)
end


