CMPT 365 Multimedia Systems

Slides:



Advertisements
Similar presentations
Multimedia Data Compression
Advertisements

Sampling and Pulse Code Modulation
Quantization Prof. Siripong Potisuk.
School of Computing Science Simon Fraser University
Computer Graphics Recitation 6. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?
CSE 589 Applied Algorithms Spring 1999 Image Compression Vector Quantization Nearest Neighbor Search.
1 Audio Compression Techniques MUMT 611, January 2005 Assignment 2 Paul Kolesnik.
Lecture05 Transform Coding.
Department of Computer Engineering University of California at Santa Cruz Data Compression (3) Hai Tao.
1 Preprocessing for JPEG Compression Elad Davidson & Lilach Schwartz Project Supervisor: Ari Shenhar SPRING 2000 TECHNION - ISRAEL INSTITUTE of TECHNOLOGY.
Spatial and Temporal Data Mining
Lecture 7: Spring 2009 Lossless Compression Algorithms
Wavelet Based Image Coding. [2] Construction of Haar functions Unique decomposition of integer k  (p, q) – k = 0, …, N-1 with N = 2 n, 0
CSc 461/561 Multimedia Systems Part B: 2. Lossy Compression
Losslessy Compression of Multimedia Data Hao Jiang Computer Science Department Sept. 25, 2007.
SWE 423: Multimedia Systems Chapter 7: Data Compression (3)
CS :: Fall 2003 MPEG-1 Video (Part 1) Ketan Mayer-Patel.
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,
Wavelet-based Coding And its application in JPEG2000 Monia Ghobadi CSC561 project
CMPT 365 Multimedia Systems
T.Sharon-A.Frank 1 Multimedia Image Compression 2 T.Sharon-A.Frank Coding Techniques – Hybrid.
Department of Computer Engineering University of California at Santa Cruz Data Compression (2) Hai Tao.
SWE 423: Multimedia Systems Chapter 7: Data Compression (5)
Roger Cheng (JPEG slides courtesy of Brian Bailey) Spring 2007
Image Compression - JPEG. Video Compression MPEG –Audio compression Lossy / perceptually lossless / lossless 3 layers Models based on speech generation.
Lossy Compression Based on spatial redundancy Measure of spatial redundancy: 2D covariance Cov X (i,j)=  2 e -  (i*i+j*j) Vertical correlation   
Pulse Modulation 1. Introduction In Continuous Modulation C.M. a parameter in the sinusoidal signal is proportional to m(t) In Pulse Modulation P.M. a.
Compression is the reduction in size of data in order to save space or transmission time. And its used just about everywhere. All the images you get on.
CS Spring 2012 CS 414 – Multimedia Systems Design Lecture 8 – JPEG Compression (Part 3) Klara Nahrstedt Spring 2012.
Klara Nahrstedt Spring 2011
Quantization Heejune AHN Embedded Communications Laboratory Seoul National Univ. of Technology Fall 2013 Last updated
1 Multimedia Compression Algorithms Wen-Shyang Hwang KUAS EE.
EE465: Introduction to Digital Image Processing 1 Data Compression: Advanced Topics  Huffman Coding Algorithm Motivation Procedure Examples  Unitary.
Wavelet-based Coding And its application in JPEG2000 Monia Ghobadi CSC561 final project
Indiana University Purdue University Fort Wayne Hongli Luo
Digital Image Processing Image Compression
Outline Kinds of Coding Need for Compression Basic Types Taxonomy Performance Metrics.
Compression video overview 演講者:林崇元. Outline Introduction Fundamentals of video compression Picture type Signal quality measure Video encoder and decoder.
Introduction to Digital Signals
JPEG - JPEG2000 Isabelle Marque JPEGJPEG2000. JPEG Joint Photographic Experts Group Committe created in 1986 by: International Organization for Standardization.
Image Coding/ Compression
ELE 488 F06 ELE 488 Fall 2006 Image Processing and Transmission ( ) Image Compression Quantization independent samples uniform and optimum correlated.
JPEG.
Image transforms of Image compression
The Discrete Wavelet Transform for Image Compression Speaker: Jing-De Huang Advisor: Jian-Jiun Ding Graduate Institute of Communication Engineering National.
Image Processing Architecture, © Oleh TretiakPage 1Lecture 4 ECE-C490 Winter 2004 Image Processing Architecture Lecture 4, 1/20/2004 Principles.
Chapter 8 Lossy Compression Algorithms. Fundamentals of Multimedia, Chapter Introduction Lossless compression algorithms do not deliver compression.
Introduction to JPEG m Akram Ben Ahmed
Fundamentals of Multimedia Chapter 6 Basics of Digital Audio Ze-Nian Li and Mark S. Drew 건국대학교 인터넷미디어공학부 임 창 훈.
CS654: Digital Image Analysis Lecture 11: Image Transforms.
Chapter 13 Discrete Image Transforms
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,
Signal Prediction and Transformation Trac D. Tran ECE Department The Johns Hopkins University Baltimore MD
Chapter 8 Lossy Compression Algorithms
Design and Implementation of Lossless DWT/IDWT (Discrete Wavelet Transform & Inverse Discrete Wavelet Transform) for Medical Images.
JPEG Compression What is JPEG? Motivation
The Johns Hopkins University
Algorithms in the Real World
Outline Introduction Signal, random variable, random process and spectra Analog modulation Analog to digital conversion Digital transmission through baseband.
Last update on June 15, 2010 Doug Young Suh
Chapter 3 Sampling.
CSI-447: Multimedia Systems
Scalar Quantization – Mathematical Model
Foundation of Video Coding Part II: Scalar and Vector Quantization
Image Coding and Compression
Govt. Polytechnic Dhangar(Fatehabad)
Presentation transcript:

CMPT 365 Multimedia Systems Lossy Compression Spring 2015

Lossless vs Lossy Compression If the compression and decompression processes induce no information loss, then the compression scheme is lossless; otherwise, it is lossy. Why is lossy compression possible ? Original Compression Ratio: 7.7 Compression Ratio: 12.3 Compression Ratio: 33.9

Outline Quantization Uniform Non-uniform Transform coding DCT

Quantization The process of representing a large (possibly infinite) set of values with a much smaller set. Example: A/D conversion An efficient tool for lossy compression Review … Encoder Entropy coding Transform Quantization channel Decoder Entropy decoding Inverse Transform Inverse Quantization

Review: Basic Idea x x Bin 4 Bin 4 index index Input Values Bin 3 Entropy Coding Entropy Decoding Bin 2 Bin 2 Reconstruction Values x Bin 1 Bin 1 Bin 0 Bin 0 Quantizer Dequantizer (Inverse Quantizer) Quantization is a function that maps an input interval to one integer Can reduce the bits required to represent the source. Reconstructed result is generally not the original input Terminologies: Decision boundaries bi: bin boundaries Reconstruction levels yi: output value of each bin by the dequantizer.

Uniform Quantizer All bins have the same size except possibly for the two outer intervals: bi and yi are spaced evenly The spacing of bi and yi are both ∆ (step size) for inner intervals. Uniform Midrise Quantizer -2.5∆ -1.5∆ -0.5∆ Reconstruction 3∆ 2∆ ∆ -∆ -2∆ -3∆ Uniform Midtread Quantizer 0.5∆ 1.5∆ 2.5∆ Input Odd number of reconstruction levels 0 is a reconstruction level Reconstruction 3.5∆ 2.5∆ 1.5∆ 0.5 ∆ -3∆ -2∆ -∆ -0.5∆ ∆ 2∆ 3∆ Input -1.5∆ -2.5∆ -3.5∆ Even number of reconstruction levels 0 is not a reconstruction level

Midtread Quantizer Quantization mapping: Output is an index Example: -2.5∆ -1.5∆ -0.5∆ Reconstruction 3∆ 2∆ ∆ -∆ -2∆ -3∆ 0.5∆ 1.5∆ 2.5∆ Input Example: x = -1.8∆, q = -2. De-quantization mapping:

Model of Quantization A B - e(x) Q Quantization: q = A(x) Inverse Quantization: B(x) is not exactly the inverse function of A(x), because Quantization error: Q Combining quantizer and de-quantizer: - e(x) or

Rate-Distortion Tradeoff Things to be determined: Number of bins Bin boundaries Reconstruction levels Rate Distortion A B A tradeoff between rate and distortion: To reduce the size of the encoded bits, we need to reduce the number of bins Less bins  More reconstruction errors

Measure of Distortion MSE: Quantization error: Mean Squared Error (MSE) for Quantization Average quantization error of all input values Need to know the probability distribution of the input Number of bins: M Decision boundaries: bi, i = 0, …, M Reconstruction Levels: yi, i = 1, …, M Reconstruction: MSE: Same as the variance of e(x) if μ = E{e(x)} = 0 (zero mean). Definition of Variance:

Rate-Distortion Optimization Two Scenarios: Given M, find bi and yi that minimize the MSE. Given a distortion constraint D, find M, bi and yi such that the MSE ≤ D.

Outline Quantization Transform coding Uniform Non-uniform Vector quantization Transform coding DCT

Uniform Quantization of a Uniformly Distributed Source Input X: uniformly distributed in [-Xmax, Xmax]: f(x)= 1 / (2Xmax) Number of bins: M (even for midrise quantizer) Step size is easy to get: ∆ = 2Xmax / M. bi = (i – M/2) ∆ b4 b3 -∆ b2 -2∆ b1 -3∆ b0 -4∆ b5 ∆ b6 2∆ b7 3∆ b8 4∆ -Xmax Xmax y4 -0.5 ∆ y3 -1.5∆ y2 -2.5∆ y1 -3.5∆ y5 0. 5∆ y6 1.5∆ y7 2.5∆ y8 3.5∆ x  e(x) is uniformly distributed in [-∆/2, ∆/2]. x 0.5 ∆ -0.5 ∆ ∆ 2∆ 3∆ 4∆ -∆ -2∆ -3∆ -4∆

Uniform Quantization of a Uniformly Distributed Source MSE M increases, ∆ decreases, MSE decreases Variance of a random variable uniformly distributed in [- ∆/2, ∆/2]: Optimization: Find M such that MSE ≤ D

Signal to Noise Ratio (SNR) Variance is a measure of signal energy Let M = 2n Each bin index is represented by n bits If nn+1, ∆ is halved, noise variance reduces to 1/4, and SNR increases by 6 dB.

Outline Quantization Uniform Non-uniform Transform coding DCT

Non-uniform Quantization Uniform quantizer is not optimal if source is not uniformly distributed For given M, to reduce MSE, we want narrow bin when f(x) is high and wide bin when f(x) is low f(x) x

Lloyd-Max Quantizer f(x) yi Also known as pdf-optimized quantizer Given M, the optimal bi and yi that minimize MSE, satisfying f(x) x yi is the centroid of interval [bi-1, bi]. 0 bi-1 bi yi

Lloyd-Max Quantizer f(x) If f(x) = c (uniformly distributed source):  bi is the midpoint of yi and yi+1 x f(x) 0 bi-1 bi bi+1 yi yi+1

Lloyd-Max Quantizer Summary of conditions for optimal quantizer: Given bi, can find the corresponding optimal yi Given yi, can find the corresponding optimal bi How to find optimal bi and yi simultaneously? A deadlock: Reconstruction levels depend on decision levels Decision levels depend on reconstruction levels Solution: iterative method !

Lloyd Algorithm (Sayood pp. 267) Start from an initial set of reconstruction values yi. Find all decision levels Computer MSE: Stop if MSE changes little from last time. Otherwise, update yi, go to step 2.

Outline Quantization Transform coding Uniform quantization Non-uniform quantization Transform coding Discrete Cosine Transform (DCT)

Why Transform Coding ? Transform Purpose of transform From one domain/space to another space Time -> Frequency Spatial/Pixel -> Frequency Purpose of transform Remove correlation between input samples Transform most energy of an input block into a few coefficients Small coefficients can be discarded by quantization without too much impact to reconstruction quality Encoder Entropy coding Transform Quantization

1-D Example Fourier Transform

1-D Example Application (besides compression) Boost bass/audio equalizer Noise cancellation

1-D Example http://www.mathdemos.org/mathdemos/trigsounddemo/trigsounddemo.html Sine wave/sound/piano www.sagebrush.com/mousing.htm An electronic instrument that allows direct control of pitch and amplitude

1-D Example Smooth signals have strong DC (direct current, or zero frequency) and low frequency components, and weak high frequency components Sample Index DC High frequency High frequency DC

2-D Example Apply transform to each 8x8 block Histograms of source and DCT coefficients Most transform coefficients are around 0. Desired for compression

Rationale behind Transform If Y is the result of a linear transform T of the input vector X in such a way that the components of Y are much less correlated, then Y can be coded more efficiently than X. If most information is accurately described by the first few components of a transformed vector, then the remaining components can be coarsely quantized, or even set to zero, with little signal distortion.

Matrix Representation of Transform Linear transform is an N x N matrix: T X y Inverse Transform: T X y x -1 Unitary Transform (aka orthonormal): T X y x For unitary transform: rows/cols have unit norm and are orthogonal to each others

Discrete Cosine Transform (DCT) DCT – close to optimal (known as KL Transform) but much simpler and faster Definition: Matlab function: dct(eye(N));

DCT Definition: N = 2 (Haar Transform): y0 captures the mean of x0 and x1 (low-pass) x0 = x1 = 1  y0 = sqrt(2) (DC), y1 = 0 y1 captures the difference of x0 and x1 (high-pass) x0 = 1, x1 = -1  y0 = 0 (DC), y1 = sqrt(2).

DCT Magnitude Frequency Responses of 2-point DCT: Can be obtained by freqz( ) in Matlab. x 2π DC Low pass High pass

4-point DCT Four subbands 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.6533 0.2706 -0.2706 -0.6533 0.5000 -0.5000 -0.5000 0.5000 0.2706 -0.6533 0.6533 -0.2706 Four subbands x 2π

8-point DCT Eight subbands x 2π

Example x = [100 110 120 130 140 150 160 170]T; 8-point DCT: [381.8377, -64.4232, 0.0, -6.7345, 0.0, -2.0090, 0.0, -0.5070] Most energy are in the first 2 coefficients.

Block Transform Divide input data into blocks (2D) Encode each block separately (sometimes with information from neighboring blocks) Examples: Most DCT-based image/video coding standards

2-D DCT Basis For 2-point DCT For 4-point DCT

2-D Separable DCT Inverse Transform: X: N x N input block T: N x N transform A = TX: Apply T to each column of X B=XTT: Apply T to each row of X 2-D Separable Transform: Apply T to each row Then apply T to each column Inverse Transform:

2-D 8-point DCT Example Original Data: 89 78 76 75 70 82 81 82 122 95 86 80 80 76 74 81 184 153 126 106 85 76 71 75 221 205 180 146 97 71 68 67 225 222 217 194 144 95 78 82 228 225 227 220 193 146 110 108 223 224 225 224 220 197 156 120 217 219 219 224 230 220 197 151 2-D DCT Coefficients (after rounding to integers): 1155 259 -23 6 11 7 3 0 -377 -50 85 -10 10 4 7 -3 -4 -158 -24 42 -15 1 0 1 -2 3 -34 -19 9 -5 4 -1 1 9 6 -15 -10 6 -5 -1 3 13 3 6 -9 2 0 -3 8 -2 4 -1 3 -1 0 -2 2 0 -3 2 -2 0 0 -1 Most energy is in the upper- left corner

Interpretation of Transform Forward transform y = Tx (x is N x 1 vector) Let ti be the i-th row of T  yi = ti x = <tiT, x> (Inner product) yi measures the similarity between x and ti Higher similarity  larger transform coefficient x is the weighted combination of ti. Rows of T are called basis vectors. Inverse transform:

Interpretation of 2-D Transform 2-D basis matrices: Outer products of basis vectors Proof: X is the weighted combination of basic matrices.

2-D DCT Basis Matrices For 2-point DCT For 4-point DCT

2-D DCT Basis Matrices: 8-point DCT

Further Exploration Textbook 8.1-8.5 Other sources Introduction to Data Compression by Khalid Sayood Vector Quantization and Signal Compression by Allen Gersho and Robert M. Gray Digital Image Processing by Rafael C. Gonzales and Richard E.Woods Probability and Random Processes with Applications to Signal Processing by Henry Stark and John W. Woods A Wavelet Tour of Signal Processing by Stephane G. Mallat