+ All Categories
Home > Documents > Lecture 7: Run-Length, Golomb, and Tunstall...

Lecture 7: Run-Length, Golomb, and Tunstall...

Date post: 04-Aug-2021
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
26
Lecture 7: Run-Length, Golomb, and Tunstall Codes Thinh Nguyen Oregon State University
Transcript
Page 1: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Lecture 7:Run-Length, Golomb, and

Tunstall Codes

Thinh NguyenOregon State University

Page 2: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Outline

Run-Length CodingGolomb CodingTunstall Coding

Page 3: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Lossless coding: Run-Length encoding (RLE)

Redundancy is removed by not transmitting consecutive identical symbols (pixels or character values that are equal).

The repeated value can be coded once, along with the number of times it repeats.

Useful for coding black and white images e.g. fax.

Page 4: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Binary RLECode the run length of 0’s using k bits. Transmit the code.Do not transmit runs of 1’s.Two consecutive 1’s are implicitly separately by a zero-length run of zero.

Example: suppose we use k = 4 bits to encode the run length (maximum run length of 15) for following bit patterns

Page 5: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

RLE Performance

Worst case behavior: transition occurs on each bit. Since we use k bits to represent the transition, we waste k-1 bits.

Best case behavior: no transition and use k bits to represent run length then the compression ratio is (2k-1)/k.

Page 6: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Can you improve RLE coding?

Why use fixed length coding for the length of a run?

Page 7: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Golomb CodingHow to code a potential infinite number of symbols?

Code the number of consecutive heads in a sequence of coin tosses.110, 1111110, 11111110, ….

Page 8: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Golomb Coding

Page 9: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Example

Page 10: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Another Way of Looking at GolombCode (m=5)

Page 11: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Run-Length Example, m = 5

Page 12: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Choosing m

Page 13: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Compression of Golomb Code

Page 14: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

GC Performance

Page 15: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Notes on GC Useful for binary compression when one symbol is much more likely than another.

binary imagesfax documentsbit planes for wavelet image compression

Need a parameter (the order)trainingadaptively learn the right parameter

Variable-to-variable length code

Last symbol needs to be a 1coder always adds a 1decoder always removes a 1

Page 16: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Tunstall Code

Page 17: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Tunstall Code PropertiesNo input code is a prefix of another to assure unique encodability.

Minimize the number of bits per symbol.

Page 18: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Prefix Code Properties

Page 19: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Prefix Code Properties

Consider the string “cc”. It does not have a code.

Send the unused code and some fixed code for the cc.

Generally, if there are k internal nodes in the prefix tree then there is a need for k-1 fixed codes.

Page 20: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Designing Tunstall Code

Page 21: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Example

Page 22: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Example

Page 23: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Example

Page 24: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Compression of Tunstall Code

Page 25: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Average Bit Rate of Tunstall Code

Page 26: Lecture 7: Run-Length, Golomb, and Tunstall Codesweb.engr.oregonstate.edu/~thinhq/teaching/ece499/spring... · 2006. 5. 9. · Code the run length of 0’s using k bits. Transmit

Notes on Tunstall CodeVariable-to-fixed length code

Error resilient

A flipped bit will introduce just one error in the output.Huffman is not error resilient. A single bit flip can destroy the code.


Recommended