Advanced Image/Video Processing: Image Compression Slide: 7Data Redundancy cont’d Compression ratio: Relative data redundancy: Example:... Advanced Image/Video Processing: Image Compre
Trang 2Introduction
Lossless Compression
Lossy Compression
Trang 3Advanced Image/Video Processing: Image Compression Slide: 3
Introduction
The goal of image compression is to reduce the amount of data required to represent a digital image.
Important for reducing storage
requirements and improving transmission
rates.
Trang 4 Does not preserve information
High compression ratios
e.g., JPEG
Trang 5Advanced Image/Video Processing: Image Compression Slide: 5
Data vs Information
Data and information are not synonymous terms!
Data is the means by which information is
conveyed.
Data compression aims to reduce the amount of data required to represent a given quantity of information while preserving as much information
as possible.
Trang 6Data Redundancy
Data redundancy is a mathematically
quantifiable entity!
compression
Trang 7Advanced Image/Video Processing: Image Compression Slide: 7
Data Redundancy (cont’d)
Compression ratio:
Relative data redundancy:
Example:
Trang 8Types of Data Redundancy
(1) Coding (2) Interpixel (3) Psychovisual
The role of compression is to reduce one or more of these redundancy types.
Trang 9Advanced Image/Video Processing: Image Compression Slide: 9
Trang 10Encoding Schemes
Elements of an encoding scheme:
Code: a list of symbols (letters, numbers, bits etc.)
Code word: a sequence of symbols used to represent a piece of information or an event (e.g., gray levels)
Code word length: number of symbols in each code word
Trang 11Advanced Image/Video Processing: Image Compression Slide: 11
Definitions
N x M image
rk: k-th gray levelP(rk): probability of rk
x
E XExpected value:= ∑ xP X = x
Trang 12Constant Length Coding
l(rk) = c which implies that Lavg=c
Example:
Trang 13Advanced Image/Video Processing: Image Compression Slide: 13
Avoiding Coding Redundancy
To avoid coding redundancy, codes should
be selected according to the probabilities of the events.
• Variable Length Coding
Assign fewer symbols (bits) to the more
probable events (e.g., gray levels for images)
Trang 14Variable Length Coding
Consider the probability of the gray levels:
variable length
Trang 15Advanced Image/Video Processing: Image Compression Slide: 15
Trang 16Interpixel redundancy (cont’d)
To reduce interpixel redundnacy, the data must
be transformed in another format (i.e., through a
Trang 17Advanced Image/Video Processing: Image Compression Slide: 17
Interpixel redundancy (cont’d)
To reduce interpixel redundnacy, the data must
be transformed in another format (i.e., through a
Trang 18Psychovisual redundancy
Takes into advantage the peculiarities of the human visual system.
The eye does not respond with equal
sensitivity to all visual information.
Humans search for important features (e.g., edges, texture, etc.) and do not perform
Trang 19Advanced Image/Video Processing: Image Compression Slide: 19
Psychovisual redundancy (cont’d)
Example: Quantization
256 gray levels 16 gray levels 16 gray levelsimproved gray-scale quantization
8/4 =2:1
i.e., add to each pixel a pseudo-random number prior to quantization
Trang 20How do we measure information?
What is the information content of a
message/image?
What is the minimum amount of data that is sufficient to describe completely an image
Trang 21Advanced Image/Video Processing: Image Compression Slide: 21
Modeling the Information Generation
Trang 22How much information does a pixel
contain?
Suppose that the gray level value of pixels
is generated by a random variable, then rkcontains
units of information
Trang 23Advanced Image/Video Processing: Image Compression Slide: 23
Entropy: the average information content of
Trang 24Redundancy:
Modeling the Information Generation Process
(cont’d)
where:
Trang 25Advanced Image/Video Processing: Image Compression Slide: 25
Entropy Estimation
Not easy!
image
Trang 26Entropy Estimation
First order estimate of H:
Trang 27Advanced Image/Video Processing: Image Compression Slide: 27
Estimating Entropy (cont’d)
Second order estimate of H:
Use relative frequencies of pixel blocks :
image
Trang 28Estimating Entropy (cont’d)
Comments on first and second order entropy
Trang 29Advanced Image/Video Processing: Image Compression Slide: 29
Question
How do we deal with interpixel
redundancy?
Apply a transformation!
Trang 30Estimating Entropy (cont’d)
E.g., consider difference image:
Trang 31Advanced Image/Video Processing: Image Compression Slide: 31
Estimating Entropy (cont’d)
Entropy of difference image:
• Better than before (i.e., H=1.81 for original image), however, a better transformation could be found:
Trang 32Image Compression Model
Trang 33Advanced Image/Video Processing: Image Compression Slide: 33
Image Compression Model (cont’d)
Mapper: transforms the input data into a format that
facilitates reduction of interpixel redundancies.
Trang 34Image Compression Model (cont’d)
Quantizer: reduces the accuracy of the mapper’s
Trang 35Advanced Image/Video Processing: Image Compression Slide: 35
Image Compression Model (cont’d)
Symbol encoder: assigns the shortest code to
the most frequently occurring output values.
Trang 36Image Compression Models (cont’d)
The inverse operations are performed.
Trang 37Advanced Image/Video Processing: Image Compression Slide: 37
Fidelity Criteria
How close is to ?
Criteria
Subjective: based on human observers
Objective: mathematically defined criteria
Trang 38Subjective Fidelity Criteria
Trang 39Advanced Image/Video Processing: Image Compression Slide: 39
Objective Fidelity Criteria
Root mean square error (RMS)
Mean-square signal-to-noise ratio (SNR)
Trang 40original RMS=5.17 RMS=15.67 RMS=14.17
Trang 41Advanced Image/Video Processing: Image Compression Slide: 41
Lossless Compression
• Huffman, Golomb, Arithmetic coding redundancy
• LZW, Run-length, Symbol-based, Bit-plane interpixel redundancy
Trang 42Huffman Coding (i.e., removes coding redundancy)
It is a variable-length coding technique.
It creates the optimal code for a set of source
Trang 43Advanced Image/Video Processing: Image Compression Slide: 43
Huffman Coding (cont’d)
Optimal code: minimizes the number of
code symbols per source symbol.
• Forward Pass
1 Sort probabilities per symbol
2 Combine the lowest two probabilities
3 Repeat Step2 until only two
probabilities remain
Trang 44Huffman Coding (cont’d)
Backward Pass
Assign code symbols going backwards
Trang 45Advanced Image/Video Processing: Image Compression Slide: 45
Huffman Coding (cont’d)
Lavg using Huffman coding:
Lavg assuming binary codes:
Trang 46Huffman Coding (cont’d)
Comments
After the code has been created,
a look-up table
Decoding can be done in an unambiguous way !!
Trang 47Advanced Image/Video Processing: Image Compression Slide: 47
Arithmetic (or Range) Coding (i.e., removes coding redundancy)
No assumption on encoding symbols one at a time
No one-to-one correspondence between source and code words.
Slower than Huffman coding but typically achieves better compression
A sequence of source symbols is assigned a single
arithmetic code word which corresponds to a sub-interval
in [0,1]
Trang 48Arithmetic Coding (cont’d)
As the number of symbols in the message
increases, the interval used to represent it becomes smaller.
Each symbol reduces the size of the interval according to its probability.
Smaller intervals require more information
Trang 49Advanced Image/Video Processing: Image Compression Slide: 49
Arithmetic Coding (cont’d)
Encode message: a1 a2 a3 a3 a4
1) Assume message occupies [0, 1)
2) Subdivide [0, 1) based on the probabilities of αi
3) Update interval by processing source symbols
Trang 50a1 a2 a3 a3 a4
Trang 51Advanced Image/Video Processing: Image Compression Slide: 51
Example
• The message a1 a2 a3 a3 a4 is encoded using 3 decimal digits
or 0.6 decimal digits per source symbol
• The entropy of this message is:
Note: Finite precision arithmetic might cause problems due to
truncations!
-(3 x 0.2log10(0.2)+0.4log10(0.4))= 0.5786 digits/symbol
Trang 52a3
a4
Trang 53Advanced Image/Video Processing: Image Compression Slide: 53
LZW Coding (i.e., removes inter-pixel redundancy)
Requires no priori knowledge of probability
Trang 54LZW Coding
A codebook or a dictionary has to be constructed.
For an 8-bit image, the first 256 entries are
assigned to the gray levels 0,1,2, ,255.
As the encoder examines image pixels, gray level
Trang 55Advanced Image/Video Processing: Image Compression Slide: 55
Trang 56- What about 39-39………….No
- Then add 39-39 in entry 256
Dictionary Location Entry
255 255
Trang 57Advanced Image/Video Processing: Image Compression Slide: 57
Trang 58Decoding LZW
• The dictionary which was used for encoding need not
be sent with the image
• A separate dictionary is built by the decoder, on the
“fly”, as it reads the received code words.
Trang 59Advanced Image/Video Processing: Image Compression Slide: 59
Run-length coding (RLC) (i.e., removes interpixel redunancy)
Used to reduce the size of a repeating string of characters (i.e.,
runs)
a a a b b b b b b c c (a,3) (b, 6) (c, 2)
Encodes a run of symbols into two bytes , a count and a
symbol
Can compress any type of data but cannot achieve high
compression ratios compared to other compression methods.
Trang 60Run-length coding (i.e., removes interpixel redunancy)
Code each contiguous group of 0’s and 1’s, encountered in a left to right scan of a row,
by its length.
1 1 1 1 1 0 0 0 0 0 0 1 (1,5) (0, 6) (1, 1)
Trang 61Advanced Image/Video Processing: Image Compression Slide: 61
Bit-plane coding (i.e., removes interpixel redundancy)
An effective technique to reduce inter pixel redundancy is
to process each bit plane individually
The image is decomposed into a series of binary images
Each binary image is compressed using one of well known binary compression techniques
e.g., Huffman, Run-length, etc
Trang 62Combining Huffman Coding
with Run-length Coding
Once a message has been encoded using
Huffman coding, additional compression can be achieved by encoding the lengths of the runs using variable-length coding!
Trang 63Advanced Image/Video Processing: Image Compression Slide: 63
Lossy Compression
Transform the image into a domain where
compression can be performed more efficiently.
Note that the transformation itself does not
compress the image!
~ (N/n) 2 subimages
Trang 64Lossy Compression (cont’d)
Example: Fourier Transform
The magnitude of the
FT decreases, as u, v
increase!
K << N
Trang 65Advanced Image/Video Processing: Image Compression Slide: 65
Transform Selection
T(u,v) can be computed using various
transformations, for example:
DCT (Discrete Cosine Transform)
KLT (Karhunen-Loeve Transformation)
Trang 66forward
inverse
Trang 67Advanced Image/Video Processing: Image Compression Slide: 67
DCT (cont’d)
Basis set of functions for a 4x4 image
(i.e.,cosines of different frequencies).
Trang 69Advanced Image/Video Processing: Image Compression Slide: 69
Trang 71Advanced Image/Video Processing: Image Compression Slide: 71
(4) Hierarchical encoding
Trang 72JPEG Compression
(Sequential DCT-based encoding)
encoder
Trang 73Advanced Image/Video Processing: Image Compression Slide: 73
JPEG Steps
1 Divide the image into 8x8 subimages;
For each subimage do:
2 Shift the gray-levels in the range [-128,
127]
3 Apply DCT (64 coefficients will be
obtained: 1 DC coefficient F(0,0), 63 AC coefficients F(u,v)).
4 Quantize the coefficients (i.e., reduce the
amplitude of coefficients that do not contribute a lot).
Quantization Table
Trang 74Advanced Image/Video Processing: Image Compression Slide: 74
JPEG Steps (cont’d)
5 Order the coefficients using zig-zag
ordering
- Place non-zero coefficients first
- Create long runs of zeros (i.e., good for run-length encoding)
Trang 75Advanced Image/Video Processing: Image Compression Slide: 75
Shifting and DCT
(non-centeredspectrum)
Trang 76Quantization Table Example
Trang 77Advanced Image/Video Processing: Image Compression Slide: 77
Quantization (cont’d)
Trang 78Zig-Zag Ordering (cont’d)
Trang 79Advanced Image/Video Processing: Image Compression Slide: 79
Intermediate Coding (cont’d)
Trang 80DC/AC Symbol Encoding
Trang 81Advanced Image/Video Processing: Image Compression Slide: 81
Entropy Encoding (cont’d)
DC
End of Block
Trang 82Entropy Encoding
Symbol_1
(Variable Length Code (VLC)) (Variable Length Integer (VLI))Symbol_2
Trang 83Advanced Image/Video Processing: Image Compression Slide: 83
highest compression
Trang 84Results
Trang 85Advanced Image/Video Processing: Image Compression Slide: 85
Progressive JPEG
The image is encoded in multiple scans, in order to produce a quick, rough decoded image when transmission time is long.
Trang 86Progressive JPEG (cont’d)
Each scan, codes a subset of DCT
coefficients.
Let’s look at three methods:
(1) Progressive spectral selection algorithm
Trang 87Advanced Image/Video Processing: Image Compression Slide: 87
Progressive JPEG (cont’d)
(1) Progressive spectral selection algorithm
Group DCT coefficients into several spectral bands
Send low-frequency DCT coefficients first
Send higher-frequency DCT coefficients next
Trang 88Progressive JPEG (cont’d)
(2) Progressive successive approximation
Trang 89Advanced Image/Video Processing: Image Compression Slide: 89
Progressive JPEG (cont’d)
(3) Combined progressive algorithm
Combines spectral selection and successive approximation.
Trang 90Results using spectral selection
Trang 91Advanced Image/Video Processing: Image Compression Slide: 91
Results using successive
approximation
Trang 92Example using successive
approximation
after 0.9s after 1.6s
after 3.6s after 7.0s
Trang 93Advanced Image/Video Processing: Image Compression Slide: 93
Lossless JPEG
Use a predictive algorithm instead of DCT-based
Trang 94Fingerprint Compression
An image coding standard for digitized
fingerprints, developed and maintained by:
Los Alamos National Lab (LANL)
National Institute for Standards and Technology (NIST).
Trang 95Advanced Image/Video Processing: Image Compression Slide: 95
Trang 96Preserving Fingerprint Details
The "white" spots in the middle of
the black ridges are sweat pores
They’re admissible points of identification in court, as are the little black flesh ‘‘islands’’ in the grooves between the ridges
Trang 97Advanced Image/Video Processing: Image Compression Slide: 97
What compression scheme should be
used?
Better use a lossless method to preserve
every pixel perfectly.
Unfortunately, in practice lossless methods haven’t done better than 2:1 on fingerprints!
Does JPEG work well for fingerprint
compression?
Trang 98Results using JPEG compression
file size 45853 bytes compression ratio: 12.9
The fine details are pretty much history, and the whole image has this artificial ‘‘blocky’’ pattern superimposed on it
The blocking artifacts affect the
Trang 99Advanced Image/Video Processing: Image Compression Slide: 99
Results using WSQ compression
file size 45621 bytes compression ratio: 12.9
The fine details are preserved better
than they are with JPEG
NO blocking artifacts!
Trang 100WSQ Algorithm
Trang 101Advanced Image/Video Processing: Image Compression Slide: 101
Varying compression ratio
FBI’s target bit rate is around 0.75 bits per
pixel (bpp)
ratio of 10.7 (assuming 8-bit images)
This target bit rate is set via a ‘‘knob’’ on
the WSQ algorithm.
many JPEG implementations.
Trang 102Varying compression ratio (cont’d)
In practice, the WSQ algorithm yields a higher compression ratio than the target because of
unpredictable amounts of lossless entropy
coding gain.
i.e., mostly due to variable amounts of blank space in the images.
Trang 103Advanced Image/Video Processing: Image Compression Slide: 103
Varying compression ratio (cont’d)
Original image 768 x 768 pixels (589824 bytes)