How does JPG store pixels?

I'm wondering if Windows has a native pixel format corresponding to JPG pixel format.
closed account (z05DSL3A)
Good starting point...
JPEG 'files' & Colour (JPEG Pt1)- Computerphile
https://www.youtube.com/watch?v=n_uNPbdenRs&spfreload=10
Alright, so JPEG is a container format and JFIF is the actual image format.

What I got from that video is that JFIF most commonly stores pixels as Y'CbCr. Does that mean the image is stored three times, as Y, Cb, and Cr separately, and then combined by the codec?

What I don't understand is when I open a JPEG in Windows, convert it to, say, 24bppBGR, copy the pixels to a file and apply LZ compression, my file ends up much larger than the original JPEG.
closed account (z05DSL3A)
Does that mean the image is stored three times, as Y, Cb, and Cr separately, and then combined by the codec?
Perhaps, I can't remember if they are split out into three channels in the file or not.

What I don't understand is when I open a JPEG in Windows, convert it to, say, 24bppBGR, copy the pixels to a file and apply LZ compression, my file ends up much larger than the original JPEG.
Think of it like a bounce castle. When you have it in the back of a van it is small and doesn't look like a castle. When you open it up and decompress it (add air) it becomes much larger and looks like a castle.

When you open a JPEG file it will be decompressed, reconstructed into the full size image in memory, this can be much larger than the file.
The JPEG file is a lot tinier than your LZ file?
That's exactly why we use JPEG.
closed account (z05DSL3A)
Opps, I missed the 'you apply LZ Compression and your file is larger' part.

If all you do is apply the compression to your raw data then you will be larger because JFIF, as the video says, does a lot more to reduce the size of the data.
OK, I watched the video again and I definitely misunderstood some stuff. E.g., JPEG is not the file format, but is the compression method. Also there is a loss of color information(down sampling) in addition to the compression. I didn't watch the second video so some things are still unclear, but I can tell I'm in over my head here. For now I'll stick with Windows codecs to do encoding ;-)
closed account (z05DSL3A)
Yep, it's a big ol' can o' worms.
Hi,

IIRC from a long time ago, JPEG does all sorts of things, including storing colours & luminosity, discrete cosine functions, diagonal run length encoding, plus other stuff I have obviously forgotten about. When I read about it, it was an 8 stage process.

The discrete cosine function is a way to save lots of space. Imagine you have a graph of the colour numbers of 1 row of pixels. Parts of this graph can be modelled using cos functions (hence the discrete), and there is only a need to store the parameters of those functions, not all the individual colour numbers. That is why a JPEG file of something uniform in colour (blue sky say) will be much smaller than a JPEG of vegetation, because the latter will have lots of discrete cos functions to cope with all the changes in colour.

So using this, files can be reduced to as low as 5% of the original, which is way better than an average compression routine.

Hope all is well :+)
Topic archived. No new replies allowed.