Fundamentals of Multimedia. Lecture 5 Lossless Data Compression Variable Length Coding

Similar documents
EE67I Multimedia Communication Systems Lecture 4

Welcome Back to Fundamentals of Multimedia (MR412) Fall, 2012 Lecture 10 (Chapter 7) ZHU Yongxin, Winson

Intro. To Multimedia Engineering Lossless Compression

Lossless Compression Algorithms

Chapter 7 Lossless Compression Algorithms

Multimedia Networking ECE 599

Data Compression. An overview of Compression. Multimedia Systems and Applications. Binary Image Compression. Binary Image Compression

IMAGE PROCESSING (RRY025) LECTURE 13 IMAGE COMPRESSION - I

Image coding and compression

ENSC Multimedia Communications Engineering Huffman Coding (1)

Wireless Communication

IMAGE COMPRESSION. Image Compression. Why? Reducing transportation times Reducing file size. A two way event - compression and decompression

IMAGE COMPRESSION- I. Week VIII Feb /25/2003 Image Compression-I 1

Ch. 2: Compression Basics Multimedia Systems

Digital Image Processing

7.5 Dictionary-based Coding

Image Coding and Data Compression

Image Coding and Compression

Source Coding Basics and Speech Coding. Yao Wang Polytechnic University, Brooklyn, NY11201

CS 335 Graphics and Multimedia. Image Compression

MCS-375: Algorithms: Analysis and Design Handout #G2 San Skulrattanakulchai Gustavus Adolphus College Oct 21, Huffman Codes

Engineering Mathematics II Lecture 16 Compression

Entropy Coding. - to shorten the average code length by assigning shorter codes to more probable symbols => Morse-, Huffman-, Arithmetic Code

Chapter 1. Digital Data Representation and Communication. Part 2

Data and information. Image Codning and Compression. Image compression and decompression. Definitions. Images can contain three types of redundancy

Greedy Algorithms CHAPTER 16

Compression. storage medium/ communications network. For the purpose of this lecture, we observe the following constraints:

Department of electronics and telecommunication, J.D.I.E.T.Yavatmal, India 2

4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd

David Rappaport School of Computing Queen s University CANADA. Copyright, 1996 Dale Carnegie & Associates, Inc.

A Comparative Study of Entropy Encoding Techniques for Lossless Text Data Compression

ITCT Lecture 8.2: Dictionary Codes and Lempel-Ziv Coding

Repetition 1st lecture

Lecture 8 JPEG Compression (Part 3)

Huffman Coding. Version of October 13, Version of October 13, 2014 Huffman Coding 1 / 27

6. Finding Efficient Compressions; Huffman and Hu-Tucker

CSE 421 Greedy: Huffman Codes

Topic 5 Image Compression

Multimedia Systems. Part 20. Mahdi Vasighi

More Bits and Bytes Huffman Coding

Compressing Data. Konstantin Tretyakov

CMPT 365 Multimedia Systems. Media Compression - Image

A Research Paper on Lossless Data Compression Techniques

Without the move-to-front step abcddcbamnopponm is encoded as C* = (0, 1, 2, 3, 3, 2, 1, 0, 4, 5, 6, 7, 7, 6, 5, 4) (Table 1.14b).

Text Compression through Huffman Coding. Terminology

Image compression. Stefano Ferrari. Università degli Studi di Milano Methods for Image Processing. academic year

ENSC Multimedia Communications Engineering Topic 4: Huffman Coding 2

EE 368. Weeks 5 (Notes)

Image Compression. CS 6640 School of Computing University of Utah

Data Compression. Media Signal Processing, Presentation 2. Presented By: Jahanzeb Farooq Michael Osadebey

15 Data Compression 2014/9/21. Objectives After studying this chapter, the student should be able to: 15-1 LOSSLESS COMPRESSION

Digital Image Processing

Information Theory and Communication

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Analysis of Algorithms

An Advanced Text Encryption & Compression System Based on ASCII Values & Arithmetic Encoding to Improve Data Security

Algorithms Dr. Haim Levkowitz

Figure-2.1. Information system with encoder/decoders.

Lecture 8 JPEG Compression (Part 3)

Chapter 5 VARIABLE-LENGTH CODING Information Theory Results (II)

Simple variant of coding with a variable number of symbols and fixlength codewords.

Analysis of Algorithms - Greedy algorithms -

Overview. Last Lecture. This Lecture. Next Lecture. Data Transmission. Data Compression Source: Lecture notes

VC 12/13 T16 Video Compression

CIS 121 Data Structures and Algorithms with Java Spring 2018

CS473-Algorithms I. Lecture 11. Greedy Algorithms. Cevdet Aykanat - Bilkent University Computer Engineering Department

Data compression.

6. Finding Efficient Compressions; Huffman and Hu-Tucker Algorithms

Ch. 2: Compression Basics Multimedia Systems

Huffman Coding. (EE 575: Source Coding Project) Project Report. Submitted By: Raza Umar. ID: g

16 Greedy Algorithms

Basic Compression Library

IMAGE COMPRESSION TECHNIQUES

Greedy Algorithms. Alexandra Stefan

University of Waterloo CS240 Spring 2018 Help Session Problems

Distributed source coding

Image Compression - An Overview Jagroop Singh 1

Lecture 5: Compression I. This Week s Schedule

Data Compression Algorithms

Lempel-Ziv-Welch (LZW) Compression Algorithm

DEFLATE COMPRESSION ALGORITHM

Lecture 6 Introduction to JPEG compression

Digital Communication Prof. Bikash Kumar Dey Department of Electrical Engineering Indian Institute of Technology, Bombay

15 July, Huffman Trees. Heaps

An undirected graph is a tree if and only of there is a unique simple path between any 2 of its vertices.

Image Compression for Mobile Devices using Prediction and Direct Coding Approach

CMPSCI 240 Reasoning Under Uncertainty Homework 4

Data Compression. Guest lecture, SGDS Fall 2011

15-122: Principles of Imperative Computation, Spring 2013

Data Compression Fundamentals

On Generalizations and Improvements to the Shannon-Fano Code

yintroduction to compression ytext compression yimage compression ysource encoders and destination decoders

International Journal of Trend in Research and Development, Volume 3(2), ISSN: A Review of Coding Techniques in the Frequency

Noise Reduction in Data Communication Using Compression Technique

CS 206 Introduction to Computer Science II

Lecture: Analysis of Algorithms (CS )

Keywords Data compression, Lossless data compression technique, Huffman Coding, Arithmetic coding etc.

Greedy algorithms part 2, and Huffman code

CS/COE 1501

A Comprehensive Review of Data Compression Techniques

Transcription:

Fundamentals of Multimedia Lecture 5 Lossless Data Compression Variable Length Coding Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Fundamentals of Multimedia 1

Data Compression Compression and compression ratio Bound of lossless compression Data entropy Fixed Length Coding Run Length Coding (RLC) Outcomes of Lecture 4 Dictionary-based Coding Lempel-Ziv-Welch (LZW) algorithm Mahmoud El-Gayyar / Fundamentals of Multimedia 2

VariableLength Coding Shannon-Fano Algorithm Huffman Coding Algorithm Lossless Compression in JPEG images. Differential Coding Lossless JPEG Outline Mahmoud El-Gayyar / Fundamentals of Multimedia 3

VariableLength Coding Shannon-Fano Algorithm Huffman Coding Algorithm Lossless Compression in JPEG images. Differential Coding Lossless JPEG Outline Mahmoud El-Gayyar / Fundamentals of Multimedia 4

Variable Length Coding (VLC) The length of the codeword is variable depends on the probabilities of possible values in the alphabet (S) Symbols that occurs more frequently will have shorter codes. Mahmoud El-Gayyar / Fundamentals of Multimedia 5

Shannon-Fano Algorithm Example: Hello Symbol H E L O Count 1 1 2 1 Algorithm: Top-down approach Sort the symbols according to the frequency count of their occurrences. Recursively divide the symbols into two parts, each with approximately the same number of counts, until all parts contain only one symbol. Mahmoud El-Gayyar / Fundamentals of Multimedia 6

Example: Shannon-Fano. Symbol L H E O Count 2 1 1 1 Mahmoud El-Gayyar / Fundamentals of Multimedia 7

Example: Shannon-Fano. Symbol Count Log 2 1/p i Code # of bits L 2 1.32 0 2 H 1 2.32 10 2 E 1 2.32 110 3 O 1 2.32 111 3 Total number of bits 10 Mahmoud El-Gayyar / Fundamentals of Multimedia 8

Example: Another Coding- Shannon-Fano. Symbol Count Log 2 1/p i Code # of bits L 2 1.32 00 4 H 1 2.32 01 2 E 1 2.32 10 2 O 1 2.32 11 2 Total number of bits 10 Mahmoud El-Gayyar / Fundamentals of Multimedia 9

Huffman Coding Algorithm Algorithm: 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: 2.1 From the list pick two symbols with the lowest frequency counts. Form a Huffman sub-tree that has these two symbols as child nodes and create a parent node. 2.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. 2.3 Delete the children from the list. 3. Assign a codeword for each leaf based on the path from the root. Mahmoud El-Gayyar / Fundamentals of Multimedia 10

Example: Huffman Coding Symbol L H E O Count 2 1 1 1 After iteration1: L P1 H After iteration2: P2 L After iteration3: P3 Symbol L H E O Code 0 10 110 111 Mahmoud El-Gayyar / Fundamentals of Multimedia 11

Properties Huffman Coding Unique Prefix Property: No Huffman code is a prefix of any other Huffman code - prevents any ambiguity in decoding. Applied also to Shannon-Fano Optimality: minimum redundancy code. 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. The average code length for an information source S is strictly less than η + 1. Mahmoud El-Gayyar / Fundamentals of Multimedia 12

Shannon-Fano vs. Huffman Coding Example: In a message, the codes and their frequencies are A(15), B(7), C(6), D(6), E(5). Encode this message with Shannon-fano and Huffman coding. Try yourself! Shannon-fano: 89 bits Huffman : 87 bits Mahmoud El-Gayyar / Fundamentals of Multimedia 13

Data sequence Fixed vs. Variable Length Coding {AAAAAAAAAAAAAAABBBBBBBCDCDCDCDCDCDEEEEE} A text string containing 39 characters and their frequency counts as follows: A:(15), B:(7), C:(6), D:(6) and E:(5) Compare with fix length coding Probability Huffman Fix length A: 15/39 B: 7/39 C: 6/39 D: 6/39 E: 5/39 Total: 0 100 101 110 111 87 bits 000 001 010 011 100 117 bits Mahmoud El-Gayyar / Fundamentals of Multimedia 14

VariableLength Coding Shannon-Fano Algorithm Huffman Coding Algorithm Lossless Compression in JPEG images. Differential Coding Lossless JPEG Outline Mahmoud El-Gayyar / Fundamentals of Multimedia 15

Differential Coding 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) Due to spatial redundancy existed in normal images I, the difference image d will have a narrower histogram and hence a smaller entropy. Mahmoud El-Gayyar / Fundamentals of Multimedia 16

Differential Coding Mahmoud El-Gayyar / Fundamentals of Multimedia 17

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. The predictor can use any one of the seven schemes. Mahmoud El-Gayyar / Fundamentals of Multimedia 18

The Predictive method Lossless JPEG (2) 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. Since prediction must be based on previously encoded neighbors, first pixel in the image I(0, 0) use its own value. The pixels in the first row always use predictor P1, and those in the first column always use P2. Mahmoud El-Gayyar / Fundamentals of Multimedia 19

Other Lossless Compression Lossless compression usually yields a relatively low compression ratio, which renders it impractical for most multimedia applications. Mahmoud El-Gayyar / Fundamentals of Multimedia 20

VariableLength Coding Shannon-Fano Algorithm Huffman Coding Algorithm Lossless Compression in JPEG images. Differential Coding Lossless JPEG Summary Mahmoud El-Gayyar / Fundamentals of Multimedia 21