JPEG stands for Joint Photographic Expert Group, the creators of the
standard.
JPEG was designed to compress photographic quality images in either
gray scale or full color and does not work well with line drawings or
black and white images.
JPEG exploits the limitations of human vision:
We do not see every detail
of an image - certain things escape our notice.
JPEG allows parameters
to be set that decide on the degree of compression.
The greater the
compression, the lower the quality, and the more noticeable the flaws
are.
A 5:1 compression or less is virtually undetectable by human eyes
on reasonable quality monitors (or on paper which has a higher resolution
with even low quality laser printers).
Compressions of 10:1 or 20:1 are often used, however. Even 100:1
compression is possible, but with low quality results.
The JPEG compression algorithm generally begins with a 24-bit stored
image, and can often lower the requirement to 1-2 bits per pixel!
JPEG tries to remove redundant information. For example, if half of a picture
consists
of blue sky, the beginning and end of this single color can be stored
so that the entire range can be recreated when the picture is shown. Although
some content may be lost at higher
compressions, our eyes fill in the gaps until the compression gets too great.
There are two components to how the human eye views color - one is the
intensity of the color, and the other is how much the
intensity varies
along the picture:
Humans can't discern a high degree of intensity
changes especially at high intensities.
JPEG converts 8x8 blocks of pixels
to numbers representing these intensity differences.
A lossy process
then removes pixels representing small changes.
The JPEG algorithm operates in three steps:
Step 1:
Discrete Cosine Transformation (DCT)
Step 2: Coefficient Quantization
Step 3:
Entropy Encoding
Steps 1 and 3 are lossless. (There is a lossless version of JPEG whose Step
2 uses a method involving a predictive/adaptive function which predicts
upcoming pixels based on previous pixels (think of the blue sky)).
To reconstruct the picture, the compressed version is decoded and shown on the
screen. It reconstructs the quantized data and then recreates the 8x8
blocks again.
JPEG can reduce the storage size to 1/100 of the original, but often 1/20 JPEG
compression is used because more than that causes a degradation of the
picture to our eyes.
It does well on natural pictures that don't have sharp edges.
Nice
diagram of JPEG compression algorithm