0% found this document useful (0 votes)
30 views

CSE679: JPEG: JPEG Goals JPEG Compression Steps Lab

The document describes the JPEG image compression standard. It outlines JPEG's goals of enabling lossy compression with adjustable levels and efficient hardware implementation. It then summarizes JPEG's main compression steps: picture preparation into blocks and pixels, forward DCT transformation, quantization using tables, and entropy encoding including differential, run-length, and Huffman coding. Finally, it provides an example of applying the steps to an original image block and calculating the resulting compressed data size ratio.

Uploaded by

xacdinhdi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

CSE679: JPEG: JPEG Goals JPEG Compression Steps Lab

The document describes the JPEG image compression standard. It outlines JPEG's goals of enabling lossy compression with adjustable levels and efficient hardware implementation. It then summarizes JPEG's main compression steps: picture preparation into blocks and pixels, forward DCT transformation, quantization using tables, and entropy encoding including differential, run-length, and Huffman coding. Finally, it provides an example of applying the steps to an original image block and calculating the resulting compressed data size ratio.

Uploaded by

xacdinhdi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

CSE679: JPEG

JPEG goals JPEG compression steps Lab

JPEG Goals
JPEG: Joint Photographic Experts Group Applications can tune compression level Should have tractable computational complexity Should be possible to implement in hardware Compression scheme should be independent of data

format

PAL/NTSC etc. shouldnt matter Independent of picture size, colors etc.

Lossless, hierarchical, sequential, and progressive

coding should be possible.

JPEG Compression Steps


Picture preparation Pixel Block, MCU (Minimum Coded Unit) Picture processing FDCT Quantization Entropy encoding Differential encoding (belongs to Source encoding) Run-length encoding Huffman encoding

Picture Preparation
JPEG specifies a very general image model. A source image consists of at least one and at most

255 components.

Components may be assigned to the three colors RGB, YIQ or YUV signals.

Convert each component into 8 8 data blocks

Each pixel is represented by p (8, or 12) bits. If p = 8, each pixel is an integer in the range of 0 to 255.

Processing Forward DCT


Shift: The pixel values are shifted into the range

[-128, 127]. DCT expression


7
j

Some Observations of Forward DCT


All 64 values in the input matrix, P[x, y] contribute to

each entry in the transform matrix, F[x, y] to generate 64 new samples F[0,0] is the mean of all 64 values in the matrix, known as the DC coefficient, others are called as the AC coefficients.

DCT Computation Features DCT Computation Features

Quantization
FQ[x, y] = Integer Round (F(x, y)/Q(x, y)) Different coefficients are treated separately based on

quantization table.

An Example of Quantization

An Example of Quantization Table

Entropy Encoding
Vectoring o 2-D matrix should represent the values in the form of a single-dimension vector. o Scan in zig-zag order

Differential Encoding
The DC coefficient varies only slowly from one block

to the next.

12, 13, 11, 11, 10,

Only the difference in the preceding block is

encoded.

12, 1, -2, 0, 1

Run-length Encoding
The AC coefficients are encoded in the form of a

string of pairs of values (skip, value)

(0,6) (0,7) (0,3) (0,3) (0,3) (0,2) (0,2) (0,2) (0,2) (0,0)

Huffman Encoding
Use variable length codes Most frequently used symbols coded with fewest bits The intermediate symbol sequence

DC coefficient: (sss, value)


sss: the number of bits needed value: the encode value

AC coefficient: (skip, sss) (value) with run-length encoding


skip: the number of consecutive 0s sss: the number of bits needed to encode the value value: the encode value

Huffman code

DC coefficients: 12 = (4, 12) = (1011100) AC coefficient: (0, 6) = (0, 3) (6) = (100110)

Summary
DC coefficient

Input: 12, 13, 11, 11, 10, Differential encode: 12, 1, -1,-1,-2 The intermediate symbol sequence: (sss, value) Huffman code:
P160 (b) sss P160 (a) value Example: 12 = (4, 12) = (1011100)

AC coefficient

Input: 6, 7, 3, 0, 0, 3, 3, 2, 0, 0, 0 Run-length encoding: (0,6) (0,7) (0,3) (2,3) (0,3) (0,2) (0,0) The intermediate symbol sequence: (skip, sss) (value) Huffman code:
P163-164 (skip, sss) P160(a) value Example: (0, 6) = (0, 3) (6) = (100110)

Lab Project
Objective: be familiar with JPEG Description

Input: an original 8 8 block original data (the value of each pixel is in the range of [0, 255]) (given by the Instructor) Steps:
Shifted to the range of [-128, 127] FDCT (round: 1.6 2, -1.6 -2, 1.5 2, 1.1 1) ( = 3.141592654) Quantized with the given quantization table (see the given example) (round) (round: 1.6 2, -1.6 -2, 1.5 2, 1.1 1) Zig-zag coded Converted to the intermediate symbol sequence with run-length encoding on AC coefficients Encoded to bit sequence with Huffman encoding (based on the given default Huffman codewords tables) compressed data The compression ratio = original data size (i.e., 64 8)/compressed data size

Output: print out all the results of the above steps into different files (The names and formats of output files should follow the files put on the web.)

Lab Project
Team: 2 or 3 students What should be turned in (via email to TA, subject: 679 project)?

Put all codes into one file (source_jpeg.c (.cpp) with clear comments (softcopy)
Make sure TA can understand, compile, and run your codes on UNIX machines. All the codes should be in C or C++.

A report including a summary (2 page # 5) and the source code file, and result files (hardcopy or softcopy either in PDF) Correctness: TA will use his own data to test your codes. Clearness: TA will check whether your code and report are understandable. Fairness:
Students in the same teams get the same scores. No copy! All students involved in copy will get ZERO.

How will TA grade?


Example - Original Block


140 144 152 168 144 152 155 145 147 140 136 156 140 147 167 160 139 140 163 152 155 148 162 155 179 167 152 136 175 179 172 160

162 147
136 148

148 167
156 155

156 140
123 136

148 155
167 155

140 155
162 152

136 140
144 147

147 136
140 147

162 162
147 136

Example - Shifted Block


12 16 16 24 19 12 12 19 11 12 27 20 51 39 47 51

24 40
34 19 8 20

27 17
20 39 28 27

8 28
28 12 -5 8

39 32
20 27 39 27

35 24
12 27 34 24

34 27
8 12 16 19

24 8
19 8 12 19

44 32
34 34 19 8

Example -After FDCT


186 20 -11 -8 -3 4 9 0 -18 -34 -23 -5 10 -2 1 -8 15 27 -2 15 8 -18 -3 -2 -9 -9 6 -15 1 8 4 2 23 -11 -18 -8 -11 8 -1 1 -9 11 3 -3 18 -3 -7 4 -14 14 -20 -3 18 1 -1 -6 -19 7 -1 8 15 -7 -2 0

Example - Quantization Table


3 5 7 5 7 9 7 9 11 9 11 13 11 13 15 13 15 17 15 17 19 17 19 21

9
11 13 15 17

11
13 15 17 19

13
15 17 19 21

15
17 19 21 23

17
19 21 23 25

19
21 23 25 27

21
23 25 27 29

23
25 27 29 31

Example - After Quantization


62 -4 2 -1 2 -1 -1 -1

4
-2 -1 0 0 1 0

-5
-3 0 1 0 0 0

3
0 1 1 -1 0 0

-1
0 -1 0 0 0 0

-1
-1 0 -1 0 0 0

1
0 0 1 0 0 0

1
-1 0 1 0 0 0

0
0 0 1 0 0 0

Example Other Steps


Zig-zag sequence 62,-4,4,-2,-5,2,-1,3,-3,-1,0,0,0,-1,2,-1,-1,0,1,1,0,1,0,1,-1,1,1,-1,-1,1,0,0,0,-1,0,0,0,0,0,-1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0 Intermediate symbol sequence (6)(62), (0,3)(-4), (0,3)(4), (0,2)(-2), (0,3)(-5), (0,2)(2), (0,1)(1), (0,2)(3), (0,2)(-3), (0,1)(-1), (3,1)(-1), (0,2)(2),(0,1)(-1), (0,1)(-1), (1,1)(1), (0,1)(1), (1,1)(1), (1,1)(1), (0,1)(-1), (0,1)(1), (0,1)(1), (0,1)(-1), (0,1)(-1), (0,1)(1),(3,1)(-1), (5,1)(-1), (1,1)(-1), (3,1)(1), (6,1)(1), (1,1)(1), (0,0) Encoded bit sequence (total 154 bits) (1110)(111110) (100)(001) (100)(100) (01)(01) (100)(010) (01)(10) (00)(0) (01)(11) (01)(00) (00)(0) (111010)(0) (01)(10) (00)(0) (00)(0) (1100)(1) (00)(1) (1100)(1) (1100)(1) (00)(0) (00)(0) (00)(1) (00)(0) (00)(0) (00)(1) (111010)(0) (1111010)(0) (1100)(0) (111010)(1) (1111011)(1) (1100)(1) (1010)

Conclusion
JPEG goals JPEG compression steps Picture Preparation
Component, block, and pixel

Picture Processing
Forward DCT

Quantization
Different coefficients are treated separately.

Entropy coding

Lab

You might also like