Lecture 10: Image Compression
Image Compression Model
-*Mapper:* transforms image to another space designed to reduce spatial and temporal redundancy → Operation generally reversible → May reduce or not amount of data necessary to represent image -*Quantizer:* reduces accuracy of mapper's output in accordance with certain fidelity criterion (irreversible) -*Symbol coder:* uses variable length coding that minimizes code redundancy (reversible)
JPEG
-8x8 subimages -Transform: Discrete Cosine Transform (DCT)
Coding Redundancy
-Alternative code → Calculate Lavg → L2 avg = 2.77 bits Cr = 3/2.7 = 1.11
JPEG's Goals for Standard
-Be near state of art in compression rate and image fidelity -User decides on *trade-off* between image fidelity and compression ratio -Be applicable to any kind of continuous-tone digital image source -Have tractable computational complexity for implementation on wide range of computational hardware
Interpixel (spatial) Redundancy (LOOK AT SLIDES)
-Can produce same histogram
Huffman coding: features
-Creates optimal code subject to constrain that symbols are coded *one at a time* -Instantaneous uniquely decodable block code → Coding not dependent of other symbols → One string of symbols decoded in only one way → Each source symbol mapped into fixed sequence -A string of symbols is decoded left to right
Introduction
-Data compression: process of reducing amount of data required to represent given quantity of information → Data =/ Info -Image compression = *enabling technology* -Not new science
LZW Coding (Lempel-Ziv-Welch)
-Dictionary method -Takes advantage of repeated strings of symbols in data to be coded -Dictionary created during coding process -Included in GIF, TIFF, PDF
Quantization
-Each coefficient quantized with rounding operation → controlled by quantization matrix -This is *compression step*
DCT Coefficients: meaning
-Every subimage (8x8) decomposed in multiplication of 8x8 coefficients by cosine basis functions
Entropy
-First-order entropy (LOOK AT SLIDES) -Maximum entropy: all values have same probability (flat histogram): 1/2^n (LOOK AT SLIDES)
Measuring Compression
-If n1 and n2 denote number of information-carrying units in two datasets → Compression ratio: Cr = n1/n2 → Relative data redundancy: Rd = 1 - (1/Cr) -Image compression is based on three basic data redundancies → Coding - Interpixel - Psychovisual
Shannon's First Theorem
-Image can be represented with as few H bits/pixel (H info units/symbol) -This lower bound in compression takes into account only coding redundancy → so even lower values can be achieved -Compression ratio is represented also as number of bits/pixel in compressed image
Coding Redundancy
-Image w/ values rk w/ probability pr(rk) (LOOK AT SLIDES) -Average number of intensity levels required per pixel (LOOK AT SLIDES) -If all intensity levels are codified with m bits: Lavg = m -And what if NOT all intensity levels are codified with m bits?
Fidelity Criteria
-In order to quantify nature of loss → objectively (look at slides) → Subjectively: worse - same - better
Compression Methods
-Lossless (no quantizer) → Possible to recover original image, no distortion, low compression ratios -Lossy (Mapper+Quantizer+Symbol coder) → Impossible to recover original image, distortion, high compression ratios
Lossy Compression
-Lossless is limited -To obtain high compression ratio, necessary to lose information -Quantization is *crucial step*
Measuring information: Entropy
-Measurement of amount of randomness (disorder) in system -In image, is way to measure average global *information content* -Info content of single pixel intensity: (LOOK AT SLIDE)
Huffman Coding
-One of most popular techniques -*1st step:* order probabilities of symbols and combining lowest probability symbols into single one that replaces them in next source reduction (LOOK AT SLIDE) -*2nd step:* code each reduced source from highest probability symbols going down L avg = (0.4)(1)+(0.3)(2) + (0.1)(3) + (0.1)(4) + (0.06)(5) + (0.04)(5) = 2.2 bits/pixel
Final Step: Symbol Encoder
-RLE using 'zigzag' order for quantized coefficients -Finally: Huffman
Run Length Coding (RLE)
-Takes into account repeating intensities in image -Simple → used for FAX -If there are no similar intensities, can provide expansion instead of compression -Run lengths can be considered symbols and their statistics used to variable-length code the run lengths themselves
JPEG Still Standard Picture Compression
-Tasked in late 1980s to: generate general-purpose standard for compression of almost all continuous tone and still-image apps.
DCT
-Transforms 8x8 block of input values to linear combination of these 64 patterns -Patterns referred to as 2D *DCT basis functions* -Output values = *transform coefficients* -Horizontal index = *u* - Vertical index = *v*
Block transform coding
1. Subimages processed independently 2. Forward transform reversible 3. Quantization of transformed coefficients is compression step 4. Finally any standard symbol encoder is applied (LOOK AT SLIDES)
Partition each band into
8X8 blocks
Downsample color bands
Downside Cb and Cr by factor of 2
How to measure spatial redundancy
LOOK AT SLIDES
JPEG not good for text images
Makes text blocky
Color Conversion
RGB → YCbCr