Singular vector decomposition and low rank approximation application for image compression

Created Diff never expires
21 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
37 lines
7 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
23 lines
function C=compressimage(k)
function C=compressimage2(k)


A=imread('/home/phung/Pictures/einstein.jpg');
A=imread('/home/phung/Pictures/einstein.jpg');


B=A(:,:,1);
B=A(:,:,1);


B=im2double(B);
B=im2double(B);


% imshow(B);
% imshow(B);


[U,S,V]=svd(B);
sigma = B' * B;

[m,n]=size(S);

n=min(m,n);

% plot([1:n,diag(S),'.');

% axis([-10,n+1,0,300]);

% hold on

C=diag(S)';

for i=k+1:n


S(i,i)=0;
[U,S,V]=svd(sigma);


end
UR = U(:,1:k);


B=U*S*V';
Breduced = B *UR;


imshow(B);
Breconstructed = Breduced * UR' ;


C=C';
imshow(Breconstructed);


end
end