Digital 3
Digital 3
2
Why do we need compression?
• Saving The Storage Space.
• Maximum Transmission Bandwidth Utility.
• Color image, 352x288 pixels “Full” color
depth: 24 bits per pixel (8 bits red, green,
blue) – 304128 bytes
• Reduced color depth: 12 bits per pixel
– 152064 bytes
3
Human Visual System (HVS)
• The human eye is not very sensitive to high
frequency changes especially in
photographic images, so the high frequency
data can, to some extent, be discarded.
• many of the pixels of a typical photographic
image contain little or no “useful” detail
(e.g. “flat” areas)
4
Fundamental Components of Compression
• Redundancy Reduction
– Removing duplication from the signal
source (Image)
• Irrelevancy reduction
– Omits parts of the signal that will not
be noticed by the signal receiver
5
Types of Redundancy
• Spatial redundancy
– correlation between adjacent pixels.
• Spectral redundancy
– Correlation between spectral bands.
• Temporal redundancy
– Correlation between adjacent frames
(video applications).
6
Some Factors Affecting Achievable Compression
7
Image and video coding Standards
• Why a standard ?
Like a language, a standard serves to facilitate
communication between men, man-machine and
machines
8
Standardization
• Two major international organizations have
been responsible for providing standards on
audio-visual coding
– International Organization for Standardization
(ISO)
– International Telecommunication Union (ITU)
9
Different Classes Of Compression
Techniques
– Compression Ratio
10
11
12
JPEG 2000 family of standards
• JPEG (1992)
– Lossy and lossless, DCT-based
• JPEG-LS (1997)
– Lossless and near-lossless, prediction-based
• JPEG 2000 Part1 (2002)
– Lossy and lossless, wavelet-based
• JPEG 2000Part2 (2002)
– Provision for 3D extensions
13
JPEG 2000Part1
• JPEG 2000Part2(extensions)
– supports arbitrary wavelet filters
– supports multi-component
transformations
• Multi-component support:
– Linear block transform(DCT, KLT,...)
– 3D wavelet transform
– predictive coding
15
What is ITU-T?
• Telecommunication standardization
• sector of ITU (Formerly CCITT)
• Study group 15 is responsible for video
• conference and video telephony
• Over 20 companies and research centers
• around the world actively participate
• Meets 3-5 times every year
• Proposes « Recommendations »
16
ITU-T Recommendations
• H.120 (1984)
– Video-conferencing over H1 channels
(1.5- 2Mb/s)
• H.261 (1988)
– Video-conferencing over ISDN lines
(p*64 Kb/s; p1…30)
• H.263 (1996)
– Video-telephony over POTS and Internet
(8-64 Kb/s)
17
18
19
Signal-to-Noise Ratio
20
INFORMATION THEORY
• ENTROPY
Entropy is a very important concept in
information theory and communications.
So is it in image and video compression.
We first define the information content
of a source symbol. Then we define
entropy as average information content
per symbol for a discrete memoriless
source.
21
Information Measure
• Consider a symbol with an occurrence probability
p. Its information content (i.e., the amount of
information contained in the symbol), I, is
defined as follows.
23
Coding Redundancy
• What is the meaning of VLC?
24
Huffman coding
• In summary, the Huffman coding algorithm consists of the
following steps.
1. Arrange all source symbols in such a way that their occurrence
probabilities are in a non increasing order.
2. Combine the two least probable source symbols:
• Form a new source symbol with a probability equal to the sum
of the probabilities of the two least probable symbols.
• Assign a binary 0 and a binary 1 to the two least probable
symbols.
3. Repeat until the newly created auxiliary source alphabet contains
only one source symbol.
4. Start from the source symbol in the last auxiliary source alphabet
and trace back to each source symbol in the original source
alphabet to find the corresponding codeword.
25
Example 5.9
Consider a source alphabet whose six source
symbols and their occurrence probabilities are
listed in Table 5.9. Figure 5.1 demonstrates the
Huffman coding procedure applied. In the
example, among the two least probable source
symbols encountered at each step we assign
binary 0 to the top symbol and binary 1 to the
bottom symbol.
26
27
Differential Coding
• SIMPLE PIXEL -TO-PIXEL DPCM
28
29
Block diagram of a practical pixel-to-pixel
differential coding system.
30
31
Image Coding based on
Linear Transform
Linear Transformation
• A linear transform is a mapping that converts
time domain (or spatial domain) digital signal
into frequency domain coefficients
• Signals represented in the frequency domain
have different properties that can be exploited
to facilitate efficient digital signal processing
• Transforms are useful for a wide range of
purposes, including convolution, enhancement,
feature detection, and compression
33
Transform Coding
34
35
DISCRETE FOURIER TRANSFORM (DFT)
• The forward and inverse transformation kernels of
the DFT are:
36
• for N = 4.
37
DISCRETE COSINE TRANSFORM (DCT)
38
DCT: discrete cosine transform
• DCT :discovered in 1974 by the research
community working on image compression.
• DCT :used in image compression in 1984.
• DCT :Technique for converting a signal into
elementary frequency components.
• DCT :Fourier related-transform similar to DFT
,but using real numbers only.
• DCT :Transform technique used for lossy
compression.
39
One-dimensional DCT
k = 0,1,................................N − 1
40
Inverse DCT (N-point IDCT)
N −1
⎡ ( 2 n + 1) k π ⎤
x ( n ) = ∑ c k X ( k ) cos ⎢ ⎥
k =0 ⎣ 2 N ⎦
n = 0 ,1,......... .......... ........ N − 1
⎧ 1
⎪ k =0
where c k = ⎨ 2
⎪⎩ 1 k ≠ 0
41
Vector-Matrix form for DCT
⎡ 0 ⎤ ⎡ ⎤⎡ 0 ⎤
⎢ 1 ⎥ ⎢ ⎥⎢ 1 ⎥
⎢ ⎥ ⎢ ⎥⎢ ⎥
⎢ 2 ⎥ 2⎢ ⎡ (2n + 1)kπ ⎤ ⎥ ⎢ 2 ⎥
⎢ ⎥ = ⎢c k cos ⎢ ⎥ ⎥ ⎢ ⎥
⎢ . ⎥ N⎢ ⎣ 2N ⎦⎥⎢ . ⎥
⎢ . ⎥ ⎢ ⎥⎢ . ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢⎣ N − 1⎥⎦ ⎣ ⎦ ⎢⎣ N − 1⎥⎦
X(k): Transform DCT Matrix x(n): Data
Vector (k x n) Vector
42
IDCT Matrix
⎡ 0 ⎤ ⎡ ⎤⎡ 0 ⎤
⎢ 1 ⎥ ⎢ ⎥⎢ 1 ⎥
⎢ ⎥ ⎢ ⎥⎢ ⎥
⎢ 2 ⎥ ⎢ ⎡ ( 2 n + 1) k π ⎤⎥⎢ 2 ⎥
⎢ ⎥ = ⎢ c k cos ⎢ ⎥⎥⎢ . ⎥
⎢ . ⎥ ⎢ ⎣ 2N ⎦ ⎢ ⎥
⎥
⎢ . ⎥ ⎢ ⎥⎢ . ⎥
⎢ ⎥ ⎢ ⎥⎦ ⎢⎢ N − 1⎥⎥
⎢⎣ N − 1⎥⎦ ⎣ ⎣ ⎦
IDCT Matrix
X(n) (n x k) X(k)
43
The Basis functions (vectors) of the
normalized 1D-DCT
k = 0
c(k , n) = 1 for
N 0 ≤ n ≤ N −1
2 ⎡ (2n + 1)kπ ⎤ 0 ≤ n ≤ n −1
c(k , n) = cos⎢ ⎥ for
N ⎣ 2 N ⎦ 1 ≤ k ≤ N −1
44
Multidimensional DCT (2D-DCT)
45
Two dimensional-DCT
2D-DCT(normalized)
2 N −1 M −1
⎡ (2n +1)uπ ⎤ ⎡ (2m +1)vπ ⎤
X (u, v) = cucv ∑∑ x(n, m) cos⎢ ⎥ cos⎢ ⎥
NM n=0 m=0 ⎣ 2N ⎦ ⎣ 2M ⎦
u = 0,1,2,.................N −1 ⎧1
⎪ l =0
cl = ⎨ 2
v = 0,1,2,.................M −1 ⎪⎩ 1 l ≠ 0
46
2D-IDCT(normalized)
2 N −1 M −1
⎡ (2n + 1)uπ ⎤ ⎡ (2m + 1)vπ ⎤
x(n, m) = cu cv ∑∑ X (u, v) cos⎢ ⎥ cos⎢ ⎥
NM n =0 m =0 ⎣ 2N ⎦ ⎣ 2M ⎦
n = 0,1,2,................N − 1 ⎧ 1
⎪ l =0
cl = ⎨ 2
m = 0,1,2,...............M − 1 ⎪⎩ 1 l ≠ 0
47
U1
Vertical edges
DC
Horizontal edges
48
Slide 48
U1 User, 2/29/2008
Basis Images for 2D-DCT
49
DCT-properties:
• Real arithmetic.
• Decomposing.
• Energy compaction.
• Orthogonality.
• Separability.
50
Decomposing Property for DCT
51
Energy Compaction
52
Orthogonality Property
−1
=
T
T T
Where T :the DCT (transform)
matrix
53
Orthogonality Property
⎡ DCT ⎤
X (k ) = ⎢ ⎥ x(n)
⎣matrix⎦
Transform vector data vector
54
Orthogonality Property
⎡ IDCT ⎤
x(n) = ⎢ ⎥ X (k )
⎣matrix⎦
where T
⎡ IDCT ⎤ ⎡ DCT ⎤
=
⎢ matrix ⎥
⎣ ⎦ ⎢ matrix ⎥
⎣ ⎦
55
Separability Property of DCT
• Using separability property 2D-DCT can
implemented by a series of 1D-DCT
56
DCT-Based Image Compression
JPEG Encoder
JPEG Decoder
57
58
DCT (8x8) image block
59
Quantization
• A quantizer simply reduces the number of
bits needed to store the transformed
coefficients by reducing the precision of
those values.
• Quantization is a lossy process and is the
main source of compression in an
encoder.
• Quantization may be uniform or non-
uniform.
60
DCT Quantized matrix
σ
2
1 i, j
b =r+ log 2 1 / 64
⎢⎣ ∏ σ
i, j 2 ⎡ 2 ⎤
i, j i , j⎥
⎦
⎛ S(u, v) ⎞
Sq (u, v) = Nearst integer ⎜⎜ ⎟⎟
⎝ Q(u, v) ⎠
R (u , v ) = S q (u , v )Q (u , v )
63
Zigzag scan
• The zigzag scan used to prepare the quantized DCT
coefficients for Entropy coding
64
Entropy Encoder
1
H ( s ) = ∑ pi log 2
i pi
65
Huffman Coding (VLC)
67
Blocking Artifacts
• Since the input image needs to be
“Blocked” correlation across the block
boundaries is not eliminated .This results
in noticeable “blocking artifacts”
particularly at low bit rates.
68
Example
69
70
71
72
Reconstructed Matrix
73
Reconstructed image with DC component
only, To show blocking artifacts
74
Compression Ratio (CR) & Image
quality
• CR =the ratio of the size of image before and
after compression.
=the ratio of bit-rates (bpp) before and after
compression.
• For lossy compression (CR) may be from10:1
up to 50:1 without significantly affecting the
image quality.
• At higher compression ratios image quality
degrades due to blocking artifacts.
75
Simulation Result (for CR=11.2460)
DCT-based
Original image image compression
CR = 11.2460
RMS = 4.1316
76
Simulation Result (for CR =53.4333)
Original image DCT-based
image compression
CR = 53.4333
RMS = 10.9662
77
DCT advantages
78
DCT-disadvantages
• Blocking Artifacts.
79
DCT Other applications:
• Speech coding.
• Image coding (BW compression)
• Image Enhancement ,Filtering.
• Video compression standards (MPEG).
80