Randy Berbaum wrote:
> What you may not have understood is that Jpeg compression is variable. It
> is not a hard and fast ratio. Any image with large areas of the same color
> compress smaller than the same size area with lots of detail. So if you
> take a photo at night that is mostly dark with a small lit subject in the
> middle would compress very small (all that black compresses to only a few
> digits). But a daytime image with lots of details and small patches of
> color needs lots more data to describe.
>
> Here's an example of how this works. If you have an image that is 16
> pixels in a 4x4 grid and the entire image is a single color that can be
> called "1", the entire image could be compressed by calling it "1x16"
> (color one repeted 16 times). While the same image space with 16 different
> colors would take more room,
> "1x1,2x1,3x1,4x1,5x1,6x1,7x1,8x1,9x1,10x1,11x1,12x 1,13x1,14x1,15x1,16x1".
> As you can see the compression will vary greatly with the subject. And
> this is before the jpeg process gets into its "lossy" formula. BTW this is
> just an example of how discrepancys in compression can happen, not an
> exact description of how the jpeg format works.
That's a pretty fair description.
Working in the "lossy" component then, you get something like this:
Say you have a section of sky, for the sake of argument, a strip one pixel wide
and 8 pixels long. Each pixel is a slightly different shade of blue - say for
easy example it goes in a steady gradient from from shade "1" to shade "8".
Now normal lossless compression would probably not reduce this at all, because
each pixel is a different value. But set for the highest-quality,
lowest-compression level of lossy compression, and what you might get is the
software deciding that the difference is small enough that if pixels 1 and 2
were the same shade, it wouldn't be noticeable... same with 3 and 4, and so
on... so instead of a strip of color of shades
"1x1,2x1,3x1,4x1,5x1,6x1,7x1,8x1,", the software would discard every second
pixel, and describe it as "1x2,3x2,5x2,7x2,9x2". Those intermediate pixels are
now gone, so when the image is displayed, it creates essentially a rougher,
"stepped" gradient. This is why it's called "lossy" compression.
As you reduce the quailty level and increase the compression, you get smaller
files, but less accurate color... for example, the next step might start with
the "2" pixel and discard one pixel to either side... so you'd get
"2x3,5x3,8"... or it may take the first pixel and discard the next two, for
"1x3,4x3,7x2". That decision would be made by the software depending on the
exact content and the specific algorithm used.
Obviously this is a VERY simplistic description, but it gives a bit of an idea
of how "lossy" compression works. BTW, MP3 compression uses a similar concept
on audio files, determining what parts of sound wouldn't normally be noticeable
(say, a wrist watch ticking on a drummer's wrist while he's playing!), and
simply discarding that data.