How JPEG actually works (2006)
blogs.msdn.microsoft.com
blogs.msdn.microsoft.com
https://www.impulseadventure.com/photo/jpeg-decoder.html
https://www.impulseadventure.com/photo/jpeg-huffman-coding.h...
Of course, there are also plenty of other "write a JPEG decoder/encoder tutorial" articles out there, of varying quality --- which if anything proves that it's not actually so hard. The standard contains a surprisingly simple and elegant flowchart description of the Huffman encoder/decoder.
The more modern JPEG 2000 encoding based on wavelets can be pushed much farther before visible artifacts appear, and includes a surprisingly efficient lossless mode. Of course, all this improvement is rather moot until common applications actually support it.
That was 12 years ago, and J2K is still pretty much unknown outside of niche applications. I'm not sure what they mean by "surprisingly efficient lossless mode", but decoding J2K is slower than regular JPEG by at least an order of magnitude if not more. The lack of articles about how to write decoders/encoders, or even just how it works in detail, is another sign of its relative obscurity. I've been studying the standard on and off for a few months, intending to write an article or even a decoder, but haven't gotten around to it yet. It is certainly an order of magnitude more complex.
It’s big in digitized documents and medical space where the superior compression has real benefits. One under-appreciated benefit is that the combination of progressive decoding and tiling is perfect for deep zoom services since you don’t want to precompute thousands of tiles per image when your library size is millions of images.
The big problem with JPEG 2000 as I see it was a lack of openness: for a long time, a copy of the spec cost non-trivial money and there was no standard test suite so compatibility was a constant problem. This meant that there was no good open source library and thus that most users had a bad experience relative to other formats. This changed over the last few years and OpenJPEG has become competitive on quality and speed but I’m afraid the damage may have been fatal.
One of the things which makes me sad about that is that it’d be great for progressive images on the web with an extension to srcset to specify the byte ranges for each size, avoiding the need to cache duplicate variants. Unfortunately the lack of high quality libraries and adoption probably means that window has passed, although it would be interesting to see how well a Web Assembly version performs.
True, but I'm sure it doesn't even hold a candle to the challenge of real-time decoding of modern video codecs.
Is it just a chicken-and-egg problem with hardware support, that prevents formats like FLIFF [0] from seeing adoption?
It would have been great if the author of the MSFT article maybe included screenshots or something to preserve the referenced content.
I know the waybackmachine exists, but 2006 doesn't feel that long ago even though it really was.
Isn't there another format recently, FLIF?
https://news.ycombinator.com/item?id=17461955
I made a checkerboard pattern of 8x8 pixels, but I still lose data to colour bleeding when re-encoding (e.g. upload to Facebook or Save to Camera Roll on the iPhone).
Is there some way I can use the "lossless" entropy coding to avoid this problem?
https://www.virusbulletin.com/virusbulletin/2015/03/script-l...
In general signal-processing terms, this is known as preemphasis/equalisation --- since the communications channel will distort the signal in a known way, by sending a signal distorted appropriately in the opposite direction, it will arrive "undistorted" at the destination.
You can also consider using ECC codes, so that any small errors introduced can be corrected.
If saving and sharing can mean changing the image dimensions however, you of course need redundancy by that factor.
But yeah, that’s why we don’t choose lossy compression algorithms for binary data. If every bit counts, there is no entropy you can lose (though a lossless algorithm might find a more efficient representation, so to speak).
Lossy compression removes information by design, you want to keep all bits of information, therefore you have to represent your information in a redundant (and therefore inefficient, by density) way.