numbsingvals=80;
a=imread('ColgatePhoto.png');

red = double(a(:,:,1));
green = double(a(:,:,2));
blue = double(a(:,:,3));

[u,s,v] = svds(red, numbsingvals);
imred = (u * s * transpose(v));

[u,s,v] = svds(green, numbsingvals);
imgreen = (u * s * transpose(v));

[u,s,v] = svds(blue, numbsingvals);
imblue = (u * s * transpose(v));

myint=@(im) uint8( 256*(im-min(im(:)))/(max(im(:))-min(im(:))) );
newa(:,:,1) = myint(imred);
newa(:,:,2) = myint(imgreen);
newa(:,:,3) = myint(imblue);

imwrite(newa,'svd80.png');
