2

I am performing an SVD image compression- SVD allows you to approximate the actual image matrix by a lower rank matrix of rank v, thus achieving compression(link).

Here's the pseudo-code:

load image_mat             % load image as a matrix
[U, S, V] = SVD(image_mat) % U and V are square, S is diagonal (mxn)
set S(v+1:end,:) = 0; set S(:,v+1:end) = 0;  % set all values after rank v as zero
new_image = U*S*V';

The problem I am facing is this: Once I perform the lower rank approximation, the old and the new matrix are of the same size (m x n). Both images contain the same number of pixels (since U and V do not change.) Thus, the file size does not (read: CANNOT!) change. However, I see the image quality changing drastically for different values of v.

What am I missing?

EDIT: Further explanation:

Below is the result of the SVD decompression, by rank reduction: RHS figure contains only 10% of the original singular values My question is, if the number of pixels in both the pictures remains the same, how would I get a file size reduction (decompression) ? Except the fact that the matrix of singular values (S) is changing in size, everything else pretty much remains the same (despite the obvious drop in image quality), i.e the new matrix constructed after decompression has the same size 512 x 512 as the original image.

ashishv
  • 181
  • 1
  • 3
  • 12
  • You are missing some compression-basics. If you save these images as uncompressed pixels like a bitmap, of course they will be the same. If you save them with compression activated like png, it's likely that the SVD-preprocessed image will be smaller as you probably changed the entropy (which is one of the important characteristics for compression algorithms). But that's just the surface. If you are clever, you are just saving the two vectors and the low-rank matrix and reconstruct the image during decompression. Of course these objects can be compressed further. – sascha Nov 02 '16 at 17:57
  • @sascha 2 vectors? Do you mean the U and V? – ashishv Nov 02 '16 at 19:11
  • @sascha I understand your point about the entropy. I computed the entropy and that makes sense with my understanding now. However, interestingly after I perform the compression, there is a threshold to how much the entropy can reduced. When I delete 95% of the singular values the entropy starts increasing again! – ashishv Nov 02 '16 at 19:14
  • @sascha Lastly, I realize that compression occurs in terms of data and not information. Hence, after decompressing I would end up getting the same size. Is this correct? – ashishv Nov 02 '16 at 19:15
  • This is all way to vague and therefore hard to follow. Write a more formulized description of what you are doing and what you want to achieve. I think it's just some experiment as this will never be able to compete with classic image-compression algorithms. Yes i meant the vectors U and V. Of course removing some parts of the singular-values will have *nonlinear* effects. Everything else is hard to answer because of missing information. I highly recommend some basic reading about compression itself (theory). – sascha Nov 02 '16 at 19:21
  • Take a look at this question: [Using SVD to compress an image in MATLAB](http://stackoverflow.com/questions/13614886/using-svd-to-compress-an-image-in-matlab) – Rodrigo de Azevedo Nov 02 '16 at 19:40
  • @sascha I added some more details. I have read about compression but all that has lead me to believe logically that the file size should change somehow (?) but that obviously that isn't the case. – ashishv Nov 02 '16 at 20:36
  • @RodrigodeAzevedo I don't think I have a problem with the algorithm. I have added some more details relating to a conceptual problem! – ashishv Nov 02 '16 at 20:38
  • The point of SVD compression (which I can't recommend for actual use, but it's fun) is that you delete the eigenvectors corresponding to small eigenvalues. So, less stuff. Of course after you *decompress* you have the same number of pixels again, by definition. – harold Nov 02 '16 at 20:39
  • @ashishv You don't quite understand the algorithm. The point of compression via SVD is to store a few singular values and vectors, not to store a matrix. From the few singular values and vectors, you can then reconstruct the matrix. It's like in Fourier analysis, where one stores Fourier coefficients rather than samples of the signal. – Rodrigo de Azevedo Nov 02 '16 at 20:58
  • @RodrigodeAzevedo I do get it now! Thank you! I think my understanding was a little twisted, since I expected the output image to have smaller file size, but that didn't add up. – ashishv Nov 02 '16 at 22:18

1 Answers1

0

You are not missing anything. the original image has mn data while the compressed one has k+km+k*n data where k is the rank.