Chapter 7 Lossless Compression Algorithms 7.1 Introduction 7.2 Basics of Information Theory 7.3 Run-Length Coding 7.4 Variable-Length Coding (VLC) 7.5.

Slides:



Advertisements
Similar presentations
15-583:Algorithms in the Real World
Advertisements

Lecture 4 (week 2) Source Coding and Compression
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Huffman code and ID3 Prof. Sin-Min Lee Department of Computer Science.
Bounds on Code Length Theorem: Let l ∗ 1, l ∗ 2,..., l ∗ m be optimal codeword lengths for a source distribution p and a D-ary alphabet, and let L ∗ be.
Lecture04 Data Compression.
CSc 461/561 CSc 461/561 Multimedia Systems Part B: 1. Lossless Compression.
SWE 423: Multimedia Systems
Spatial and Temporal Data Mining
A Data Compression Algorithm: Huffman Compression
Data Compression Basics
Chapter 9: Huffman Codes
Fundamentals of Multimedia Chapter 7 Lossless Compression Algorithms Ze-Nian Li and Mark S. Drew 건국대학교 인터넷미디어공학부 임 창 훈.
Fundamentals of Multimedia Part II: Multimedia Data Compression Chapter 7 : Lossless Compression Algorithms 2 nd Edition 2014 Ze-Nian Li Mark S. Drew Jiangchuan.
Lossless Compression - I Hao Jiang Computer Science Department Sept. 13, 2007.
Data Compression Basics & Huffman Coding
1 Lossless Compression Multimedia Systems (Module 2) r Lesson 1: m Minimum Redundancy Coding based on Information Theory: Shannon-Fano Coding Huffman Coding.
©Brooks/Cole, 2003 Chapter 15 Data Compression. ©Brooks/Cole, 2003 Realize the need for data compression. Differentiate between lossless and lossy compression.
Data Structures and Algorithms Huffman compression: An Application of Binary Trees and Priority Queues.
Basics of Compression Goals: to understand how image/audio/video signals are compressed to save storage and increase transmission efficiency to understand.
Huffman Coding Vida Movahedi October Contents A simple example Definitions Huffman Coding Algorithm Image Compression.
8. Compression. 2 Video and Audio Compression Video and Audio files are very large. Unless we develop and maintain very high bandwidth networks (Gigabytes.
15-853Page :Algorithms in the Real World Data Compression II Arithmetic Coding – Integer implementation Applications of Probability Coding – Run.
Source Coding-Compression
296.3Page 1 CPS 296.3:Algorithms in the Real World Data Compression: Lecture 2.5.
CS Spring 2011 CS 414 – Multimedia Systems Design Lecture 7 – Basics of Compression (Part 2) Klara Nahrstedt Spring 2011.
Page 110/6/2015 CSE 40373/60373: Multimedia Systems So far  Audio (scalar values with time), image (2-D data) and video (2-D with time)  Higher fidelity.
1 Analysis of Algorithms Chapter - 08 Data Compression.
CMPT 365 Multimedia Systems
1 Multimedia Compression Algorithms Wen-Shyang Hwang KUAS EE.
Multimedia Data Introduction to Lossless Data Compression Dr Sandra I. Woolley Electronic, Electrical.
Compression.  Compression ratio: how much is the size reduced?  Symmetric/asymmetric: time difference to compress, decompress?  Lossless; lossy: any.
1 Classification of Compression Methods. 2 Data Compression  A means of reducing the size of blocks of data by removing  Unused material: e.g.) silence.
File Compression Techniques Alex Robertson. Outline History Lossless vs Lossy Basics Huffman Coding Getting Advanced Lossy Explained Limitations Future.
Lossless Compression CIS 465 Multimedia. Compression Compression: the process of coding that will effectively reduce the total number of bits needed to.
Image Compression – Fundamentals and Lossless Compression Techniques
COMPRESSION. Compression in General: Why Compress? So Many Bits, So Little Time (Space) CD audio rate: 2 * 2 * 8 * = 1,411,200 bps CD audio storage:
Huffman coding Content 1 Encoding and decoding messages Fixed-length coding Variable-length coding 2 Huffman coding.
Huffman Code and Data Decomposition Pranav Shah CS157B.
CS Spring 2011 CS 414 – Multimedia Systems Design Lecture 6 – Basics of Compression (Part 1) Klara Nahrstedt Spring 2011.
Lecture 4: Lossless Compression(1) Hongli Luo Fall 2011.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
Digital Image Processing Lecture 22: Image Compression
Bahareh Sarrafzadeh 6111 Fall 2009
Lossless Compression(2)
Lossless Decomposition and Huffman Codes Sophia Soohoo CS 157B.
Chapter 8 Lossy Compression Algorithms. Fundamentals of Multimedia, Chapter Introduction Lossless compression algorithms do not deliver compression.
Multi-media Data compression
1 Data Compression Hae-sun Jung CS146 Dr. Sin-Min Lee Spring 2004.
CS Spring 2012 CS 414 – Multimedia Systems Design Lecture 7 – Basics of Compression (Part 2) Klara Nahrstedt Spring 2012.
Chapter 7 Lossless Compression Algorithms 7.1 Introduction 7.2 Basics of Information Theory 7.3 Run-Length Coding 7.4 Variable-Length Coding (VLC) 7.5.
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Basics
Huffman Coding (2 nd Method). Huffman coding (2 nd Method)  The Huffman code is a source code. Here word length of the code word approaches the fundamental.
Lossless Compression-Statistical Model Lossless Compression One important to note about entropy is that, unlike the thermodynamic measure of entropy,
UNIT I. Entropy and Uncertainty Entropy is the irreducible complexity below which a signal cannot be compressed. Entropy is the irreducible complexity.
Chapter 7 Lossless Compression Algorithms
HUFFMAN CODES.
IMAGE PROCESSING IMAGE COMPRESSION
Data Coding Run Length Coding
Digital Image Processing Lecture 20: Image Compression May 16, 2005
Algorithms in the Real World
Applied Algorithmics - week7
Chapter 9: Huffman Codes
Why Compress? To reduce the volume of data to be transmitted (text, fax, images) To reduce the bandwidth required for transmission and to reduce storage.
Chapter 11 Data Compression
Huffman Coding CSE 373 Data Structures.
CSE 589 Applied Algorithms Spring 1999
Huffman Encoding Huffman code is method for the compression for standard text documents. It makes use of a binary tree to develop codes of varying lengths.
Presentation transcript:

Chapter 7 Lossless Compression Algorithms 7.1 Introduction 7.2 Basics of Information Theory 7.3 Run-Length Coding 7.4 Variable-Length Coding (VLC) 7.5 Dictionary-based Coding 7.6 Arithmetic Coding 7.7 Lossless Image Compression Li & Drew1

Fundamentals of Multimedia, Chapter Introduction Compression: the process of coding that will effectively reduce the total number of bits needed to represent certain information. Fig. 7.1: A General Data Compression Scheme. Li & Drew2

Fundamentals of Multimedia, Chapter 7 Introduction (cont’d) If the compression and decompression processes induce no information loss, then the compression scheme is lossless; otherwise, it is lossy. Compression ratio: (7.1) B 0 – number of bits before compression B 1 – number of bits after compression Li & Drew3

Fundamentals of Multimedia, Chapter Basics of Information Theory The entropy η of an information source with alphabet S = { s 1, s 2,..., s n } is: (7.2) (7.3) p i – probability that symbol s i will occur in S. – indicates the amount of information ( self- information as defined by Shannon) contained in s i, which corresponds to the number of bits needed to encode s i. Li & Drew4

Fundamentals of Multimedia, Chapter 7 Distribution of Gray-Level Intensities Fig. 7.2 Histograms for Two Gray-level Images. Fig. 7.2(a) shows the histogram of an image with uniform distribution of gray-level intensities, i.e., ∀ i p i = 1/256. Hence, the entropy of this image is: log = 8 (7.4) Fig. 7.2(b) shows the histogram of an image with two possible values. Its entropy is Li & Drew5

Fundamentals of Multimedia, Chapter 7 Entropy and Code Length As can be seen in Eq. (7.3): the entropy η is a weighted-sum of terms ; hence it represents the average amount of information contained per symbol in the source S. The entropy η specifies the lower bound for the average number of bits to code each symbol in S, i.e., (7.5) - the average length (measured in bits) of the codewords produced by the encoder. Li & Drew6

Fundamentals of Multimedia, Chapter Variable-Length Coding (VLC) Shannon-Fano Algorithm — a top-down approach 1. Sort the symbols according to the frequency count of their occurrences. 2. Recursively divide the symbols into two parts, each with approximately the same number of counts, until all parts contain only one symbol. An Example: coding of “HELLO” Frequency count of the symbols in ”HELLO”. Li & Drew7 SymbolHELOHELO Count

Fundamentals of Multimedia, Chapter 7 Fig. 7.3: Coding Tree for HELLO by Shannon-Fano. Li & Drew8

Fundamentals of Multimedia, Chapter 7 Table 7.1: Result of Performing Shannon-Fano on HELLO Li & Drew9 SymbolCountLog 2 Code# of bits used L H E O TOTAL # of bits:10

Fundamentals of Multimedia, Chapter 7 Fig. 7.4 Another coding tree for HELLO by Shannon-Fano. Li & Drew10

Fundamentals of Multimedia, Chapter 7 Table 7.2: Another Result of Performing Shannon-Fano on HELLO (see Fig. 7.4) Li & Drew11 SymbolCountLog 2 Code# of bits used L H E O TOTAL # of bits:10

Fundamentals of Multimedia, Chapter 7 Huffman Coding ALGORITHM 7.1 Huffman Coding Algorithm— a bottom-up approach 1. Initialization: Put all symbols on a list sorted according to their frequency counts. 2. Repeat until the list has only one symbol left: (1) From the list pick two symbols with the lowest frequency counts. Form a Huffman subtree that has these two symbols as child nodes and create a parent node. (2) Assign the sum of the children’s frequency counts to the parent and insert it into the list such that the order is maintained. (3) Delete the children from the list. 3. Assign a codeword for each leaf based on the path from the root. Li & Drew12

Fundamentals of Multimedia, Chapter 7 Fig. 7.5: Coding Tree for “HELLO” using the Huffman Algorithm. Li & Drew13

Fundamentals of Multimedia, Chapter 7 Huffman Coding (cont’d) In Fig. 7.5, new symbols P1, P2, P3 are created to refer to the parent nodes in the Huffman coding tree. The contents in the list are illustrated below: After initialization: L H E O After iteration (a): L P1 H After iteration (b): L P2 After iteration (c): P3 Li & Drew14

Fundamentals of Multimedia, Chapter 7 Properties of Huffman Coding 1. Unique Prefix Property: No Huffman code is a prefix of any other Huffman code - precludes any ambiguity in decoding. 2. Optimality: minimum redundancy code - proved optimal for a given data model (i.e., a given, accurate, probability distribution): The two least frequent symbols will have the same length for their Huffman codes, differing only at the last bit. Symbols that occur more frequently will have shorter Huffman codes than symbols that occur less frequently. * Huffman Coding has been adopted in fax machines, JPEG, and MPEG. Li & Drew15

Fundamentals of Multimedia, Chapter Lossless Image Compression Approaches of Differential Coding of Images: – Given an original image I ( x, y ), using a simple difference operator we can define a difference image d ( x, y ) as follows: d ( x, y ) = I ( x, y ) − I ( x − 1, y ) (7.9) or use the discrete version of the 2-D Laplacian operator to define a difference image d ( x, y ) as d ( x, y ) = 4 I ( x, y ) − I ( x, y − 1) − I ( x, y +1) − I ( x +1, y ) − I ( x − 1, y ) (7.10) Due to spatial redundancy existed in normal images I, the difference image d will have a narrower histogram and hence a smaller entropy, as shown in Fig Li & Drew16

Fundamentals of Multimedia, Chapter 7 Fig. 7.9: Distributions for Original versus Derivative Images. (a,b): Original gray-level image and its partial derivative image; (c,d): Histograms for original and derivative images. (This figure uses a commonly employed image called “Barb”.) Li & Drew17

Fundamentals of Multimedia, Chapter 7 Lossless JPEG Lossless JPEG: A special case of the JPEG image compression. The Predictive method 1. Forming a differential prediction: A predictor combines the values of up to three neighboring pixels as the predicted value for the current pixel, indicated by ‘X’ in Fig The predictor can use any one of the seven schemes listed in Table Encoding: The encoder compares the prediction with the actual pixel value at the position ‘X’ and encodes the difference using one of the lossless compression techniques we have discussed, e.g., the Huffman coding scheme. Li & Drew18

Fundamentals of Multimedia, Chapter 7 Fig. 7.10: Neighboring Pixels for Predictors in Lossless JPEG. Note: Any of A, B, or C has already been decoded before it is used in the predictor, on the decoder side of an encode-decode cycle. Li & Drew19

Fundamentals of Multimedia, Chapter 7 Table 7.6: Predictors for Lossless JPEG Li & Drew20 PredictorPrediction P1A P2B P3C P4A + B – C P5A + (B – C) / 2 P6B + (A – C) / 2 P7(A + B) / 2

Fundamentals of Multimedia, Chapter 7 Table 7.7: Comparison with other lossless compression programs Li & Drew21 Compression ProgramCompression Ratio LenaFootballF-18Flowers Lossless JPEG Optimal Lossless JPEG Compress (LZW) Gzip (LZ77) Gzip -9 (optimal LZ77) Pack(Huffman coding) See this: