Digital Image Processing Lecture 21 Lossy Compression May

  • Slides: 9
Download presentation
Digital Image Processing Lecture 21: Lossy Compression May 18, 2005 Prof. Charlene Tsai 1

Digital Image Processing Lecture 21: Lossy Compression May 18, 2005 Prof. Charlene Tsai 1

JPEG Algorithm n n n Lossy compression trades some acceptable data loss for greater

JPEG Algorithm n n n Lossy compression trades some acceptable data loss for greater rate of compression. There are many available, but the most popular is the one developed by JPEG – transform coding. Coding not done on pixel values, but on a transform. 2

Transform n n n Discrete Cosine Transform (DCT) Applying to 8 x 8 blocks,

Transform n n n Discrete Cosine Transform (DCT) Applying to 8 x 8 blocks, the forward and inverse DCT are real-valued, high informationpacking capability, and separable. 3

Comparison with FFT n n n Given the following sequence 10 25 40 55

Comparison with FFT n n n Given the following sequence 10 25 40 55 70 85 100 115 If using FFT, the inverse of the first 4 FFT coefficients gives 49 41 56 57 71 70 85 90 If using DCT, the result is 11 23 41 56 69 84 102 114 4

JPEG Compression n For each 8 x 8 image block, perform the compression q

JPEG Compression n For each 8 x 8 image block, perform the compression q q q Subtracting 128 from each value Apply DCT Normalization by dividing by matrix Q (the lossy part) n q Turning most of the elements zero Change the matrix into a vector by reading the nonzero element in a zigzag fashion. O O O … … … 5

(con’d) n The first element (DC coefficient) of the vector is encoded as the

(con’d) n The first element (DC coefficient) of the vector is encoded as the difference between itself and the DC of previous block. q q n n Keeps all values (except the very first one) small Compressed using RLE Other values (AC coefficients) are compressed using Huffman coding Rate of compression is controlled by scaling Q => more scaling, more compression (see page 413~415 for an example) 6

Decompression n Inverse the operations: q q q Decode Huffman encoding and RLE Put

Decompression n Inverse the operations: q q q Decode Huffman encoding and RLE Put the vector back to 8 x 8 matrix Multiply by Q Inverse DCT Shift back by 128 7

The Lossless Parts n n Huffman Coding and RLE for AC and DC terms,

The Lossless Parts n n Huffman Coding and RLE for AC and DC terms, respectively. We’ll focus the discussion on the AC terms q q q Each nonzero value x is assigned a category k The number of preceding 0 s (run). Values: 7 -1 10 0 2 1 0 0 2 4 0 1 0 -1 Category: 1 4 2 1 2 3 1 1 Run: 0 0 1 0 2 0 1 1 8

Huffman Code Table n n Part of JPEG baseline standard See page 417 and

Huffman Code Table n n Part of JPEG baseline standard See page 417 and 418 for the code table, and the application. 9