Lecture11 Lossless
Lecture11 Lossless
Lecture11 Lossless
Knowledge Base
Roadmap
• Color image processing • Image compression
– Interpreting color – Data vs. information
– Pseudo-color IP – Entropy
• Intensity slicing – Data redundancy
• Transform in spatial domain • Coding redundancy
• Interpixel redundancy
• Transform in frequency
• Psycho-visual redundancy
domain
– Fidelity measurement
– Full-color IP
• Tonal correction • Lossless compression
• Color correction – Variable length coding
• Enhancement (I vs. RGB • Huffman coding
channels) – LZW
• Restoration (I vs. RGB – Bitplane coding
channels) – Binary image compression
• Color image edge detection • Run length coding
– Lossless predictive coding
• Lossy compression
Questions
• What is the difference between data and information?
• How to measure data redundancy?
• How many different types of data redundancy? Explain
each.
• What is entropy? What is the first/second order estimate of
entropy?
• Understand the two criteria that all coding mechanisms
should satisfy.
• Understand Huffman coding
• How do you explain the average coding length from
Huffman coding is always greater than the entropy?
• What image format uses which coding scheme?
• Understand RLC, differential coding
Data and Information
• Data and information
– Different data set can represent the same kind of
information
• Data redundancy
– Relative data redundancy
– I(E): self-information of E
– The amount of self-information attributed to
event E is inversely related to the probability of
E
– If base 2 is used, the unit of information is
called a bit
– Example: if P(E) = ½, then I(E) = -log2P(E) = 1.
Entropy
• Average information per source output, or
uncertainty, or entropy of the source
Can we do
this?
Huffman Coding
• Uniquely decodable
• Instantaneous coding
• Source reduction
– Order the probabilities of symbols
– Combine the lowest probability symbols into a
single symbol that replaces them in the next
source reduction
• Code each reduced source, starting with
the smallest source and working back to
the original source
Example
R1 0.25 (01) 0.25 (01) 0.25 (01) 0.25 (01) 0.35 (00) 0.4 (1) 0.6 (0)
R2 0.21 (10) 0.21 (10) 0.21 (10) 0.21 (10) 0.25 (01) 0.35 (00) 0.4 (1)
R0 0.19 (11) 0.19 (11) 0.19 (11) 0.19 (11) 0.21 (10) 0.25 (01)
R3 0.16 (001) 0.16 (001) 0.16 (001) 0.19 (000) 0.19 (11)
R4 0.08 (0001) 0.08 (0001) 0.11 (0000) 0.16 (001)
R5 0.06 (00000) 0.06 (00000) 0.08 (0001)
R6 0.03 (000010) 0.05 (00001)
R7 0.02 (000011)
Entropy of the source:
-0.25*log2(0.25) - 0.21*log2(0.21) - 0.19*log2(0.19) - 0.16*log2(0.16)
-0.08*log2(0.08) - 0.06*log2(0.06) - 0.03*log2(0.03) - 0.02*log2(0.02)
= 2.6508 bits/pixel
• Example:
– 127 0111 1111 0100 0000
– 128 1000 0000 1100 0000
Binary Image Compression
- RLC
• Developed in 1950s
• Standard compression approach in FAX
coding
• Approach
– Code each contiguous group of 0’s or 1’s
encountered in a left to right scan of a row by
its length
– Establish a convention for determining the
value of the run
– Code black and white run lengths separately
using variable-length coding
A Complete Example
2
Original image 127 128
3 32 33
Huffman 1 0.34 (1) 0.66 (0) 3 1.00 (0) 0 0.34 (1) 1 2 0.4 (1) 0.6 (0)
coding 2 0.33 (00) 0.34 (1) 1 0.33 (00) 2 2 0.4 (00) 0.4 (1)
3 0.33 (01) 2 0.33 (01) 0 1 0.2 (01)
126 1 1
Lossless Compression
Approaches
Averagely, use
Variable-length coding shorter-length
Code code to
redundancy Huffman coding convey the
same amount of
information
Bit-plane coding
Run-length coding
Interpixel LZW
redundancy
Predictive coding