120 likes | 256 Views
The Baseline JPEG Algorithm. Mei-Chen Yeh 12/04/2009. Background. Joint Photographic Experts Group (JPEG) Joint standards committee of ITU-T and ISO Optimized for still images. Baseline algorithm. Slide credit: Bernd Girod. Transform (1). Level shift—subtract the mean
E N D
The Baseline JPEG Algorithm Mei-Chen Yeh 12/04/2009
Background • Joint Photographic Experts Group (JPEG) • Joint standards committee of ITU-T and ISO • Optimized for still images
Baseline algorithm Slide credit: Bernd Girod
Transform (1) • Level shift—subtract the mean • Subtract 128 from each pixel for a 8-bit image [0, 255] -> [-128, 127] • 8x8 forward DCT • Replicate the last column/row until the size is a multiple of eight An 8x8 block from the Sena image Large values DCT coefficients Small values
Transform (2) • Forward DCT • Inverse DCT
Quantization (1) • Uniform midtread quantization • The quantization step sizes are organized in a table (the quantization table) Reconstruction = ? DCT coefficients
Quantization (2) More quantization errors! DCT coefficients Quantization errors in the DC and lower AC coefficients are more easily detectable than that in the higher AC coefficients.
Coding (1) Coding of the differences of the DC labels • Differential coding of DC coefficient (0,0) • Partition the differences into categories • Ex: DIFF = 6 • First, send Huffman code (100) for the category 3 [-7…-4, 4…7] • Second, send 3 bits to specify the value “6”
Coding (2) • Two special codes • EOF: the end of block • ZRL: used when # of consecutive zero values exceeds 15 • Zig-zag-scan and run-level-coding of AC coefficients • Ex: 0 0 0 0 -14 0 0 +1 0 0 0 … 0 • (4, -14) (2, +1) EOF
Coding (3) 0 0 0 0 -14 0 0 +1 0 0 0 … 0 (4, -14) (2, +1) EOF -14: Category 4 Encode (4, -14) Check codeword for 4/4 Use 4 bits to encode -14 +1: Category 1 Encode (2, +1) Check codeword for 2/1 Use 1 bit to encode +1 EOF (1010)
Put things together… FDCT Quantization DC = 2 Suppose the previous DC is -1, DIFF_DC = 2 – (-1) = 3 3 is in Category 2 (send 011), use 2 bits to specify “3” 5 bits AC = 1, -9, 3, EOF 1 is in Category 1, Z/C = 0/1 (send 00), use 1 bit to specify “1” 3 bits -9 is in Category 4, Z/C = 0/4 (send 1011), use 4 bits to specify “-9” 8 bits 3 is in Category 2, Z/C = 0/2 (send 01), use 2 bit to specify “3” 4 bits EOF (send 1010) 4 bits 24 / 64 = 0.375 bits per pixel
Sinan image coded using JPEG 0.5 bits per pixel 0.25 bits per pixel