390 likes | 659 Views
Data Compression Techniques. Text: WinZIP, WinRAR (Lempel-Ziv compression’1977) Image: JPEG (DCT-based), BMP (run-length coding) Video: VCD/DVD (MPEG), Real Player/Windows Media Player (H.263/H.264), BluRay Audio and Speech: MP3, G.728 (CELP). Lossless vs. Lossy Compression.
E N D
Data Compression Techniques • Text: WinZIP, WinRAR (Lempel-Ziv compression’1977) • Image: JPEG (DCT-based), BMP (run-length coding) • Video: VCD/DVD (MPEG), Real Player/Windows Media Player (H.263/H.264), BluRay • Audio and Speech: MP3, G.728 (CELP) EE465: Introduction to Digital Image Processing
Lossless vs. Lossy Compression One is original and the other is compressed, which one is original? Mathematical lossy can still be visually lossless EE465: Introduction to Digital Image Processing
Engineering is About Design and Implementation performance Product A Product B cost EE465: Introduction to Digital Image Processing
A Tour of JPEG Coding Algorithm C T Q Flow-chart diagram of DCT-based coding algorithm specified by Joint Photographic Expert Group (JPEG) EE465: Introduction to Digital Image Processing
T First Building Block: 8-by-8 DCT j DC i EE465: Introduction to Digital Image Processing
Transform Coding of Images • Why not transform the whole image together? • Require a large memory to store transform matrix • It is not a good idea for compression due to spatially varying statistics within an image • Idea of partitioning an image into blocks • Each block is viewed as a smaller-image and processed independently • It is not a magic, but a compromise EE465: Introduction to Digital Image Processing
Block Processing under MATLAB • Type “help blkproc” to learn the usage of this function • B = BLKPROC(A,[M N],FUN) processes the image A by applying the function FUN to each distinct M-by-N block of A, padding A with zeros if necessary. • Example I = imread('cameraman.tif'); fun = @dct2; J = blkproc(I,[8 8],fun); EE465: Introduction to Digital Image Processing
Block-based DCT Example I J note that white lines are artificially added to the border of each 8-by-8 block to denote that each block is processed independently EE465: Introduction to Digital Image Processing
Boundary Padding Example 12 13 14 15 16 17 18 19 12 13 14 15 16 17 18 19 12 13 14 15 16 17 18 19 12 13 14 15 16 17 18 19 padded regions When the width/height of an image is not the multiple of 8, the boundary is artificially padded with repeated columns/rows to make them multiple of 8 EE465: Introduction to Digital Image Processing
Work with a Toy Example Any 8-by-8 block in an image is processed in a similar fashion EE465: Introduction to Digital Image Processing
Encoding Stage I: Transform • Step 1: DC level shifting 128 (DC level) _ EE465: Introduction to Digital Image Processing
Encoding Step 1: Transform (Con’t) • Step 2: 8-by-8 DCT 88 DCT EE465: Introduction to Digital Image Processing
Second Building Block: Quantization Q-table : specifies quantization stepsize (see slide #28) Notes: • Q-table can be specified by customer • Q-table is scaled up/down by a chosen quality factor • Quantization stepsize Qij is dependent on the coordinates (i,j) within the 8-by-8 block • Quantization stepsize Qijincreases from top-left to bottom-right EE465: Introduction to Digital Image Processing
Encoding Stage II: Quantization (Con’t) Example sij xij f EE465: Introduction to Digital Image Processing
The Third Building Block: Entropy Coding zigzag scan (20,5,-3,-1,-2,-3,1,1,-1,-1, 0,0,1,2,3,-2,1,1,0,0,0,0,0, 0,1,1,0,1,EOB) End Of the Block: All following coefficients are zero Zigzag Scan EE465: Introduction to Digital Image Processing
Run-length Coding (20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB) DC coefficient AC coefficient - DC coefficient : DPCM coding encoded bit stream - AC coefficient : run-length coding (run, level) (5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB) (0,5),(0,-3),(0,-1),(0,-2),(0,-3),(0,1),(0,1),(0,-1),(0,-1),(2,0),(0,1), (0,2),(0,3),(0,-2),(0,1),(0,1),(6,0),(0,1),(0,1),(1,0),(0,1),EOB Huffman coding encoded bit stream EE465: Introduction to Digital Image Processing
JPEG Decoding Stage I: Entropy Decoding encoded bit stream Huffman decoding (0,5),(0,-3),(0,-1),(0,-2),(0,-3),(0,1),(0,1),(0,-1),(0,-1),(2,0),(0,1), (0,2),(0,3),(0,-2),(0,1),(0,1),(6,0),(0,1),(0,1),(1,0),(0,1),EOB encoded bit stream DPCM decoding (20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB) DC coefficient AC coefficients EE465: Introduction to Digital Image Processing
JPEG Decoding Stage II: Inverse Quantization (20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,EOB) zigzag f-1 EE465: Introduction to Digital Image Processing
JPEG Decoding Stage III: Inverse Transform 88 IDCT 128 (DC level) + EE465: Introduction to Digital Image Processing
Quantization Noise ^ X X ^ Distortion calculation: MSE=||X-X||2 Rate calculation: Rate=length of encoded bit stream/number of pixels (bps) EE465: Introduction to Digital Image Processing
JPEG Examples 10 (8k bytes) 50 (21k bytes) 90 (58k bytes) best quality, lowest compression 0 worst quality, highest compression 100 EE465: Introduction to Digital Image Processing
Rate-Distortion Tradeoff EE465: Introduction to Digital Image Processing
Block artifacts of JPEG when the bit rate is low (0.25bpp) EE465: Introduction to Digital Image Processing
JPEG Coding Algorithm Summary EE465: Introduction to Digital Image Processing
Lossy Compression of Color Images Color-space transformation luminance chrominance forward transform inverse transform Luminance channel can be treated just like a gray-scale image EE465: Introduction to Digital Image Processing
Compression of Chrominance Channels Q-Table Down-sampling 2 Cr/Cb Human eye is relatively insensitive to the high-frequency content of the chrominance channels. EE465: Introduction to Digital Image Processing
Technology is About New Tools • The same design principle but each building block can be replaced by a more advanced technique • Transform: DCT becomes Wavelet Transform • Quantization: uniform quantization becomes bitplane coding (to support scalability) • Entropy coding: Huffman coding becomes arithmetic coding (more flexible) • JPEG becomes JPEG2000 EE465: Introduction to Digital Image Processing
A Glimpse into Wavelet Transform* Multi-Resolution Analysis in Vision Human vision system is capable of interpreting the visual information regardless of the resolution EE465: Introduction to Digital Image Processing
Progressive Image Transmission • I hate to wait – show me a piece and see if I like it or not Low-resolution (LR) High-resolution (HR) EE465: Introduction to Digital Image Processing
Haar Transform – the simplest wavelet transform Example EE465: Introduction to Digital Image Processing
Reordering Coefficients approximation horizontal details Apply Haar transform to each 2-by-2 block vertical details diagonal details é ù 200 200 0 0 ê ú 100 100 0 0 ê ú regrouping = Y 0 0 0 0 ê ú ê ú 0 0 0 0 ë û EE465: Introduction to Digital Image Processing
é ù 200 200 0 0 ê ú 100 100 0 0 ê ú = Y 0 0 0 0 ê ú ê ú 0 0 0 0 ë û Multi-level Wavelet Transform Apply one-level Haar transform Apply Haar transform to Low-Low band only EE465: Introduction to Digital Image Processing
Image Example EE465: Introduction to Digital Image Processing
Wavelet Image Compression compressed bit stream Scalar Quantization Entropy Coding Wavelet Transform image Major improvements Wavelet transform instead of DCT Arithmetic coding instead of Huffman coding Modeling location instead of intensity Those are the topics in EE565: Advanced Image Processing EE465: Introduction to Digital Image Processing
FBI Wavelet Scalar Quantization (WSQ) Standard • Established by FBI in 1990s as the standard for fingerprint image compression • Wavelet-based: Daubechies’ wavelets were built just in time to win the race • Demonstrate better Rate-Distortion performance than DCT-based JPEG standard EE465: Introduction to Digital Image Processing
JPEG2000 Standard • Developed by ISO in late 1990s to replace the DCT-based JPEG standard • Accumulative research progress on wavelet image compression has dramatically pushed the art of lossy image compression forward • Demonstrate much better Rate-Distortion performance than DCT-based JPEG standard for typical photographic images EE465: Introduction to Digital Image Processing
Wavelet vs. DCT discrete cosine transform based wavelet transform based JPEG (CR=64) JPEG2000 (CR=64) EE465: Introduction to Digital Image Processing
BIGGER Question • Why haven’t we seen JPEG being replaced by JPEG2000? • Technical superiority DO NOT always imply economical wins (think about Unix vs. Windows) • THE next image compression standard has to wait for the right timing • Anyone including you can be a part of that business EE465: Introduction to Digital Image Processing