Compression II: Images (JPEG) What is JPEG? JPEG: Joint Photographic Expert Group an international standard in 1992. Works with colour and greyscale images Up 24 bit colour images (Unlike GIF) Target Photographic Quality Images (Unlike GIF) Suiable Many applications e.g., satellite, medical, general photography... 438
Basic JPEG Compression Pipeline JPEG compression involves the following: Encoding 439 Figure 46: JPEG Encoding Decoding Reverse the order for encoding
Major Coding Algorithms in JPEG The Major Steps in JPEG Coding involve: Colour Space Transform and subsampling (YIQ) DCT (Discrete Cosine Transformation) Quantization Zigzag Scan DPCM on DC component RLE on AC Components Entropy Coding Huffman or Arithmetic We have met most of the algorithms already: JPEG expoits them in the compression pipeline to achieve maximal overall compression. 440
Quantization Why do we need to quantise: To throw out bits from DCT. Example: 101101 = 45 (6 bits). Truncate to 4 bits: 1011 = 11. Truncate to 3 bits: 101 = 5. 441 Quantization error is the main source of Lossy Compression. DCT itself not Lossy How we throw away bits in Quantization Step is Lossy
Uniform quantization Divide by constant N and round result (N = 4 or 8 in examples above). Non powers-of-two gives fine control (e.g., N = 6 loses 2.5 bits) 442
Quantization Tables In JPEG, each F[u,v] is divided by a constant q(u,v). Table of q(u,v) is called quantization table. Eye is most sensitive to low frequencies (upper left corner), less sensitive to high frequencies (lower right corner) Standard defines 2 default quantization tables, one for luminance (below), one for chrominance. ---------------------------------- 16 11 10 16 24 40 51 61 12 12 14 19 26 58 60 55 14 13 16 24 40 57 69 56 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 100 103 99 ---------------------------------- 443
Quantization Tables (Cont) Q: How would changing the numbers affect the picture E.g., if we doubled them all? 444 Quality factor in most implementations is the scaling factor for default quantization tables. Custom quantization tables can be put in image/scan header. JPEG Quantisation Examples JPEG Quantisation Example (Java Applet)
Zig-zag Scan What is the purpose of the Zig-zag Scan: to group low frequency coefficients in top of vector. Maps 8 x 8 to a 1 x 64 vector 445
Differential Pulse Code Modulation (DPCM) on DC component Another encoding method is employed DPCM on the DC component at least. Why is this strategy adopted: 446 DC component is large and varied, but often close to previous value (like lossless JPEG). Encode the difference from previous 8x8 blocks DPCM
Run Length Encode (RLE) on AC components Yet another simple compression technique is applied to the AC component: 1x64 vector has lots of zeros in it Encode as (skip, value) pairs, where skip is the number of zeros and value is the next non-zero component. Send (0,0) as end-of-block sentinel value. 447
Entropy Coding DC and AC components finally need to be represented by a smaller number of bits: Categorize DC values into SSS (number of bits needed to represent) and actual bits. 448 -------------------- Value SSS 0 0-1,1 1-3,-2,2,3 2-7..-4,4..7 3 -------------------- Example: if DC value is 4, 3 bits are needed. Send off SSS as Huffman symbol, followed by actual 3 bits. For AC components (skip, value), encode the composite symbol (skip,sss) using the Huffman coding. Huffman Tables can be custom (sent in header) or default.
Example JPEG Compression 449
Another Enumerated Example 450
JPEG 2000 New version released in 2002. Based on: discrete wavelet transform (DWT),instead of DCT, scalar quantization, context modeling, arithmetic coding, post-compression rate allocation. 451 Application: variety of uses, ranging from digital photography to medical imaging to advanced digital scanning and printing. Higher compression efficiency visually lossless compression at 1 bit per pixel or better.
Further Information Basic JPEG Information: http://www.jpeg.org Online JPEG Tutorial 452 For more information on the JPEG 2000 standard for still image coding, refer to http://www.jpeg.org/jpeg2000.htm