lecture12

advertisement
ENEE631 Spring’09
Lecture 12 (3/9/2009)
Subband and Wavelet Coding
Spring ’09 Instructor: Min Wu
Electrical and Computer Engineering Department,
University of Maryland, College Park
 bb.eng.umd.edu (select ENEE631 S’09)
 minwu@eng.umd.edu
M. Wu: ENEE631 Digital Image Processing (Spring'09)
UMCP ENEE631 Slides (created by M.Wu © 2004)
Overview and Logistics

Last Time:
– Basis images for 2-D separable unitary transform
– Basics on transform coding
– JPEG compression standard: Baseline block-DCT based algorithm



lossy part: quantization with different step size for each coeff. band
lossless part: run-length coding, Huffman coding, differential coding
Today
– Wrap up JPEG compression
– Subband and Wavelet based compression


Subband decomposition
Exploit the structures between coefficients for removing redundancy
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [2]
UMCP ENEE631 Slides (created by M.Wu © 2001)
Review and Exercise on Basis Images
Exercise:
– A is unitary transform or not?
– Find basis images
1
A
2


H
*
A Y A 


1
2
1
2
1 1 
1  1


1 
2 
1 

2 
_
_

1 2
X 

3
4


_
_ 





1
2
1
2
1 
2 
1 

2 
– Represent an image X with basis images
1
2
H
*
X  A Y A  5 
1

2
1
1
2   (1)   2
1
1


2
2
1
 1
 
2  (2)   2
 1
1

 
2
 2
1 
 1
2   0  2
 1
1

 
2
 2
1
 
2
1 

2 
(Jain’s e.g.5.1, pp137: A’ [5, –1; – 2, 0] A; outer product of columns of AH : [1,1]’[1 1]/2, …)
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [4]
UMCP ENEE408G Slides (created by M.Wu & R.Liu © 2002)
Review: Baseline JPEG Algorithm

“Baseline”: simple, lossy compression


Subset of various DCT-based modes of JPEG standard
A few basics: 8x8 block-DCT based coding
– Shift to zero-mean by subtracting 128  [-128, 127]

Allows using signed integer to represent both DC and AC coefficients
– Color representation: YCbCr / YUV


Color components can have lower
spatial resolution than luminance
Interleaving color components:
4 Y blocks, 1 U block, 1 V block
0.587
0.114   R 
Y   0.299
C    0.147  0.289 0.436  G 
 b 
 
Cr   0.615  0.515  0.100  B 
(Based on Wang’s video book Chapt.1)
=> Flash demo on Baseline JPEG algorithm
by Dr. Ken Lam (HK PolyTech Univ.)
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [5]
From B. Liu PU EE488 F’06
Recap: JPEG Still Image Coding
Lossy, block based, transform coding
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [7]
UMCP ENEE408G Slides (created by M.Wu & R.Liu © 2002)
Lossy Part in JPEG

Important tradeoff between bit rate and visual quality

Quantization (adaptive bit allocation)
–
–
–
–

Different quantization step size for different coefficient bands
Use same quantization matrix for all blocks in one image
Choose quantization matrix to best suit a specific image
Different quantization matrices for luminance and color components
Default quantization table
– “Generic” over a variety of images

Quality factor “Q”  [1, 100]
–
–
–
–
Scale the quantization table
Medium quality Q = 50 ~ no scaling
High quality Q = 100 ~ quantization step is 1
Low quality ~ small Q, larger quantization step

visible artifacts like ringing and blockiness
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [9]
Quantization Table Recommended in JPEG
– Take account of human visual properties and statistics from representative
natural images
8x8 Quantization Table for
Luminance
16
12
14
14
18
24
49
72
11
12
13
17
22
35
64
92
10
14
16
22
37
55
78
95
16 24 40
19 26 58
24 40 57
29 51 87
56 68 109
64 81 104
87 103 121
98 112 100
51 61
60 55
69 56
80 62
103 77
113 92
120 101
103 99
8x8 Quantization Table for
Chrominance
17
18
24
47
99
99
99
99
18
21
26
66
99
99
99
99
24
26
56
99
99
99
99
99
47
66
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
– “Optimal” quantization tables vary, depending on image content, desired bit
rate, and distortion criterion => need to send decoder the tables used
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [10]
Achieving Different Coding Bit Rate vs Distortion

Adjust quantization by multiplying scale factor to
base quantization tables
(below is a commonly used scaling)
– A convenient way to achieve different encoding bit rate vs distortion
Medium quality Q = 50 ~ no scaling
 High quality Q = 100 ~ quantization step is 1 (i.e. just round coeff. to integer)
 Low quality ~ larger quantization step
 5000

1

Q

50


 Determine MSE introduced
scale factor  Q

 200  2 * Q
50  Q  99
(%)
– Energy preservation by unitary transf.
 1
Q  100 


=> MSE in DCT coefficients equal MSE



in image signal samples
– Artifacts contributed by DCT basis images of strongly quantized freq. bands

“Optimal” quantization tables
– Depend on image content, desired bit rate, and distortion criterion
– Need to inform decoder what the quantization tables were used

Encode the customized table, or quality factor if standard table is used
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [11]
UMCP ENEE408G Slides (created by M.Wu & R.Liu © 2002)
Lossless Coding Part in JPEG

Differentially encode DC
– (lossy part: DC differences are then quantized.)

AC coefficients in one block
– Zig-zag scan after quantization for better run-length

save bits in coding consecutive zeros
– Represent each AC run-length using entropy coding

use shorter codes for more likely AC run-length symbols
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [12]
UMCP ENEE408G Slides (created by M.Wu & R.Liu © 2002)
Lossless Coding Part in Baseline JPEG: Details

Differentially encode DC
– ( SIZE, AMPLITUDE ), with amplitude range in [-2048, 2047]

AC coefficients in one block
– Zig-zag scan for better run-length
– Represent each AC with a pair of symbols

Symbol-1: ( RUNLENGTH, SIZE )  Huffman coded

Symbol-2: AMPLITUDE  Variable length coded
RUNLENGTH  [0,15]
# of consecutive zero-valued AC coefficients
preceding the nonzero AC coefficient  [0,15]
SIZE  [0 to 10 in unit of bits]
# of bits used to encode AMPLITUDE
AMPLITUDE  in range of [-1023, 1024]
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [13]
Encoding Non-zero AC Coefficients
UMCP ENEE631 Slides (created by M.Wu © 2004)

DCT AC coefficients of natural images follow Laplacianlike distribution
– use shorter codewords for coeff. with small magnitude, and vice versa
Table is from slides at
Gonzalez/ Woods DIP 2/e
book website (Chapter 8);
Baseline JPEG use a smaller
part of the coefficient range.
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [14]
UMCP ENEE631 Slides (created by M.Wu © 2004)
Subband/Wavelet Coding
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [16]
UMCP ENEE631 Slides (created by M.Wu © 2001/2004)
Wavelet Transform for Image Compression

ENEE631 emphasis
– Focus on conceptual aspects related to image compression
– Multiresolution analysis through wavelet transforms also useful for
image modeling, denoising, enhancement, and content analysis
– Build upon filterbank and subband coding from ENEE630’s
multirate signal processing
(For more in-depth info. on wavelet: wavelet course offered in Math Dept.)

K-level 1-D wavelet/subband decomposition
– Successive lowpass/highpass filtering and downsampling


on different level: capture transitions of different frequency bands
on the same level: capture transitions at different locations
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [17]
Review: Subband Coding Concept
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [18]
UMCP ENEE631 Slides (created by M.Wu © 2001/2004)
Successive Wavelet/Subband Decomposition
Successive lowpass/highpass filtering and downsampling


on different level: capture transitions of different frequency bands
on the same level: capture transitions at different locations
Figure from Matlab Wavelet Toolbox Documentation
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [19]
UMCP ENEE631 Slides (created by M.Wu © 2001)
Examples of 1-D Wavelet Transform
From Matlab
Wavelet Toolbox
Documentation
Figures are from slides at
Gonzalez/ Woods DIP book 2/e website (Chapter 7)
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [20]
UMCP ENEE631 Slides (created by M.Wu © 2004)
Review: Filterbank & Multiresolution Analysis
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [21]
UMCP ENEE631 Slides (created by M.Wu © 2004)
2-D Example
Separable transform
by successively
applying 1-D DWT
to rows and columns
From Usevitch’s article in
IEEE Sig.Proc. Mag. 9/01
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [24]
Subband Coding Techniques
UMCP ENEE631 Slides (created by M.Wu © 2001)

General coding approach
– Allocate different bits for coefficients in different frequency bands
– Encode different bands separately
– Example: DCT-based JPEG and early wavelet coding


Some difference between subband coding and early
wavelet coding ~ Choices of filters
– Subband filters aims at (approx.) non-overlapping frequent response
– Wavelet filters has interpretations in terms of basis and typically designed
for certain smoothness constraints
=> will discuss more

Shortcomings of subband coding
– Difficult to determine optimal bit allocation for low bit rate applications
– Not easy to accommodate different bit rates with a single coded stream
– Difficult to encode at an exact target rate
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [25]
Recall: Filterbank Perspective of Block Processing
From Assignment#1
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [26]
Embedded Zero-Tree Wavelet Coding (EZW)
UMCP ENEE631 Slides (created by M.Wu © 2001)

“Modern” lossy wavelet coding exploits multi-resolution
and self-similar nature of wavelet decomposition
– Energy is compacted into a small number of coefficients
– Significant coeff. tend to cluster at the same spatial location in
each frequency subband


time-freq. or space–freq.
analysis
Two set of info. to code:
– Where are the significant
coefficients?
– What values are the significant
coefficients?
From Usevitch (IEEE
Sig.Proc. Mag. 9/01)
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [28]
Key Concepts in EZW
UMCP ENEE631 Slides (created by M.Wu © 2001)

Parent-children relation among coeff.
– Each parent coeff at level k spatially correlates
with 4 coeff at level (k-1) of same orientation
– A coeff at lowest band correlates with 3 coeff.

Coding significance map via zero-tree
– Encode only high energy coefficients

Need to send location info.  large overhead
– Encode “insignificance map” w/ zero-trees

Successive approximation
quantization
– Send most-significant-bits first and
gradually refine coefficient value
– “Embedded” nature of coded bit-stream

get higher fidelity image by adding extra
refining bits
M. Wu: ENEE631 Digital Image Processing (Spring'09)
From Usevitch (IEEE
Sig.Proc. Mag. 9/01)
Lec12 – Subband/Wavelet Coding [29]
EZW Algorithm and Example
UMCP ENEE631 Slides (created by M.Wu © 2001)



Initial threshold ~ 2 ^ floor(log2 xmax)
– Put all coeff. in dominant list
Dominant Pass (“zig-zag” across bands)
– Assign symbol to each coeff. and
entropy encode symbols




– Significant coefficients


Move to subordinate list
Set them to zero in dominant list
Subordinate Pass
– Output one bit for subordinate list


ps – positive significance
ns – negative significance
iz – isolated zero
ztr – zero-tree root
According to position in up/low half of quantization interval
From Usevitch (IEEE
Sig.Proc. Mag. 9/01)
Repeat with half threshold
– Until bit budget achieved
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [30]
Pass
From Usevitch (IEEE Sig.Proc. Mag. 9/01)
Divide quantization interval of [32,64) by half:
[32,48) => 40 and [48, 64) => 56
UMCP ENEE631 Slides (created by M.Wu © 2001)
After
1st
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [31]
UMCP ENEE631 Slides (created by M.Wu © 2001)
After 2nd Pass
From Usevitch (IEEE Sig.Proc. Mag. 9/01)
[16,24) => 20, [24, 32) => 28;
[32,40) => 36, [40,48) => 44;
[48, 56) => 52, [56, 64) => 60
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [32]
UMCP ENEE631 Slides (created by M.Wu © 2001/2004)
EZW and Beyond

Can apply DWT to entire images or larger blocks than 8x8

Symbol sequence can be entropy encoded
– e.g. arithmetic coding

Cons of EZW
– Poor error resilience; Difficult for selective spatial decoding

SPIHT (Set Partitioning in Hierarchal Trees)
– Further improvement over EZW to remove redundancy

EBCOT (Embedded Block Coding with Optimal Truncation)
– Used in JPEG 2000
– Address the shortcomings of EZW (random access, error resilience, …)
– Embedded wavelet coding in each block + bit-allocations among blocks
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [33]
UMCP ENEE631 Slides (created by M.Wu © 2004)
A Close Look at Wavelet Transform
Exercise: Show Haar Transform is
unitary and orthogonal
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [34]
UMCP ENEE631 Slides (created by M.Wu © 2001/2004)
Construction of Haar Functions

Unique decomposition of integer k  (p, q)
– k = 0, …, N-1 with N =
0 <= p <= n-1
– q = 0, 1 (for p=0); 1 <= q <= 2p (for p>0)
2 n,
e.g., k=0
(0,0)

k=1
(0,1)
k=2
(1,1)
k=3
(1,2)
hk(x) = h p,q(x) for x  [0,1]
1
h0 ( x)  h0, 0 ( x) 
for x  [0,1]
N
q- 12
q-1
 1 p/2
for p  x  p
 N 2
2
2

q- 12
q
 1 p/2
2
for p  x  p
hk ( x)  h p ,q ( x)  
2
2
N



for other x  [0,1]
0
M. Wu: ENEE631 Digital Image Processing (Spring'09)
k=4 …
(2,1) …
power of 2
k = 2p + q – 1
“remainder”
x
1
Lec12 – Subband/Wavelet Coding [35]
UMCP ENEE631 Slides (created by M.Wu © 2001)
Haar Transform

Haar transform H
– Sample hk(x) at {m/N}

m = 0, …, N-1
– Real and orthogonal
– Transition at each scale p is
localized according to q






1 
8





1
1
1
1
1
1
1
1
 2
 2
0
2 2
0
0
0
0
0
0
2
2
0
0
0
0
0
0
0
0
2
0
2
1 
1 1 1
 1 
0
0
0
0 

2
2  2  2
0 0 0 0


0 0 0 0

2 2 0 0


0 0 2 2

1
1
1
Basis images of 2-D
(separable) Haar transform
– Outer product of two basis vectors
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [36]
Summary of Today’s Lecture
UMCP ENEE631 Slides (created by M.Wu © 2004)

Compression via subband/wavelet coding
– Subband decomposition
– EZW: exploit structures between coefficients for removing redundancy

Next Lecture:
– More on wavelet transforms

Readings
– Gonzalez’s 3/e book Section 8.2.8; 8.2.10, 7.1, 7.4-7.5
Wallace’s paper on JPEG compression standard
Usevitch’s SPM Sept.2001 tutorial paper on wavelet compression
To explore further:
Gonzalez’ 3/e book 7.2-7.3 (wavelet)
IEEE Sig. Proc. Magazine Special Issue on transform coding (Sept.2001);
Bovik’s Handbook 5.4 (wavelet compression) & 5.5 (JPEG lossy)
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [37]
UMCP ENEE631 Slides (created by M.Wu © 2004)
A Close Look at Wavelet Transform
Haar Transform – unitary
Orthonormal Wavelet Filters
Biorthogonal Wavelet Filters
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [39]
Compare Basis Images of DCT and Haar
UMCP ENEE631 Slides (created by M.Wu © 2001)
M. Wu: ENEE631 Digital Image Processing (Spring'09)
See also: Jain’s Fig.5.2 pp136
Lec12 – Subband/Wavelet Coding [40]
Summary on Haar Transform
UMCP ENEE631 Slides (created by M.Wu © 2001)

Two major sub-operations
– Scaling captures info. at different frequencies
– Translation captures info. at different locations

Can be represented by filtering and downsampling

Relatively poor energy compaction
– Equiv. filter response doesn’t have good cutoff & stopband attenuation
x
1
M. Wu: ENEE631 Digital Image Processing (Spring'09)
Lec12 – Subband/Wavelet Coding [41]
Download