Docsity

Lossless Compression: Huffman, Run-Length, Quadtrees, and Lossless JPEG, Slides of Multimedia Applications

Partial preview of the text

Download Lossless Compression: Huffman, Run-Length, Quadtrees, and Lossless JPEG and more Slides Multimedia Applications in PDF only on Docsity!

Lossless Compression

Compression

  • Compression : the process of coding that will

effectively reduce the total number of bits needed to represent certain information.

Information Theory

  • We define the entropy η of an information source with alphabet S = { s 1 , s 2 , …, s (^) n } as
  • pi - probability that s (^) i occurs in the source and log 2 1/ pi is amount of information in s (^) i

Information Theory

  • Figure (a) has a maximum entropy of 256 ×

(1/256 × log 2 256) = 8.

  • Any other distribution has lower entropy

Run-Length Coding

  • Run-length coding is a very widely used and

simple compression technique which does not assume a memoryless source

  • We replace runs of symbols (possibly of length one) with pairs of ( run-length, symbol )
  • For images, the maximum run-length is the size of a row

Variable Length Coding

  • A number of compression techniques are based on the entropy ideas seen previously.
  • These are known as entropy coding or variable length coding - The number of bits used to code symbols in the alphabet is variable - Two famous entropy coding techniques are Huffman coding and Arithmetic coding

Huffman Coding Algorithm

  1. Initialization: Put all symbols on a list sorted according to their frequency counts.
  2. Repeat until the list has only one symbol left:

a. 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.

Huffman Coding Algorithm

b. Assign the sum of the children's frequency counts to the parent and insert it into the list such that the order is maintained. c. Delete the children from the list.

  1. Assign a codeword for each leaf based on the

path from the root.

Huffman Coding Algorithm

Properties of Huffman Codes

  • No Huffman code is the prefix of any other Huffman codes so decoding is unambiguous
  • The Huffman coding technique is optimal (but we must know the probabilities of each symbol for this to be true)
  • Symbols that occur more frequently have shorter Huffman codes

Dictionary-based Coding

  • LZW uses fixed-length codewords to represent variable-length strings of symbols/characters that commonly occur together, e.g., words in English text.
  • The LZW encoder and decoder build up the same dictionary dynamically while receiving the data.
  • LZW places longer and longer repeated entries into a dictionary, and then emits the code for an element, rather than the string itself, if the element has already been placed in the dictionary.

LZW Compression Algorithm

LZW Example

Code String

1 a

2 b

2 c

LZW Example