Compression. What. Why. Reduce the amount of information (bits) needed to represent image Video: 720 x 480 res, 30 fps, color

Similar documents
Image and Multidimensional Signal Processing

Image Compression. Qiaoyong Zhong. November 19, CAS-MPG Partner Institute for Computational Biology (PICB)

Reduce the amount of data required to represent a given quantity of information Data vs information R = 1 1 C

ECE472/572 - Lecture 11. Roadmap. Roadmap. Image Compression Fundamentals and Lossless Compression Techniques 11/03/11.

Image Compression. Fundamentals: Coding redundancy. The gray level histogram of an image can reveal a great deal of information about the image

IMAGE COMPRESSION-II. Week IX. 03/6/2003 Image Compression-II 1

repetition, part ii Ole-Johan Skrede INF Digital Image Processing

encoding without prediction) (Server) Quantization: Initial Data 0, 1, 2, Quantized Data 0, 1, 2, 3, 4, 8, 16, 32, 64, 128, 256

SYDE 575: Introduction to Image Processing. Image Compression Part 2: Variable-rate compression

IMAGE COMPRESSION IMAGE COMPRESSION-II. Coding Redundancy (contd.) Data Redundancy. Predictive coding. General Model

Multimedia Networking ECE 599

4. Quantization and Data Compression. ECE 302 Spring 2012 Purdue University, School of ECE Prof. Ilya Pollak

Image Compression - JPEG

Compression. Encryption. Decryption. Decompression. Presentation of Information to client site

Multimedia. Multimedia Data Compression (Lossless Compression Algorithms)

Overview. Analog capturing device (camera, microphone) PCM encoded or raw signal ( wav, bmp, ) A/D CONVERTER. Compressed bit stream (mp3, jpg, )

Module 2 LOSSLESS IMAGE COMPRESSION SYSTEMS. Version 2 ECE IIT, Kharagpur

L. Yaroslavsky. Fundamentals of Digital Image Processing. Course

Lecture 10 : Basic Compression Algorithms

Transform Coding. Transform Coding Principle

RLE = [ ; ], with compression ratio (CR) = 4/8. RLE actually increases the size of the compressed image.

Run-length & Entropy Coding. Redundancy Removal. Sampling. Quantization. Perform inverse operations at the receiver EEE

Basic Principles of Video Coding

Transform coding - topics. Principle of block-wise transform coding

Chapter 2: Source coding

Basics of DCT, Quantization and Entropy Coding

CSE 408 Multimedia Information System Yezhou Yang

Digital Image Processing Lectures 25 & 26

Introduction p. 1 Compression Techniques p. 3 Lossless Compression p. 4 Lossy Compression p. 5 Measures of Performance p. 5 Modeling and Coding p.

Image compression. Institute of Engineering & Technology, Ahmedabad University. October 20, 2015

Multimedia & Computer Visualization. Exercise #5. JPEG compression

CMPT 365 Multimedia Systems. Final Review - 1

Basics of DCT, Quantization and Entropy Coding. Nimrod Peleg Update: Dec. 2005

SIGNAL COMPRESSION. 8. Lossy image compression: Principle of embedding

BASICS OF COMPRESSION THEORY

Source Coding for Compression

Digital communication system. Shannon s separation principle

Image Compression Basis Sebastiano Battiato, Ph.D.

CMPT 365 Multimedia Systems. Lossless Compression

Source Coding. Master Universitario en Ingeniería de Telecomunicación. I. Santamaría Universidad de Cantabria

Image Data Compression

CompSci 267 Data Compression

Source Coding Techniques

Information and Entropy

Coding for Discrete Source

Wavelets & Mul,resolu,on Analysis

Real-Time Audio and Video

Lecture 7 Predictive Coding & Quantization

CHAPTER 3. Transformed Vector Quantization with Orthogonal Polynomials Introduction Vector quantization

Kotebe Metropolitan University Department of Computer Science and Technology Multimedia (CoSc 4151)

BASIC COMPRESSION TECHNIQUES

Objective: Reduction of data redundancy. Coding redundancy Interpixel redundancy Psychovisual redundancy Fall LIST 2

Waveform-Based Coding: Outline

Fault Tolerance Technique in Huffman Coding applies to Baseline JPEG

at Some sort of quantization is necessary to represent continuous signals in digital form

6.003: Signals and Systems. Sampling and Quantization

CS4800: Algorithms & Data Jonathan Ullman

Multimedia Communications. Scalar Quantization

Fundamentals. Relative data redundancy of the set. C.E., NCU, Taiwan Angela Chih-Wei Tang,

Compression and Coding

Compression. Reality Check 11 on page 527 explores implementation of the MDCT into a simple, working algorithm to compress audio.

JPEG Standard Uniform Quantization Error Modeling with Applications to Sequential and Progressive Operation Modes

Introduction to Video Compression H.261

Numerical Analysis. Carmen Arévalo Lund University Arévalo FMN011

Lecture 2: Introduction to Audio, Video & Image Coding Techniques (I) -- Fundaments

Can the sample being transmitted be used to refine its own PDF estimate?

Lecture 2: Introduction to Audio, Video & Image Coding Techniques (I) -- Fundaments. Tutorial 1. Acknowledgement and References for lectures 1 to 5

Compression methods: the 1 st generation

Autumn Coping with NP-completeness (Conclusion) Introduction to Data Compression

Multimedia Information Systems

Optimum Notch Filtering - I

Summary of Last Lectures

Wavelet Scalable Video Codec Part 1: image compression by JPEG2000

on a per-coecient basis in large images is computationally expensive. Further, the algorithm in [CR95] needs to be rerun, every time a new rate of com

On Compression Encrypted Data part 2. Prof. Ja-Ling Wu The Graduate Institute of Networking and Multimedia National Taiwan University

Image Compression. 1. Introduction. Greg Ames Dec 07, 2002

Proyecto final de carrera

Compressing a 1D Discrete Signal

Implementation of Lossless Huffman Coding: Image compression using K-Means algorithm and comparison vs. Random numbers and Message source

2018/5/3. YU Xiangyu

JPEG and JPEG2000 Image Coding Standards

Basic Principles of Lossless Coding. Universal Lossless coding. Lempel-Ziv Coding. 2. Exploit dependences between successive symbols.

CSEP 521 Applied Algorithms Spring Statistical Lossless Data Compression

Design of Optimal Quantizers for Distributed Source Coding

Objectives of Image Coding


Image Compression Using the Haar Wavelet Transform

Lec 05 Arithmetic Coding

Singular Value Decompsition

Chapter 9 Fundamental Limits in Information Theory

Sparse Regression Codes for Multi-terminal Source and Channel Coding

Compressing a 1D Discrete Signal

Scalable color image coding with Matching Pursuit

Learning goals: students learn to use the SVD to find good approximations to matrices and to compute the pseudoinverse.

Huffman Coding. C.M. Liu Perceptual Lab, College of Computer Science National Chiao-Tung University

UNIT I INFORMATION THEORY. I k log 2

Chapter 2 Date Compression: Source Coding. 2.1 An Introduction to Source Coding 2.2 Optimal Source Codes 2.3 Huffman Code

Information Theory. Coding and Information Theory. Information Theory Textbooks. Entropy

+ (50% contribution by each member)

Wavelets and Multiresolution Processing

Transcription:

Compression What Reduce the amount of information (bits) needed to represent image Video: 720 x 480 res, 30 fps, color Why 720x480x20x3 = 31,104,000 bytes/sec 30x60x120 = 216 Gigabytes for a 2 hour movie Transmission (send video over wireless channel) Storage (fit a 2 hour movie on a DVD)

Compression Model Image 1 compress Save/transmit (File 1) Image 2 decompress Save/transmit (File 2) channel Image1 == Image2 -> lossless <- reduces redundant info Image1!= Image2 -> lossy <- tries to reduce redundant & irrelevant info Size(File1)/Size(File2) -> compression ratio

Redundancy Coding redundancy More bits than necessary to create unique codes Spatiotemporal redundancy Correlation between pixels Patterns in image, motion in video Irrelevant information Human visual system cannot distinguish more than a certain number of gray levels in a given image

1. Coding redundancy p r ( r k ) = n k MN L 1 ( ) L avg = l r k p r r k l r k k=0 ( ) ( ) Number of bits needed for level k Code 1: L avg = 8 bits Code 2: L avg = 0.25*2+047*1+0.25*3+0.03*3=1.81 bits Compression ra?o C = 8/1.81 = 4.42

Informa?on Theory How much informa?on does a random event E give us? I(E)=log[ 1/P(E) ] = - log P(E) Base 2 log, unit of informa?on is bits If an event is sure to happen, i.e. P(E)=1, do I get much informa?on when it happens? Event: The sun rose this morning. Info: The world didn t end? If an event is unlikely to happen, small P(E), if it happens we get a lot of informa?on. Event: It is raining in my bedroom. Info: my roof must be leaking.

Information Theory Informa?on content of a signal - > entropy p(x) L 1 j=0 ( ) H = P(r j )log P(r j ) H = Low entropy p(x)log p(x)dx High entropy x Entropy gives the lower bound on #bits need to unambiguously represent a sequence of symbols

Back to coding example Code 1: L avg = 8 bits / pixel Code 2: L avg = 0.25*2+047*1+0.25*3+0.03*3=1.81 bits /pixel Compression ra?o C = 8/1.81 = 4.42 What does informa?on theory say? (all logs are base 2) H=- [0.25 log 0.25 + 0.47 log 0.47 + 0.25 log 0.25 + 0.03 log 0.03] H=1.6614 bits / pixel. This is a lower bound. Could be achieved theore?cally if coding groups of symbols rather than one at a?me

Huffman Coding Need a method for compu?ng the code Op?mal when coding one symbol at a?me Variable length code Source reduc?on step Order probabili?es Combine lowest probability pair into compound symbol, repeat.

Huffman Coding Code assignment step Start at the end, assign 0 and 1 to the two compound symbols, work backwards L avg = 0.4*1 + 0.3*2 + 0.1*3 + 0.1*4 + 0.06 *5 + 0.04*5 = 2.2 bits/pixel H=[0.4log0.4+0.3log0.3+0.1log0.1+0.1*log0.01+0.06log0.06+ 0.04log0.04]= 2.1435 bits/pixel JPEG, MPEG,H.261- H.264

Huffman coding Aeer the code is created, it serves as a look- up table for coding and lossless decoding Block code: each source symbol is mapped into a fixed sequence of code symbols Instantaneous: Each code work can be decoded without reference to previous symbols in the sequence. Unique: Any sequence of symbols can be decoded in only one way.

Coding example Generate the code for the sequence a 3 a 1 a 2 a 2 a 6 a 3 a 1 a 2 a 2 a 6 01010 011 1 1 00 010100111100

Decoding example Decode 010100111100. Find first valid code word 010100111100 - > a 3 Find next valid code word 010100111100 - > a 3 a 1 01010 011 1 1 00 - > a 3 a 1 a 2 a 2 a 6 a 3 a 1 a 2 a 2 a 6

2. Spatial redundancy Images have homogeneous regions Run-length encoding Row-major order Encode value of run and it s length Can combine with symbol encoder Good for images with few, discrete color values. For instance, binary images Issues How homogeneous is the data? Is there enough continuity in rows? BMP, JPEG,MPEG

BMP file format Uses a form of RLE. Two modes Encoded: 2 byte representa?on: first byte number of pixels, second byte value/color index Absolute: First byte 0. Second byte has special meaning Next 2 bytes posi?on This many uncompressed pixels follow

Fixed Length Codes Dictionary with strategy to capture special structure of data Example: LZW (Lempel-Ziv-Welch) Start with basic dictionary (e.g. grey levels) As new sequences of symbols are encountered add them to dictionary Hope: encode frequently occuring sequences of symbols Greedy Can decompress w/out table

LZW coding 39 39 126 126 39 39 126 126 39 39 126 126 39 39 126 126 4 x 4 image 512-word dictionary 0-255 stores intensities 256-511 initially unused Process left-to-right, top-tobottom fashion 16

39 39 126 126 39 39 126 126 39 39 126 126 39 39 126 126 4 x 4 image 512-word dictionary 0-255 stores intensities 256-511 initially unused Process left-to-right, topto-bottom fashion GIF, TIFF, PDF 17

3. Irrelevant information/ Quantization Eliminate symbols that are too small or not important Find a small set of approximating symbols (less entropy) Grey level or vector quantization Find values that minimize error Related to clustering in pattern recognition

Code: 11 10 01 00 Could also use Huffman coding to generate a more optimal code using the histogram of the image 19

Fidelity criteria SNR ms = M 1 x=0 N 1 y=0 M 1 x=0 # $ N 1 y=0 ˆf (x, y) 2 ˆf (x, y) f (x, y) % & 2 Approximation For instance quantized image Input Can we choose the quantization transform Q(f) to minimize SNR? 20

Bin boundaries min x = L 1 < L 2 < < L n+1 = max x Replacement values p 1, p 2,, p n q(x) = p j when L j <= x < L j+1 Choose L and p to minimize m Lloyd-Max algorithm E(L, p) = x q(x ) i i = x p i j i=1 j=1 x i [L j,l j+1 ) ( ) 2 n ( ) 2 21

Lloyd-Max algorithm E(L, p) = n j=1 Derivative with respect to p E = p j x i [L j,l j+1 ) ( x p ) 2 i j x i [L j,l j+1 ) 2( x i p ) j = 0 p j = x i [L j,l j+1 ) x i # i x i [L j, L j+1 ) { } Size of the set Update rule for p j Average intensity of pixels with intensities in this interval 22

Lloyd-Max algorithm E(L, p) = n j=1 ( x p ) 2 i j x i [L j,l j+1 ) Update rule for L L j =0.5*(p j-1 +p j ). Why? If you decrease L j, you will be assigning some x i to p j even though it is closer to p j-1 If you increase L j, you will be assigning some x i to p j-1 even though it is closer to p j 23

1. Start from uniform quantization bin boundaries 2. Update p using for j = 1 to n Lloyd-Max algorithm p j = x i [L j,l j+1 ) 3. Update L using L j =0.5*(p j-1 +p j ) for j=2 to n. Notice lower and upper limit always set to min and max of image. 4. Go to step 2 until convergence x i # i x i [L j, L j+1 ) { } 24

Image Compression Model Mapper: usually reduces spa?otemporal redundancy (run- length coding), but could also increase redundancy (less correlated transform coefficients). Lossless (reversible) Quan7zer: reduces irrelevant informa?on according to a fidelity criterion. Lossy Symbol coder: For instance Huffman coding. Lossless. Decoder: Undoes these in reverse order. Quan?za?on can t be undone

Block transform coding Forward transform: decorrelate pixels + pack as much info as possible into fewest transform coefficients. Quan7za7on: eliminate or coarsely quan?ze least informa?ve transform coefficients Symbol encoder: Variable length coding for quan?zed coefficients All steps can be adap?ve to subimages or fixed globally

Transforms n 1 n 1 T(u, v) = g(x, y)r(x, y,u, v) x=0 y=0 n 1 n 1 g(x, y) = T(u, v)s(x, y,u, v) u=0 v=0 Basis func?ons Forward transform Inverse transform Fourier basis: r(x,y,u,v) = e - j2π(ux+vy)/n s(x,y,u,v) = (1/n 2 )e j2π(ux+vy)/n

Walsh Hadamard transform (WHT) A computa?onally very simple method. Basis func?ons consists of only +1 and - 1 Math for how they are produced in the textbook No?ce frequency papern Basis func?ons r and s are iden?cal Example on the right is for n=4

Discrete Cosine Transform (DCT)!( 2x +1)uπ $!( 2y +1)vπ $ r(x, y,u, v) = s(x, y,u, v) = α(u)α(v)cos# &cos# & " 2n % " 2n % ( * * α(u) = ) * * + 1 n 2 n u = 0 u =1, 2,..., n 1 Real valued basis func?ons Used in JPEG

Fourier Walsh Hadamard Discrete Cosine Reconstruc?on Error 8 x 8 blocks: 64 coefficients, in each block 32 coefficients with smallest magnitude were truncated. Blocks then reconstructed from remaining 32 coefficients. RMS Errors: Fourier 2.32, WHT 1.78, DCT 1.13

Subimage size selec?on n is usually a power of 2 Larger n increases computa?onal complexity (transforms don t scale linearly with number of pixels in subimage) 25% coefficients retained

How to truncate n 1 n 1 g(x, y) = T(u, v)x(u, v)s(x, y,u, v) u=0 v=0 Top: zonal mask X(u,v). Fixed strategy Bopom: threshold mask. Depends on subimage. Have to also know which elements we are keeping

How to quan?ze Zonal strategy for how many bits used per coefficient for quan?za?on

Block Transform Coding: JPEG International standard (ISO) Baseline algorithm with extensions Transform: discrete cosine transform (DCT) Encodes freq. Info w/out complex #s FT of larger, mirrored signal Does not have other nice prop. of FT

JPEG Algorithm Integer grey-level image broken into 8x8 sub blocks Set middle (mean?) grey level to zero (subtract middle) DCT of sub blocks (11 bit precision) -> T(u,v) Rescale frequency components by Z(u,v) and round

Rescaling Different scalling matrices possible, but recommended is:

Reordering DCT entries reordered in zig-zag fashion to increase coherency (produce blocks of zeros)

Coding Each sub-block is coded as a difference from previous sub-block Zeros are run-length encoded and nonzero elements are Huffman coded Modified HC to allow for zeros

JPEG Example Compression Ratio ~10:1 Loss of high frequencies Ringing Block artifacts