141 points · by dmicz · 2y ago · 22 comments
I think for a fair comparison for any actual compression you'd need to consider the effects of quantization of the SVD output itself (in say the rows/columns of U,V alone, since you can keep the singular values at high-precision w/o appreciable cost). [I'd guess they'd be ok for 2 bytes/element, but 1 byte might be a problem].
[0] Said code comment is "# Plotting the principal components".
[1] https://en.wikipedia.org/wiki/Principal_component_analysis
One small quibble, with JPEG you don’t “lose” the “high-frequency” data; that would blur the image. You approximate it, so you could argue you “lose” some of it. JPEG is not very good at compressing high-frequency data, which is basically the edges of things, so if your JPEG has sharp edges, you are not losing much high-frequency data, just compressing everything else.
Personally I think that innovation in explanation/illustration of abstract mathematical topics is one of the most valuable kinds of progress, but it’s rarely talked about as such. When someone comes up with the right framework, visualisation, or metaphor for explaining a complex and abstract subject in a way that induces “the right” mental model, and this new teaching “tool” proliferates, that is just a beautiful thing to see.
To go from JPEG to lossy WebP (really, VP8 intra frames), the main differences are
(a) using smaller (4x4) transform blocks instead of 8x8,
(b) noticing that if you take just the first coefficient in each block, it looks like a lower resolution of the original image, and applying another 4x4 transform to those coefficients,
(c) adding more sophisticated prediction between blocks (e.g., subtract the pixel on the right edge of the previous block from all the pixels in the same row of the current block before transforming them, or something similar to predict in other directions),
(d) filtering along block edges to reduce blocking artifacts (many JPEG decoders do this, but WebP/VP8 make it a mandatory part of the standard), and
(e) using arithmetic coding instead of Huffman coding.
There are of course other minor differences in the details.
But the main mechanism that underlies both is a transform that can be derived from the SVD if one assumes a simple statistical model of natural image data.
Those are some very interesting comments!
I'd be interested (and this is purely "academic" curiousity) IF there was:
Something mathematical -- which would underly all image compression algorithms; that is, if all image compression algorithms could be shown ("proven" I guess -- I am not a professional Mathematician, only armchair, so bear with me!) to belong to a specific class of generalized compression algorithms or (ideally!) a single "parent" (for lack of a better word) image compression algorithm -- that would give rise to all other image compression algorithms, no matter how diverse or not mathematically related they would all seem...
The use of Matrices (which model systems of linear equations, which in turn, enumerate/list/make clear/table -- relationships between factors in those equations) -- would seems to be a good starting point for this Mathematical inquiry, should it be made...
Maybe I should phrase this a little bit better...
Maybe it's something like (as a future goal for the Mathematicians of the world), "for every image compression algorithm X, show/prove that X is related to <parent Mathematical principle involving matrices>"...
Or something like that...
Sort of like a grand unifying theory of image compression...
Anyway, your comments are highly interesting.
It seems like you might be part of the way there for something like a rigorously mathematically unified (and proven!) future understanding of image compression!
1. Use a reversible linear transform to transform the image into some other space. (It'll still require the same amount of data to represent) 2. Throw away a bunch of the values (set them to zero, or round them to low precision, etc) 3. Now that there are some repetitive zeroes or whatever, a conventional data compression algorithm (like LZW, Huffman, or interval/arithmetic) can make it smaller
Even simple things like resizing an image smaller can be fit into this framework: step 1 is a simple blur, step 2 sets a bunch of pixels to zero, step 3 discards them.
(I don't think fractal compression can be fit into this framework, but I could be wrong. That's the only exception I can think of offhand.)