JPEG compression

JPEG stands for Joint Photographic Experts Group, which is a standardization committee. It also stands for the compression algorithm that was invented by this committee.

There are two JPEG compression algorithms: the oldest one is simply referred to as ‘JPEG’ within this page. The newer JPEG 2000 algorithm is discussed on a separate page. Please note that you have to make a distinction between the JPEG compression algorithm, which is discussed on this page, and the corresponding JFIF file format, which many people refer to as JPEG files and which is discussed in the file format section.

JPEG is a lossy compression algorithm that has been conceived to reduce the file size of natural, photographic-like true-color images as much as possible without affecting the quality of the image as experienced by the human sensory engine. We perceive small changes in brightness more readily than we do small changes in color. It is this aspect of our perception that JPEG compression exploits in an effort to reduce the file size

How JPEG works

The JPEG algorithms performs its compression in four phases:

  1. First, the JPEG algorithms first cuts up an image in separate blocks of 8×8 pixels. The compression algorithm is calculated for each separate block, which explains why these blocks or groups of blocks become visible when too much compression is applied.
    Humans are more sensitive to changes in hue (chrominance) than changes in brightness (luminance). The JPEG algorithm is based on this difference in perception. It does not analyse RGB or CMYK color values but instead the image data are first converted to a luminance/chrominance color space, such as YUV. This allows for separate compression of these two factors. Since luminance is more important than chrominance for our visual system, the algorithm retains more of the luminance in the compressed file.
  2. The next step in the compression process is to apply a Discrete Cosine Transform (DCT) for the entire block. DCT is a complex process that is let loose on each individual pixel. It replaces actual color data for each pixel for values that are relative to the average of the entire matrix that is being analysed. This operation does not compress the file, it simply replaces 8×8 pixel values by an 8×8 matrix of DCT coefficients.
  3. Once this is done, the actual compression can start. First the compression software looks at the JPEG image quality the user requested (e.g. Photoshop settings like ‘low quality’, ‘medium quality’,…) and calculates two tables of quantization constants, one for luminance and one for chrominance. Once these tables have been constructed, the constants from the two tables are used to quantize the DCT coefficients. Each DCT coefficient is divided by its corresponding constant in the quantization table and rounded off to the nearest integer. The result of quantizing the DCT coefficients is that smaller, unimportant coefficients will be replaced by zeros and larger coefficients will lose precision. It is this rounding-off that causes a loss in image quality.
  4. The resulting data are a list of streamlined DCT coefficients. The last step in the process is to compress these coefficients using either a Huffman or arithmetic encoding scheme. Usually Huffman encoding is used. This is a second (lossless) compression that is applied.

Advantages

By putting 2 compression algorithms on top of each other, JPEG achieves remarkable compression ratios. Even for prepress use, you can easily compress a file to one fifth of its original size. For web publishing or e-mail exchange, even better ratios up to 20-to-1 can be achieved.

JPEG decompression is supported in PostScript level 2 and 3 RIPs. This means that smaller files can be sent across the network to the RIP which frees the sending station faster, minimizes overhead on the print server and speeds up the RIP.

Disadvantages

The downside of JPEG compression is that the algorithm is only designed for continuous tone images (remember that the P in JPEG stands for Photographic). JPEG not does not lend itself for images with sharp changes in tone. There are some typical types of images where JPEG should be avoided:

  • images that have had a mask and shadow effect added to them in applications like Photoshop.
  • screendumps or diagrams.
  • blends created in Photoshop.
  • images containing 256 (or less) colors.
  • images generated by CAD-CAM software or 3D applications like Maya or Bryce.
  • images that lack one or more of the process colors. Sometimes images are created that use for instance only the magenta and black plate. If such an image is compressed using JPEG compression, you may see artefacts show up on the cyan and yellow plate.

Because of its lossy nature, JPEG should only be used during the production stage of prepress (making PostScript or PDF, imposing, proofing, outputting). During the create process when images are still edited, cropped and colour corrected, each new SAVE-command leads to extra loss of image quality when JPEG is used.

I have seen older level 2 RIPs stumble over JPEG decompression from time to time. Simply resending the file solved the problem.

Where is JPEG compression used

JPEG compression can be used in a variety of file formats:

  • EPS-files
  • EPS DCS-files
  • JFIF-files
  • PDF-files
8 August 2013

4 Responses to “JPEG compression”

  1. Allan Bardon says:

    So we charge our customers top dollar for the highest resolution scans possible, Then, right before we ship the product, we let a computer decide on how much of that product really gets shipped, based on the fact the customer will never notice.
    hmmmm.
    OK

  2. Daniel says:

    > Humans are more sensitive to changes in hue
    > (chrominance) than changes in brightness (luminance).

    Isn’t that backwards? Note that later the same paragraph says:

    > Since luminance is more important than chrominance for
    > our visual system, …

  3. yossi says:

    i would like to have table with size of JPEG files in D1 size (i.e 720×576 PAL) and different compression quality,,

  4. khaaaaaaaaaan says:

    it was reallly helpful for meeeeeeeeeeeeeeeeeeeeee


Advertising