EE465: Introduction to Digital Image Processing1 Lossy Image Compression: a Quick Tour of JPEG Coding Standard Why lossy for grayscale images?  Tradeoff.

Slides:



Advertisements
Similar presentations
Multimedia Data Compression
Advertisements

Chapter 7 End-to-End Data
SWE 423: Multimedia Systems
School of Computing Science Simon Fraser University
CSE 589 Applied Algorithms Spring 1999 Image Compression Vector Quantization Nearest Neighbor Search.
Department of Computer Engineering University of California at Santa Cruz Data Compression (3) Hai Tao.
Spatial and Temporal Data Mining
JPEG.
Losslessy Compression of Multimedia Data Hao Jiang Computer Science Department Sept. 25, 2007.
Image (and Video) Coding and Processing Lecture: DCT Compression and JPEG Wade Trappe Again: Thanks to Min Wu for allowing me to borrow many of her slides.
JPEG Still Image Data Compression Standard
Methods of Image Compression by PHL Transform Dziech, Andrzej Slusarczyk, Przemyslaw Tibken, Bernd Journal of Intelligent and Robotic Systems Volume: 39,
EE569 Digital Video Processing
CMPT 365 Multimedia Systems
T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid.
Multimedia Data The DCT and JPEG Image Compression Dr Mike Spann Electronic, Electrical and Computer.
Department of Computer Engineering University of California at Santa Cruz Data Compression (2) Hai Tao.
5. 1 JPEG “ JPEG ” is Joint Photographic Experts Group. compresses pictures which don't have sharp changes e.g. landscape pictures. May lose some of the.
Roger Cheng (JPEG slides courtesy of Brian Bailey) Spring 2007
1 JPEG Compression CSC361/661 Burg/Wong. 2 Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with.jpg.
Image Compression JPEG. Fact about JPEG Compression JPEG stands for Joint Photographic Experts Group JPEG compression is used with.jpg and can be embedded.
Lossy Image Compression
Trevor McCasland Arch Kelley.  Goal: reduce the size of stored files and data while retaining all necessary perceptual information  Used to create an.
Lossy Compression Based on spatial redundancy Measure of spatial redundancy: 2D covariance Cov X (i,j)=  2 e -  (i*i+j*j) Vertical correlation   
Introduction to JPEG Alireza Shafaei ( ) Fall 2005.
CS Spring 2012 CS 414 – Multimedia Systems Design Lecture 8 – JPEG Compression (Part 3) Klara Nahrstedt Spring 2012.
1 Image Compression. 2 GIF: Graphics Interchange Format Basic mode Dynamic mode A LZW method.
Klara Nahrstedt Spring 2011
Concepts of Multimedia Processing and Transmission IT 481, Lecture 5 Dennis McCaughey, Ph.D. 19 February, 2007.
EE591U Wavelets and Filter Banks Copyright Xin Li Roadmap to Lossy Image Compression JPEG standard: DCT-based image coding First-generation wavelet.
EE465: Introduction to Digital Image Processing 1 Data Compression: Advanced Topics  Huffman Coding Algorithm Motivation Procedure Examples  Unitary.
EE465: Introduction to Digital Image Processing1 Data Compression Techniques Text: WinZIP, WinRAR (Lempel-Ziv compression’1977) Image: JPEG (DCT-based),
CMPT 365 Multimedia Systems
JPEG. The JPEG Standard JPEG is an image compression standard which was accepted as an international standard in  Developed by the Joint Photographic.
Indiana University Purdue University Fort Wayne Hongli Luo
JPEG CIS 658 Fall 2005.
EE591f Digital Video Processing 1 Roadmap Introduction Intra-frame coding –Review of JPEG Inter-frame coding –Conditional Replenishment (CR) –Motion Compensated.
1 Image Formats. 2 Color representation An image = a collection of picture elements (pixels) Each pixel has a “color” Different types of pixels Binary.
CS Spring 2014 CS 414 – Multimedia Systems Design Lecture 10 – Compression Basics and JPEG Compression (Part 4) Klara Nahrstedt Spring 2014.
Advances in digital image compression techniques Guojun Lu, Computer Communications, Vol. 16, No. 4, Apr, 1993, pp
Digital Image Processing Lecture 21: Lossy Compression Prof. Charlene Tsai.
JPEG - JPEG2000 Isabelle Marque JPEGJPEG2000. JPEG Joint Photographic Experts Group Committe created in 1986 by: International Organization for Standardization.
JPEG (Joint Photographic Expert Group)
JPEG Image Compression Standard Introduction Lossless and Lossy Coding Schemes JPEG Standard Details Summary.
ELE 488 F06 ELE 488 Fall 2006 Image Processing and Transmission ( ) Image Compression Quantization independent samples uniform and optimum correlated.
CS654: Digital Image Analysis
STATISTIC & INFORMATION THEORY (CSNB134) MODULE 11 COMPRESSION.
Chapter 8 Lossy Compression Algorithms. Fundamentals of Multimedia, Chapter Introduction Lossless compression algorithms do not deliver compression.
Introduction to JPEG m Akram Ben Ahmed
JPEG. Introduction JPEG (Joint Photographic Experts Group) Basic Concept Data compression is performed in the frequency domain. Low frequency components.
By Dr. Hadi AL Saadi Lossy Compression. Source coding is based on changing of the original image content. Also called semantic-based coding High compression.
Entropy vs. Average Code-length Important application of Shannon’s entropy measure is in finding efficient (~ short average length) code words The measure.
Image Processing Architecture, © Oleh TretiakPage 1Lecture 5 ECEC 453 Image Processing Architecture Lecture 5, 1/22/2004 Rate-Distortion Theory,
Chapter 8 Lossy Compression Algorithms
JPEG Compression What is JPEG? Motivation
IMAGE PROCESSING IMAGE COMPRESSION
IMAGE COMPRESSION.
Chapter 9 Image Compression Standards
An Example of 1D Transform with Two Variables
Algorithms in the Real World
Digital Image Processing Lecture 21: Lossy Compression May 18, 2005
Digital Image Processing Lecture 21: Lossy Compression
JPEG Image Coding Standard
Discrete Cosine Transform
JPEG.
CMPT 365 Multimedia Systems
JPEG Still Image Data Compression Standard
Image Coding and Compression
Presentation transcript:

EE465: Introduction to Digital Image Processing1 Lossy Image Compression: a Quick Tour of JPEG Coding Standard Why lossy for grayscale images?  Tradeoff between Rate and Distortion Transform basics  Unitary transform and properties Quantization basics  Uniform Quantization and 6dB/bit Rule JPEG=T+Q+C  T: DCT, Q: Uniform Quantization, C: Run-length and Huffman coding

EE465: Introduction to Digital Image Processing2 Why Lossy? In most applications related to consumer electronics, lossless compression is not necessary  What we care is the subjective quality of the decoded image, not those intensity values With the relaxation, it is possible to achieve a higher compression ratio (CR)  For photographic images, CR is usually below 2 for lossless, but can reach over 10 for lossy

EE465: Introduction to Digital Image Processing3 A Simple Experiment Bit-plane representation A=a 0 +a 1 2+a … … +a Least Significant Bit (LSB) Most Significant Bit (MSB) Example A=129  a 0 a 1 a 2 …a 7 = a 0 a 1 a 2 …a 7 =  A= =204

EE465: Introduction to Digital Image Processing4 A Simple Experiment (Con ’ t) How will the reduction of gray-level resolution affect the image quality?  Test 1: make all pixels even numbers (i.e., knock down a 0 to be zero)  Test 2: make all pixels multiples of 4 (i.e., knock down a 0,a 1 to be zeros)  Test 3: make all pixels multiples of 4 (i.e., knock down a 0,a 1,a 2 to be zeros)

EE465: Introduction to Digital Image Processing5 Experiment Results original Test 1 Test 2 Test 3

EE465: Introduction to Digital Image Processing6 How to Measure Image Quality? Subjective  Evaluated by human observers  Do not require the original copy as a reference  Reliable, accurate yet impractical Objective  Easy to operate (automatic)  Often requires the original copy as the reference (measures fidelity rather than quality)  Works better if taking HVS model into account

EE465: Introduction to Digital Image Processing7 Mean Square Error (MSE) Peak Signal-to-Noise-Ratio (PSNR) Objective Quality Measures originaldecoded Question: Can you think of a counter-example to prove objective measure is not consistent with subjective evaluation?

EE465: Introduction to Digital Image Processing8 Answer Shifted (MSE=337.8)Original cameraman image By shifting the last row of the image to become the first row, we affect little on subjective quality but the measured MSE is large

EE465: Introduction to Digital Image Processing9 Overview of JPEG Lossy Compression Flow-chart diagram of DCT-based coding algorithm specified by Joint Photographic Expert Group (JPEG) TQ C

EE465: Introduction to Digital Image Processing10 Lossy Image Compression: a Quick Tour of JPEG Coding Standard Why lossy for grayscale images?  Tradeoff between Rate and Distortion Transform basics  Unitary transform and properties Quantization basics  Uniform Quantization and 6dB/bit Rule JPEG=T+Q+C  T: DCT, Q: Uniform Quantization, C: Run-length and Huffman coding

EE465: Introduction to Digital Image Processing11 An Example of 1D Transform with Two Variables x1x1 x2x2 y1y1 y2y2 Transform matrix (1,1) (1.414,0)

EE465: Introduction to Digital Image Processing12 forward transform Generalization into N Variables basis vectors (column vectors of transform matrix)

EE465: Introduction to Digital Image Processing13 Decorrelating Property of Transform x1x1 x2x2 y1y1 y2y2 x 1 and x 2 are highly correlated p(x 1 x 2 )  p(x 1 )p(x 2 ) y 1 and y 2 are less correlated p(y 1 y 2 )  p(y 1 )p(y 2 )

EE465: Introduction to Digital Image Processing14 Transform=Change of Coordinates Intuitively speaking, transform plays the role of facilitating the source modeling  Due to the decorrelating property of transform, it is easier to model transform coefficients (Y) instead of pixel values (X) An appropriate choice of transform (transform matrix A) depends on the source statistics P(X)  We will only consider the class of transforms corresponding to unitary matrices

EE465: Introduction to Digital Image Processing15 A matrix A is called unitary if A -1 =A* T Unitary Matrix and 1D Unitary Transform Definition conjugate transpose When the transform matrix A is unitary, the defined transform is called unitary transform Example For a real matrix A, it is unitary if A -1 =A T

EE465: Introduction to Digital Image Processing16 Inverse of Unitary Transform For a unitary transform, its inverse is defined by Inverse Transform basis vectors corresponding to inverse transform

EE465: Introduction to Digital Image Processing17 Properties of Unitary Transform Energy compaction: only few transform coefficients have large magnitude  Such property is related to the decorrelating role of unitary transform Energy conservation: unitary transform preserves the 2-norm of input vectors  Such property essentially comes from the fact that rotating coordinates does not affect Euclidean distance

EE465: Introduction to Digital Image Processing18 Energy Compaction Example Hadamard matrix insignificant significant

EE465: Introduction to Digital Image Processing19 Energy Conservation* A is unitary Proof

EE465: Introduction to Digital Image Processing20 Numerical Example Check:

EE465: Introduction to Digital Image Processing21 Implication of Energy Conservation A is unitary Q TT -1

EE465: Introduction to Digital Image Processing22 Summary of 1D Unitary Transform Unitary matrix: A -1 = A *T Unitary transform: A unitary Properties of 1D unitary transform  Energy compaction: most of transform coefficients y i are small  Energy conservation: quantization can be directly performed to transform coefficients

EE465: Introduction to Digital Image Processing23 Do N 1D transforms in parallel From 1D to 2D

EE465: Introduction to Digital Image Processing24 2D forward transform 1D column transform1D row transform Definition of 2D Transform

EE465: Introduction to Digital Image Processing25 2D Transform=Two Sequential 1D Transforms Conclusion:  2D separable transform can be decomposed into two sequential  The ordering of 1D transforms does not matter row transform column transform row transform column transform (left matrix multiplication first) (right matrix multiplication first)

EE465: Introduction to Digital Image Processing26 Energy Compaction Property of 2D Unitary Transform  Example insignificant coefficients (th=64) A coefficient is called significant if its magnitude is above a pre-selected threshold th

EE465: Introduction to Digital Image Processing27 Energy Conservation Property of 2D Unitary Transform Example: 2-norm of a matrix X A unitary You are asked to prove such property in your homework

EE465: Introduction to Digital Image Processing28 Implication of Energy Conservation Q TT -1 Similar to 1D case, quantization noise in the transform domain has the same energy as that in the spatial domain

EE465: Introduction to Digital Image Processing29 Important 2D Unitary Transforms Discrete Fourier Transform  Widely used in non-coding applications (frequency-domain approaches) Discrete Cosine Transform  Used in JPEG standard Hadamard Transform  All entries are  1  N=2: Haar Transform (simplest wavelet transform for multi-resolution analysis)

EE465: Introduction to Digital Image Processing30 Discrete Cosine Transform

EE465: Introduction to Digital Image Processing31 forward transforminverse transform 1D DCT  Real and orthogonal  fast implementation available: O(Nlog 2 N)  excellent energy compaction property  DCT is NOT the real part of DFT Fact The real and imaginary parts of DFT are generally not orthogonal matrices Properties

EE465: Introduction to Digital Image Processing32 2D DCT Notice the excellent energy compaction property of DCT Original cameraman image X Its DCT coefficients Y (2451 significant coefficients, th=64)

EE465: Introduction to Digital Image Processing33 Summary of 2D Unitary Transform Unitary matrix: A -1 =A *T Unitary transform: A unitary Properties of 2D unitary transform  Energy compaction: most of transform coefficients y i are small  Energy conservation: quantization can be directly performed to transform coefficients

EE465: Introduction to Digital Image Processing34 Lossy Image Compression: a Quick Tour of JPEG Coding Standard Why lossy for grayscale images?  Tradeoff between Rate and Distortion Transform basics  Unitary transform and properties Quantization basics  Uniform Quantization and 6dB/bit Rule JPEG=T+Q+C  T: DCT, Q: Uniform Quantization, C: Run-length and Huffman coding

EE465: Introduction to Digital Image Processing35 What is Quantization? In Physics  To limit the possible values of a magnitude or quantity to a discrete set of values by quantum mechanical rules In image compression  To limit the possible values of a pixel value or a transform coefficient to a discrete set of values by information theoretic rules

EE465: Introduction to Digital Image Processing36 Examples Unlike entropy, we encounter it everyday (so it is not a monster) Continuous to discrete  a quarter of milk, two gallons of gas, normal temperature is 98.6F, my height is 5 foot 9 inches Discrete to discrete  Round your tax return to integers  The mileage of my car is about 55K.

EE465: Introduction to Digital Image Processing37 A Game Played with Bits Precision is finite: the more precise, the more bits you need (to resolve the uncertainty)  Keep a card in secret and ask your partner to guess. He/she can only ask Yes/No questions: is it bigger than 7? Is it less than 4?... However, not every bit has the same impact  How much did you pay for your car? (two thousands vs. $ )

EE465: Introduction to Digital Image Processing38 Scalar vs. Vector Quantization We only consider the scalar quantization (SQ) in this course  Even for a sequence of values, we will process (quantize) each sample independently Vector quantization (VQ) is the extension of SQ into high-dimensional space  Widely used in speech compression, but not for image compression

EE465: Introduction to Digital Image Processing39 Definition of (Scalar) Quantization x f f -1 x ^ sSsS original value quantization index quantized value Quantizer x Q x ^ f finds the closest (in terms of Euclidean distance) approximation of x from a codebook C (a collection of codewords) and assign its index to s; f -1 operates like a table look-up to return the corresponding codeword

EE465: Introduction to Digital Image Processing40 Numerical Example (I) 0 1 C={-1,0,1} Three codewords S={1,2,3} 123 red: codewords green: index in C x x ^ xRxR

EE465: Introduction to Digital Image Processing41 Numerical Example (II) C={8,24,40,56,72,…,248} sixteen codewords S={1,2,3,…,16} 123 red: codewords green: index in C x x ^ x  {0,1,…,255} (note that the scales are different) 8 floor operation

EE465: Introduction to Digital Image Processing42 Numerical Example (III) Q x ^x  For scalar quantization, each sample is quantized independently Notes  Quantization is irreversible

EE465: Introduction to Digital Image Processing43 Uniform Quantization for Uniform Distribution Uniform Quantization A scalar quantization is called uniform quantization (UQ) if all its codewords are uniformly distributed (equally-distanced) Example (quantization stepsize  =16)  Uniform Distribution -A-AA 1/2A x f(x) denoted by U[-A,A]

EE465: Introduction to Digital Image Processing44 Quantization Noise of UQ  -  /2  /2 1/  e f(e) Quantization noise of UQ on uniform distribution is also uniformly distributed Recall Variance of U[-  /2,  /2] is -A-A A

EE465: Introduction to Digital Image Processing45 6dB/bit Rule Signal: X ~ U[-A,A] Noise: e ~ U[-  /2,  /2] Choose N=2 n (n-bit) codewords for X N=2 n (quantization stepsize)

EE465: Introduction to Digital Image Processing46 Lossy Image Compression: a Quick Tour of JPEG Coding Standard Why lossy for grayscale images?  Tradeoff between Rate and Distortion Transform basics  Unitary transform and properties Quantization basics  Uniform Quantization and 6dB/bit Rule JPEG=T+Q+C  T: DCT, Q: Uniform Quantization, C: Run-length and Huffman coding

EE465: Introduction to Digital Image Processing47 JPEG Coding Algorithm Overview

EE465: Introduction to Digital Image Processing48 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 Processing49 Block-based DCT Example J I 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 Processing50 Boundary Padding padded regions Example 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 Processing51 Work with a Toy Example Any 8-by-8 block in an image is processed in a similar fashion

EE465: Introduction to Digital Image Processing52 Encoding Stage I: Transform Step 1: DC level shifting 128 (DC level) _

EE465: Introduction to Digital Image Processing53 Step 2: 8-by-8 DCT Encoding Step 1: Transform (Con’t) 8  8 DCT

EE465: Introduction to Digital Image Processing54 Encoding Stage II: 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 Q ij is dependent on the coordinates ( i,j ) within the 8-by-8 block  Quantization stepsize Q ij increases from top-left to bottom-right

EE465: Introduction to Digital Image Processing55 Encoding Stage II: Quantization (Con’t) Example f x ij s ij

EE465: Introduction to Digital Image Processing56 Encoding Stage III: 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) zigzag scan End Of the Block: All following coefficients are zero

EE465: Introduction to Digital Image Processing57 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 - 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 Processing58 JPEG Decoding Stage I: Entropy 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) Huffman decoding encoded bit stream AC coefficients DC coefficient DPCM 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

EE465: Introduction to Digital Image Processing59 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 Processing60 JPEG Decoding Stage III: Inverse Transform 8  8 IDCT 128 (DC level) +

EE465: Introduction to Digital Image Processing61 Quantization Noise X X ^ MSE=|| X-X || 2 ^ Distortion calculation: Rate calculation: Rate=length of encoded bit stream/number of pixels (bps)

EE465: Introduction to Digital Image Processing62 JPEG Examples (58k bytes)50 (21k bytes)10 (8k bytes) best quality, lowest compression worst quality, highest compression

EE465: Introduction to Digital Image Processing63 Wavelet vs. DCT JPEG (CR=64)JPEG2000 (CR=64) discrete cosine transform basedwavelet transform based

EE465: Introduction to Digital Image Processing64 Image Compression Summary JPEG=T+Q+C (so is JPEG2000 except T becomes wavelet transform instead of DCT) Key idea: sparsity of transform coefficients (most transform coefficients are quantized to zero) Main weakness: blocky artifacts at low bit rates (many deblocking algorithms have been proposed in the literature)

EE465: Introduction to Digital Image Processing65 One-Minute Survey How much do you think you have understood today’s lecture?  A) >90%, B)70-90%, C)50-70%, D) <50% How long have you spent on final project so far? What is the best score you have reached so far? (please indicate your status: G/UG)