You are on page 1of 6

Multimedia And Animation [By- Ms. Shilpy Gupta (M.Tech, BE), Asst. Prof. Dept.

of CSE/IT]

Unit - 2: Image Compression and Standards 2.1 Introduction to images

Refer to the BooK as done in class. Upto 3 D Drawing and Rendering


JPEG (Joint Photographic Experts Group)

Commonly used method of lossy compression for photographic images.

Lossy compression refers to the data compression technique in which some amount of data is lost considered as an attempt to eliminate the redundant or unnecessary information.

2.7.1 JPEG Objectives

The various objectives of using JPEG image format with compression technique are as follows: To be at or near the state of art for degree of compression versus image quality. The standard should be independent of image size. It should be applicable to any image aspect ratio (ratio of the width of the image to its height). Color space and number of colors used should be independent of one another. Standard should be state of art regarding the compression factor & image quality. Sequential and progressive decoding should both be possible.

2.7.2 JPEG Overview

The JPEG compression process can be explained by the following diagram: I/p Picture Preparation Major steps involves: Discrete Cosine Transformation (DCT) Quantization Zigzag scan Picture Processing Picture Processing Entropy Coding O/p


Multimedia And Animation [By- Ms. Shilpy Gupta (M.Tech, BE), Asst. Prof. Dept. of CSE/IT]

DPCM on DC component RLE on AC component Entropy coding DCT: Mathematical operation that transform a set of data, which is sampled at a given sampling rate, to its frequency components. Quantization: procedure of constraining something from a continous set of values (such as the real numbers) to a discrete set (such as integers). It refers to the process of approximating the continous set of values in the image data with a finite set of values. In other words, it divides the image data and round the results according to the required quality. This may cause some loss of data. Zigzag scan: used to group low frequency coefficients in top of vector. It maps an 8 x 8 matrix to a 1 x 64 vector.

. . . .

DPCM on DC component: Differential Pulse Code Modulation (DPCM) ia a modulation technique providing a digital representation of an analog signal where the magnitude of the signal is sampled regularly at uniform intervals. Every sample is quantized to a series of symbols in a digital code, which is usually a binary code. DPCM on the DC component is used for the following purposes: DC component is larger and varied, but often close to previous value (like lossless). Encode the difference from previous 8x8 blocks. RLE on AC component: Run Length Encode is a simple form of data compression in which runs of data are stored as a single data value and count, rather than as the original run. (Runs of data: sequence in which the same data value occurs in many consecutive data elements). 1x64 vector has lots of zeros in it.


Multimedia And Animation [By- Ms. Shilpy Gupta (M.Tech, BE), Asst. Prof. Dept. of CSE/IT]

Encode as (skip, value) pairs, where skip is the number of zeros, and value is the next non-zero component. Send (0,0) as end of block sentinal value. Entropy coding: Entropy is the smallest number of bits needed, on the average, to represent a symbol. Entropy coding is the lossless compression scheme which is independent of the specific characteristics of the medium. In other words, it is the type of lossless coding to compress digital data by representing frequently occurring patterns with few bits and rarely occurring patterns with many bits. JPEG defines several image compression modes by selecting different combinations of the above discussed steps. It defines four modes which themselves include additional variations: The lossy, sequential DCT based mode must be supported by every JPEG decoder. The expanded lossy, DCT based mode provides a set of further enhancements to base mode. The lossless mode has a low compression ratio and allows a perfect reconstruction of the original image. The hierarchical mode accommodates images of different resolutions by using algorithms defined for the other 3 modes. The baseline process uses the following techniques: Block, Minimum Coded Unit (MCU), FDCT (Fourier DCT), Run length Huffman


JPEG DCT Encoding and Quantization

The key to the JPEG compression is a mathematical transformation called DCT.

Its basic operation is to take a signal and transform it from one type of representation to another. In this case the signal is a graphical image. The DCT breaks the source image into NxN matrix. Then DCT is applied on the matrix. The output matrix consists of DCT coefficients containing useful and important data for representation of the image are in the upper left of the matrix and in the lower right, coefficients containing less useful information.


Multimedia And Animation [By- Ms. Shilpy Gupta (M.Tech, BE), Asst. Prof. Dept. of CSE/IT]

(Eye is most sensitive to low frequencies (upper left corners), and less sensitive to high frequencies (lower right corners)). The DC coefficient is at positions 0,0 in the upper left hand corner of the matrix and it represents the average of the other values in the matrix. This step prepares the image for the next step, namely quantization.

The image presented for quantization is considered to be undergone through a little actual image compression. Quantization is a process of reducing the number of bits needed to store an integer value by reducing the precision of the integers. For every element in the DCT matrix, a corresponding value in the quantization matrix gives a quantum value. The quantum value is what is stored in the compressed image. The formula for quantization is simple: DCT (i , j) ------------------Rounded to nearest integer Quantum (i , j)

Quantized value (i , j) =


JPEG Statistical Coding

The final encoding step is statistical coding. JPEG standard allows two types of statistical coding: Huffman coding Arithmetic coding

Huffman Coding
It requires specification of the huffman table or code books. This is done on the basis of the application. There is no standard specified. The standard supports four huffman tables per image in order to provide different tables for each component of a multicomponent image. A huffman code can be determined by successively constructing binary tree whereby the leaves represent the characters that are to be encoded.

Arithmetic Coding
It does not require a separate table. It requires a little more processing for implementation. It provides better compression i.e. 5 to 10% for many images. Unlike huffman coding, arithmetic coding does not code each symbol separately. Each symbol is


Multimedia And Animation [By- Ms. Shilpy Gupta (M.Tech, BE), Asst. Prof. Dept. of CSE/IT]

instead coded by considering all prior data. Thus data dtream encoded in this fashion must always be read from the beginning.

2.10 JPEG Predictive Lossless Mode

The lossless compression mode based on prediction is shown as follows:

Uncompressed Digitized Image data

Prediction Technique

Entropy Encoder Compressed Image Data Tables

Figure. Lossless mode based on prediction.

The lossless mode uses a single pixels as data units during image preparation. Between 2 to 16 bits can be used per pixel. Although all pixels of an image must use the same precision, one can also conceive of adaptive pixel precision. In predictive mode, image processing and quantization use a predictive technique instead of transformation coding. For each pixel X, one of the eight possible predictots is selected. The selection criterion is the best possible prediction of the value of X from the already known adjacent samples A, B, and C.



Figure. Basic prediction in lossless mode.

The number of the chosen predictors, as well as the difference between the prediction and the actual value, are passed to the subsequent entropy encoding which can use either huffman arithmetic coding. This mode supports two types of processing, each with 2 16 bits per pixel. The table of predictors is given below:


Multimedia And Animation [By- Ms. Shilpy Gupta (M.Tech, BE), Asst. Prof. Dept. of CSE/IT]

Selection Value 0 1 2 3 4 5 6 7

Prediction No Prediction X=A X=B X=C X=A+B+C X = A + (B C) / 2 X = B + (A - C) / 2 X = (A + B) / 2

Table. Predictors in lossless mode.

2.10 JPEG Performance

Compression performance is best specified by relating image quality to bits per pixel in the compressed data stream. This relationship depends to some degree or the characteristics of the source image. Some images are harder to compress successfully than others. Figures for some images are: (1) 0.25 0.5 bits per pixel provides moderate to good quality compression, sufficient for some applications. (2) 0.5 o.75 bits per pixel provides good to very good quality compression that is sufficient for many applications. (3) 0.75 1. 5 bits per pixel supports excellent quality compression sufficient for most applications. (4) 1.5 2.0 bits per pixel provides undistinguishable compressed image from the original one, that is sufficient for the most demanding applications.