data compression (3)

19
Department of Computer Engineering University of California at Santa Cruz Data Compression (3) Hai Tao

Upload: zalman

Post on 29-Jan-2016

46 views

Category:

Documents


0 download

DESCRIPTION

Data Compression (3). Hai Tao. JPEG Compression. JPEG is the image compression standard developed by the Joint Photographic Experts Group JPEG was designed for natural image compression It convert the original image into YIQ space and compress each channel as a separate gray image - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Data Compression (3)

Hai Tao

Page 2: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG Compression

JPEG is the image compression standard developed by the Joint Photographic Experts Group

JPEG was designed for natural image compression It convert the original image into YIQ space and compress

each channel as a separate gray image The compression ratio and the quality of the decoded

images is controlled by quality factor (1-100)• Quality factor > 35 - no big difference

• Quality factor < 10 – significant difference

Page 3: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Quality factor

Original Quality factor = 20

Quality factor = 75 Quality factor = 5

Page 4: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG Compression – Algorithm Overview

An input image is divided into 8x8 blocks. Each block is encoded based on DCT transform

DCT coefficients are quantized according to a quatization matrix Entropy coding is used to encode positions and the magnitudes of the

coefficients

Page 5: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Color space conversion

Human visual system has less resolution in color than in intensity. As a result, the original color images are converted into intensity and color channels. One such transformation is RGB->YIQ

B

G

R

Q

I

Y

311.0523.0212.0

321.0275.0596.0

114.0587.0299.0

Page 6: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG – 8x8 DCT Transformation

After DCT compression, only a few DCT coefficients have large values in each 8x8 block

These coefficients are floating-point numbers

Page 7: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Quantization of the DCT Coefficients

Each coefficients are converted into an integer number using quatization

The choices of quatization steps• Large quantization step - Large rounding errors, smaller quantized

values

• Small quatization step – Small rounding errors, large quantized coefficients

• The same quatization step for all coefficients ? – Human visual system is more sensitive to relative low frequency changes in images, which implies that for high frequency coefficients, larger quantization steps can be used without causing noticeable image distortion

• What does all this means ?

Page 8: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG Quantization Matrix

The low frequency coefficients (upper-left corner) have smaller quantization steps, therefore more accurately encoded

3 5 7 9 11 13 15 17

5 7 9 11 13 15 17 19

7 9 11 13 15 17 19 21

9 11 13 15 17 19 21 23

11 13 15 17 19 21 23 25

13 15 17 19 21 23 25 27

15 17 19 21 23 25 27 29

17 19 21 23 25 27 29 31

Page 9: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG Quantization Using the Quantization Matrix

92 3 -9 -7 3 -1 0 2

-39 -58 12 17 -2 2 4 2

-84 62 1 -18 3 4 -5 5

-52 -36 -10 14 -10 4 -2 0

-86 -40 49 -7 17 -6 -2 5

-62 65 -12 -2 3 -8 -2 0

-17 14 -36 17 -11 3 3 -1

-54 32 -9 -9 22 0 1 3

30 0 -1 0 0 0 0 0

-7 -8 1 1 0 0 0 0

-12 6 0 -1 0 0 0 0

-5 -3 0 0 0 0 0 0

-7 -3 3 0 0 0 0 0

-4 4 0 0 0 0 0 0

-1 0 -1 0 0 0 0 0

-3 1 0 0 0 0 0 0

Before quantization

After quantization90 0 -7 0 0 0 0 0

-35 -56 9 11 0 0 0 0

-84 54 0 -13 0 0 0 0

-45 -33 0 0 0 0 0 0

-77 -39 45 0 0 0 0 0

-52 60 0 0 0 0 0 0

-15 0 -19 0 0 0 0 0

-51 19 0 0 0 0 0 0

After reconstruction

Page 10: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Encoding

We need to compress the quantized coefficients

Lossless methods are used to • Encode the position of non-zero coefficients

• Encode the magnitudes of these coefficients

30 0 -1 0 0 0 0 0

-7 -8 1 1 0 0 0 0

-12 6 0 -1 0 0 0 0

-5 -3 0 0 0 0 0 0

-7 -3 3 0 0 0 0 0

-4 4 0 0 0 0 0 0

-1 0 -1 0 0 0 0 0

-3 1 0 0 0 0 0 0

Page 11: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Encoding

Zig-Zag encoding of coefficient positions• Non-zero coefficients and the number of 0’s in front of them are

encoded along the zig-zag path

Page 12: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Example

The following quantized coefficient matrix is represented as(30,0), (-7,1), (-12, 0), (-8, 0), (-1, 0), (1,1),(6,0),(-5,0),(-7,0),(-3,0),(1,1), (-1,3),(-3,1),(-4,0), (-1,0), (4,0), (3,0),(-3,11),(1,0), (-1,0),(end)

These pairs are encoded using a entropy coding method

30 0 -1 0 0 0 0 0

-7 -8 1 1 0 0 0 0

-12 6 0 -1 0 0 0 0

-5 -3 0 0 0 0 0 0

-7 -3 3 0 0 0 0 0

-4 4 0 0 0 0 0 0

-1 0 -1 0 0 0 0 0

-3 1 0 0 0 0 0 0

Page 13: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG bit stream

Page 14: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG Bitstream

Terminology• Frame – image

• Block – 8x8 image block

• Segment – a group of blocks

Frame header• Sample precision

(width, height) of image number of components unique ID (for each component) horizontal/vertical sampling factors (for each component) quantization table to use (for each component)

Page 15: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

JPEG Bitstream

Scan header • Number of components in scan

component ID (for each component) Huffman table for each component (for each component)

Misc. (can occur between headers)• Quantization tables

Huffman Tables Arithmetic Coding Tables Comments Application Data

Page 16: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Various JPEG modes

Baseline/Sequential Lossless mode Progressive mode

• Display low quality image first, and then transmit and display more details

• Method 1: Send DC components first, then a few low frequency components, and then more components

• Method 2: Send significant bits first, then more less significant bits

Page 17: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Decoding

Decoding is the inverse process of the encoding• Recover the quantized coefficient matrix

• Recover the coefficient matrix

• IDCT

JPEG is lossy because of the quatization process

Page 18: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Evaluation

To evaluate an image compression algorithm, there are two criteria• Subjective - The visual quality vs. bit rate (subjective)

• Objective - The rate distortion curve (Peak SNR vs. bit rate)

N

i

N

je jiIjiI

N 1 1

22

2 )),('),((1

The difference image when the quality factor is 3

N

i

N

jI jiIjiI

N 1 1

22

2 )),(),((1

)(log10 10e

IdBPSNR

Page 19: Data Compression (3)

Department of Computer EngineeringUniversity of California at Santa Cruz

Evaluation

The rate distortion curve