**1 Answer**

written 7.9 years ago by |

Joint Picture Expert Group is a lossy/lossless compression method for color and gray scale still images.

The compression steps involved in JPEG are:

i. Color images are transformed from RGB to yCrCbcolour space. This step is not required for gray scale images.

ii. Color images are downsampled by creating low resolution pixels from original ones. (This is used only when hierarchical compression is needed and it is always skipped for grayscale images).

iii. The downsampling is not done for luminance component but only for Cr and Cb components. Downsampling is done either at the ratio of 2:1 both horizontally and vertically called 4:1:1 sampling or at the ratio of 2:1 horizontally and 1:1 vertically called as 4:2:2 sampling.

iv. If the picture is not in color (gray scale), each pixel can be represented by an 8-bit integer (256 levels). If the picture is in color, each pixel can be represented by 24 bits (3× 8 bits), with each 8 bits representing red, blue, or green (RBG).

v. In JPEG, a gray scale picture is divided into blocks of 8 × 8 pixels (see Figure3).

vi. The purpose of dividing the picture into blocks is to decrease the number of calculations because, the number of mathematical operations for each picture is the square of the number of units.

vii. The whole idea of JPEG is to change the picture into a linear (vector) set of numbers that reveals the redundancies. The redundancies (lack of changes) can then be removed by using one of the text compression methods. A simplified scheme of the process is shown in Figure4.

**Organization into group :**The pixels of each color component are originated in groups of 8×8 pixels. If the no. of rows and columns are not multiple of 8 then bottom rows or rightmost column are duplicated as many times as necessary.

**DCT :**i. In this step, each block of 64 pixels goes through a transformation called the discrete cosine transform (DCT). The transformation changes the 64 values so that the relative relationships between pixels are kept but the redundancies are revealed.

ii. The DCT is applied to each 8×8 block of data to get the 64 DCT coefficients. They represent average pixel value and successive higher frequency changes within the block of data. Due to the precision of arithmetic some amount of loss is introduced due to DCT.

**Quantization :**i. Here, we divide the number by a constant and then drop the fraction. This reduces the required number of bits even more.

ii. In most implementations, a quantizing table (8 by 8) defines how to quantize each value.

iii. This is done to optimize the number of bits and the number of 0s for each particular application.

iv. Each of the 64 frequency components are divided by a separate number called quantization coefficient (Q) and then rounded to an integer. This causes permanent loss of information. Large Q’s causes more loss and hence higher frequency components typically have large Q’s. Each of the 64 Q’s is a parameter defined by JPEG standard.

v. Welose some information here that is not recoverable.

vi. The 64 Quantized frequency coefficients which are not integer and are encoded using either RLE or Huffman coding.

vii. In the final step header information and all parameters used are added.

**Compression :**After quantization, the values are read from the table, and redundant 0s are removed. However, to cluster the 0s together, the table is read diagonally in a zigzag fashion rather than row by row or column by column. The reason is that if the picture changes smoothly, the bottom right corner of the T table is all 0s.

JPEG supports several different Modes.

**1. Sequential DCT-Based Mode :**- Image components are compressed either individually or in groups (by interleaving).
- In the sequential mode of operation encoder encodes every pixel in a single left to right and top to bottom scan.
- A restricted mode that must be included in any decoder.
- Color Components interleaving is done to save buffer size.

**2. Progressive Mode:**- A sequence of “scans”, each codes a part of the quantized DCT coefficients data. Two ways of doing this:
- Spectral selection: coefficient are grouped into spectral bands, and lower-frequency bands sent first.
- Successive Approximation: data is first sent with lower precision and then refined. Gives better quality for lower bit-rates.

**3. Hierarchical Mode :**- Progressive coding with increasing spatial resolution between stages.
- First stage (lowest resolution) is coded using sequential or progressive modes.
- Output of each stage is up-sampled (if necessary) and becomes the prediction for the next stage.
- Image quality at extremely low bit-rates is much better than all other modes, but at cost of higher bit-rate (~30%) at completion.