How to check whether an image is compressed or not after applying SVD on this image (relative to the size of the compressed image on the disk)

I=imread('cameraman.tif'); figure(1),imshow(I) I1=im2double(I); [U,S,V]=svd(I1); figure(2),imshow(I1) for j=1:90 I2=U(:,1:j)*S(1:j,1:j)*V(:,1:j)'; end figure(3),imshow(I2) I3=U*S*V'; figure(4),imshow(I3) 

this is the code that I wrote to decompose SVD, I got the correct output. But the size of the compressed image is larger than the original image, so how to calculate whether the svd image is compressed after compression or not, it means that I got the image size on disk after applying svd iterations larger than the original image.

+4
source share
2 answers

Here is an example:

 I = imread('cameraman.tif'); X = im2double(I); %# SVD [USV] = svd(X); %# variance explained by each eigenvector variances = abs(diag(S).^2); plot(cumsum(variances)./sum(variances), 'b.-'), ylim([0 1]) title('SVD'), xlabel('i^{th} Component'), ylabel('Variance explained') %# iterate over number of components to keep figure subplot(121), imshow(X), title( sprintf('size=%d',numel(X)) ) subplot(122) for p = 1:(size(U,2)/2-1) %# truncated SVD Up = U(:,1:p); Vp = V(:,1:p); Sp = diag(S(1:p,1:p)); %# reconstruct/compress XHat = Up * diag(Sp) * Vp'; %'# approximation err = mean( abs(X(:)-XHat(:)) ); %# mean absolute error sz = (numel(Up) + numel(Vp) + numel(Sp)); %# new size %# show imshow(XHat) title( sprintf('p=%d, size=%d, err=%g', p, sz, err) ) %# flush output drawnow end 

varsvd_approx

+4
source

I think you are missing the decomposition of SVD. the size of the restored image will remain the same as the number of pixels. what SVD does allows you to store / transmit less information ... in other words, in your case, you can transmit 256 ^ 2 doubles or (256 * j) + j + (256 * j). for j out of 90 it is 46170 (against 65536)

+1
source

All Articles