Introduction ti to JPEG JPEG: Joint Photographic Expert Group work under 3 standards: ISO, CCITT, IEC Purpose: image compression Compression accuracy Works on full-color or gray-scale image
Color Grayscale image: Value 0-255 RGB color model: Three components R 0-255 G 0-255 B 0-255 File size of grayscale image is 75% of a color image
How does JPEG work? Source image data RGB Color transform DCT Quantization Compressed image data JPEG Huffman
Step1: color transformation ti RGB Color transform 1 Lossless YCbCr DCT Quantization Huffman
YCbCr color model YCbCr model exploits the property of the visual system that more sensitive to changes luminance than to change hue. Y is the luminance. Cb and Cr are the chromaticity. Only Y component will show black/white TV More bits are used for Y, and less bits for Cb or Cr. RGB YCbCr Y = 0.3R +0.6G +0.1B Cb = -0.2R - 0.3G + 0.5B + 128 Cr = 0.5R - 0.4G - 0.1B + 128 YCbCr RGB R = Y +1.4(Cr 128) G = Y - 0.3 (Cb 128) - 0.7(Cr-128) B= Y+1 1.8 (Cb 128)
RGB image
YCbCr image
Step1: color transformation ti This step is optional No for grayscale image From RGB to luminance/chrominance color model Enable to compress more in chrominance component Y JPEG compressor RGB Color Cb Transform JPEG compressor JPEG stream Cr JPEG compressor
Step 2 : Discrete Cosine Transform RGB Color transform DCT 2 Lossless Quantization JPEG Huffman
Discrete Cosine Transform Purpose: Convert from spatial domain to frequency domain Be able to separate what the eye can see from imperceptible 1D DDCT: DCT: 250 100 100 0 0-100 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
Cosine basis functions u=0 u=1 u=2 u=3 u=4 u=5 u=6 u=7
Cosine basis functions A set of waveforms is orthogonal Orthogonal waveforms are independent A set of waveforms scaled and added together can represent any eight samples DC coefficient (u=0) Scales the constant basis function (average value) AC coefficients The higher the frequency the less important the coefficient i
1D DCT FDCT 8 samples 8 DCT coefficients IDCT
Basis functions of 2D DCT A set of 64 2D basis functions: Multiply l horizontally oriented set by vertically oriented set Block 8x8 samples is represented dby 64 coefficients
2D DCT
Scanning DCT coefficients i The zigzag pattern orders the basis functions from the low to high spatial frequencies One constant basis function one DC coefficient Rest are AC coefficients DC coefficient AC coefficient
2D Discrete Cosine Transform The forward equation is S ( u, v ) C( u) C( v) 2 2 The inverse equation is u(2x 1) v(2 s ( x, y )cos cos 16 7 7 y x0 y0 16 1) s( x, y) 7 C( v) 2 7 C( u) u(2x 1) v(2y 1) S( u, v)cos cos 16 u0 v0 2 16 C u) 1 1 ( 2 if u 0 otherwise
DCT coefficients i Block 8x8 samples FDCT IDCT 8x8 DCT coefficients Distribution of the DCT coefficients within the block is non-linear. Coefficients at the lower frequencies have large magnitude, while it has less magnitude at the higher magnitude. A large number of bits are assigned to values corresponding to lower frequencies, while fewer bits to higher h frequencies
Step 3: quantization RGB Color transform DCT Quantization 3 Lossy JPEG Huffman
Quantization Purpose: Eliminate less significant information Low frequency coefficients i have smaller quantization steps, therefore more accurately encoded Luminance data is quantized more accurately than the chromatic data How? Each coefficient in each block is divided by separate quantization coefficient Round the result to integer
Quantization G(u, v) G (u G(u, v) G( u, v) round q( u, v) G'( u, v) q(u, v)
Quantization DCT coefficients Quantizated DCT coefficients Q table
Step 4: Huffman coding RGB Color transform DCT Quantization Huffman JPEG 4 Lossless
DC coefficient i Coding Encode the difference between the value and already coded value Sample Previous sample Difference AC coefficient Huffman code: less bits for common values
JPEG decoderd Source image data RGB Color transform DCT Dequantization Compressed image data JPEG Huffman
MPEG
MPEG
MPEG compression