Sie sind auf Seite 1von 29

JPEG

JPEG - Introduction

Since the mid-1980s, the ITU and ISO had been


working together to develop a joint international
standard for the compression of still images.
JPEG became an international standard in 1992.
Officially, JPEG [jpeg] is the ISO/IEC international
standard 10918-1: digital compression and coding of
continuous-tone still images, or the ITU-T
Recommendation T.81.
JPEG - Joint Photographic Experts Group was formed
to develop a still image color data compression
standard.

JPEG Modes of Operation

The JPEG standard includes two basic compression methods, which


has different modes of operation.
Lossy process

Lossless process

DCT-based
sufficient for many applications
Prediction-based

JPEG has four basic modes of operation

Baseline Lossy Compression based on DCT and quantization Tables


(sequential DCT based mode)
Extended Lossy Compression options (hierarchical and progressive
compression modes)
JPEG Lossless compression mode (DPCM with Huffman coding)

Sequential DCT-based encoding


algorithm

Also known as the Baseline algorithm which is known


as the heart of JPEG coding standard.

Sequential DCT-based encoding


algorithm

The original image is partitioned into 8 x 8 pixel


blocks. and each block is independently
transformed using the DCT.

Sequential DCT Normalization


array

The DCT coefficients are scaled using a userdefined normalization array that is fixed for all
blocks.

For the baseline system, four different normalization


arrays are allowed (e.g., to accommodate luminance
and chrominance components of an image).

Each component of the normalization array,


Q(u,v), is an 8-bit integer that in effect
determines the quantization step size.

Sequential DCT Normalization


array

The quality and bit rate of an encoded image can be


varied by changing this array.
The normalization matrix may be designed according
to the perceptual importance of the DCT coefficients
under the intended viewing conditions.
The following is an example obtained by measuring
the DCT coefficient visibility threshold using
CCIR-601 images and display:

Sequential DCT Normalization


array

Sequential DCT Normalization


array

Quantization Tables are designed to provide the most visually


correct reconstruction image.
Different applications may use different tables.
After normalization, the coefficients are quantized by rounding
off to the nearest integer.

F (u, v)

F (u, v) round
Q(u, v)

The normalization/quantization process typically results in many


zero-valued coefficients which can be coded efficiently.

Original 8 x 8 Image Block


139 144 149 153 155 155 155 155
144 151 153 156 159 156 156 156
150 155 160 163 158 156 156 156
159 161 162 160 160 159 159 159
159 160 161 162 162 155 155 155

161 161 161 161 160 157 157 157


162 162 161 163 162 157 157 157
162 162 161 161 163 158 158 158

DCT of 8 x 8 Image Block


1259.6 - l.0 - 12.1
- 22.6 - 17.5 - 6.2
- 10.9 - 9.3 - l.6
- 7.1
- 1.9 0.2
- 0.6 - 0.8 1.5
1.8
- 0.2 1.6
- 1.3 - 0.4 - 0.3
- 2.6
1.6 - 3.8

- 5.2
- 3.2
1.5
1.5
1.6
- 0.3
- 1.5
- 1.8

2.1
- 2.9
0.2
0.9
- 0.1
- 0.8
- 0.5
1.9

- 1.7
0. l
- 0.9
- 0.1
- 0.7
1.5
1.7
1.2

- 2.7
0.4
- 0.6
0.0
0.6
1.0
1.1
- 0.6

1.3
- 1 .2
- 0.1
0.3
1.3
- 1.0
- 0.8
- 0.4

Normalized/Quantized
Coefficients
79 0
- 2 -1
-1 -1
0
0
0
0
0
0
0
0
0
0

-1
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0

Zigzag Scan

Prior to the entropy encoding, the 2-D coefficients are


scanned into a l-D format according to the following
zigzag pattern.
0 1 2 3 4 5 6 7
______________________________
DC

0:
1:
2:
3:
4:
5:
6:
7:

0 1 5 6 14 15 27 28
2 4 7 13 16 26 29 42
3 8 12 17 25 30 41 43
9 11 18 24 31 40 44 53
10 19 23 32 39 45 52 54
20 22 33 38 46 51 55 60
21 34 37 47 50 56 59 61
35 36 48 49 57 58 62 63
______________________________

RLC and Huffman coding

DC Coding:

The top-left coefficient in the 2-D DCT array is referred to


as the DC coefficient and is proportional to the average
brightness of the spatial block.
The difference between the quantized DC coefficient of the
current block and the quantized DC coefficient of the
previous block is variable-length coded.
A set of Huffman codes with a maximum codeword length
of 16 bits is used to specify the different categories. The
category code and an additional k bits (category k) is send as
the complete code.
The k bits corresponds to the k LSBs of the positive
difference or k LSBs of the negative difference 1.

Magnitude Category Table

DC Base Code Table

RLC and Huffman coding Cont..

AC Coefficient Coding:

The quantization of AC coefficients creates many


zeros, especially at higher frequencies.
The 2-D array of the DCT coefficients is formatted
into a 1-D vector using a zigzag reordering.
This rearranges the coefficients in approximately
decreasing order of their average energy (as well as
in order of increasing spatial frequency) with the
aim of creating large runs of zero values.

RLC and Huffman coding Cont..

The AC coefficients are coded in a similar manner as


DC coefficients.
The major difference is that the default AC Huffman
code word depends on the number of zero valued
coefficients preceding the non zero coefficient to be
coded, as well as the magnitude category of the non
zero coefficient.
The base code along with an additional k bits are
needed to completely code the coefficients, where the
last k bits are generated in the same manner as that for
the DC coefficient.

Huffman Table

Huffman Table

RLC and Huffman coding Cont..

If the run length exceeds 16 zero coefficients, it


is coded by using multiple symbols.

In addition, a special symbol is used to code the


end of block (EOB) which signals that all the
remaining coefficients in the block are zero.

Huffman Coding Example

Quantized DCT AC coefficients in zigzag


order:

79 0 -2 -1 -1 -1 0 0 -1 All Zeros.

Huffman Symbols:- (Zero run, Category)

DC Coefficient (1,2) (0,1) ( 0,1) (0,1) (2,1) EOB.

Huffman Coding Example

Codeword Assignment

Final codeword = (Huffman codeword) append (k


additional bits for category k coefficient)
-2 preceded by one zero: (k=2, run=1) 111001 append 0
(sign bit) append 1 = 11100101.

Huffman code for the block:

DC diff.
codeword/11100101/000/000/000/110110/1010.
Total bits assuming 8 bits for the DC difference codeword=
35, Bit rate = 35/64 = 0.55 bits/pixel

Progressive DCT-based mode

Similar to sequential DCT-based mode


Quantized DCT coefficients, however, first stored in buffer.
DCT coefficients in buffer then encoded by a multiple scanning
process
In each scan, quantized DCT coefficients partially encoded
either by spectral selection or successive approximation.
In spectral selection, quantized DCT coefficients divided
into multiple spectral bands according to the zig-zag order.
In each scan, a specified band is encoded.
In successive approximation, a specified number of most
significant bits of quantized coefficients first encoded. In
subsequent scans, less significant bits are encoded.

Progressive DCT - Example

Hierarchical mode

An image first spatially down-sampled to a multiple


layered pyramid

1. Filter and down sample the original image by the


desired number of multiples of 2 in each dimension.
2. Encode this reduced size image using one of the
sequential DCT, progressive DCT, or lossless encoders
described previously.
3. Decode this reduced size image and then interpolate and
up sample it by 2 horizontally and/or vertically, using
the identical interpolation filter which the receiver must
use.

Hierarchical mode

4. Use this up sampled image as a prediction of the


original at this
resolution, and encode the
difference image using one of the sequential DCT,
progressive DCT, or lossless encoders described
previously.
5. Repeat steps 3) and 4) until the full resolution of
the image has been encoded.

Hierarchical mode

Lossless coding mode

Uses Lossless Predictive coding


Method (DPCM)

Das könnte Ihnen auch gefallen