Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

CS 411 : Data Compression

Lecture 9
Block Transform Coding
Image transform
• Two main types:
-Orthogonal transform:
e.g. Walsh-Hadamard transform, DCT

-Subband transform:
e.g. Wavelet transform

12/9/2022 2
Disadvantages of DCT

• DCT based JPEG uses blocks of image, there is still correlation across blocks.
• Block boundaries are noticeable in some cases
• Can overlap the blocks Computationally expensive
• Only spatial correlation of the pixels inside the single 2-D block is
considered and the correlation from the pixels of the neighboring blocks is
neglected
• Impossible to completely decorrelate the blocks at their boundaries using
DCT
• Does not perform efficiently for binary images (fax or pictures of
fingerprints) characterized by large periods of constant amplitude (low
spatial frequencies), followed by brief periods of sharp transitions

Why Wavelets?
• No need to block the image
• More robust under transmission errors
• Facilitates progressive transmission of the image (Scalability)
Was JPEG not good enough?
• JPEG is based on DCT.
• Equal subbands.
• At low bit rates, there is a sharp
degradation with image quality.
• 43:1 compression ratio
Advantages of Discrete Wavelet Transform over DCT

• No need to divide the input coding into non-overlapping 2-D blocks, it has higher
compression ratios avoid blocking artifacts.
• Allows good localization both in time and spatial frequency domain.
• Transformation of the whole image introduces inherent scaling
• Better identification of which data is relevant to human perception higher
compression ratio
Discrete Wavelet Transform

• Performance
• Peak Signal to Noise ratio used to be a measure of image quality
• The PSNR between two images having 8 bits per pixel or sample in terms of decibels (dBs)
is given by:  255 2 
 
• PSNR = 10 log10
MSE  
• mean square error (MSE)
• Generally when PSNR is 40 dB or greater, then the original and the reconstructed images
are virtually indistinguishable by human observers
Wavelet Transform

• Uses a variable length window, e.g.:


– Narrower windows are more appropriate at high frequencies
– Wider windows are more appropriate at low frequencies
What is a wavelet?
• A function that “waves” above and below the x-axis with
the following properties:
– Varying frequency
– Limited duration
– Zero average value
• This is in contrast to sinusoids, used by FT, which have
infinite duration and constant frequency.
Sinusoid Wavelet
Types of Wavelets

• There are many different wavelets, for example:

Haar Morlet Daubechies


Basis Functions Using Wavelets
• Like sin( ) and cos( ) functions in the Fourier Transform,
wavelets can define a set of basis functions ψk(t):

f (t )   ak k (t )
k

• Span of ψk(t): vector space S containing all functions f(t)


that can be represented by ψk(t).
Basis Construction – “Mother” Wavelet
The basis can be constructed by applying translations and
scalings (stretch/compress) on the “mother” wavelet ψ(t):

Example:
scale

ψ(t)

translate
Basis Construction - Mother Wavelet

(dyadic/octave grid)

  jk (t )

scale =1/2j
(1/frequency) j

k
Continuous Wavelet Transform (CWT)

translation parameter scale parameter scale =1/2j


(measure of time) (measure of frequency) (1/frequency)

1  t  
Forward C ( , s)   f  t  

 dt
CWT: s t  s 

mother wavelet (i.e.,


normalization window function)
constant
Continuous Wavelet Transform (cont’d)

1  t  
Forward CWT: C ( , s)   f  t  

 dt
s t  s 

1 t 
Inverse CWT: f (t ) 
s  s C ( , s) ( s )d ds

Note the double integral!


Discrete Wavelet Transform (DWT)

a jk   f (t ) *jk (t ) (forward DWT)


t

f (t )   a jk jk (t ) (inverse DWT)


k j

where  jk (t )  2 j / 2  2 j t  k 
Convention for illustrating
1D Haar wavelet decomposition
x x x x x x … x x
average
(LP)
… detail
(HP)
re-arrange: …


… LP HP
re-arrange: …
Haar Wavelet Transform
 Find the average of each pair of samples
 Find the difference between the average and sample
 Fill the first half with averages
 Fill the second half with differences
 Repeat the process on the first half
 Step 1:
[3 5 4 8 13 7 5 3]
Averaging
Differencing

[4 6 10 4 -1 -2 3 1]

18
Haar Wavelet Transform
 Step 2
[4 6 10 4 -1 -2 3 1]

Averaging Differencing

[5 7 -1 3 -1 -2 3 1]

ex. (4 + 6)/2 = 5
4 - 5 = -1
19
Haar Wavelet Transform
 Step 3
[5 7 -1 3 -1 -2 3 1]

Averaging Differencing

[6 -1 -1 3 -1 -2 3 1]
row average

ex. (5 + 7)/2 = 6
5 - 6 = -1

20
Example - Haar Wavelets

• Suppose we are given a 1D "image" with a resolution of 4 pixels:


[9 7 3 5]

• The Haar wavelet transform is the following:

(with sub-sampling)

L0 D1 D2 D3
Example - Haar Wavelets (cont’d)
• Start by averaging and subsampling the pixels
together (pairwise) to get a new lower resolution
image:
[9 7 3 5]

• To recover the original four pixels from the two


averaged pixels, store some detail coefficients.

1
Example - Haar Wavelets (cont’d)
• Repeating this process on the averages (i.e., low
resolution image) gives the full decomposition:

Harr decomposition:
Example - Haar Wavelets (cont’d)
• The original image can be reconstructed by adding or
subtracting the detail coefficients from the lower-
resolution representations.

L0 D1 D2 D3
2 1 -1
[6]
Summary: wavelet expansion (Section 7.2)

• Wavelet decompositions involve a pair of waveforms:

encodes low encodes details or


resolution info φ(t) ψ(t) high resolution info

f (t )   ck (t  k )   d jk (2 j t  k )
k k j

Terminology: scaling function wavelet function


1D Haar Wavelets

• Haar scaling and wavelet functions:

φ(t) ψ(t)

computes average computes details


(low pass) (high pass)
Example (revisited)

[9 7 3 5]
low-pass, high-pass,
down-sampling down-sampling

(9+7)/2 (3+5)/2 (9-7)/2 (3-5)/2


LP HP
Example (revisited)

[9 7 3 5]

low-pass, high-pass,
down-sampling down-sampling

LP HP

(8+4)/2 (8-4)/2
2D Haar Wavelet Transform

• The 2D Haar wavelet decomposition can be computed


using 1D Haar wavelet decompositions.
– i.e., 2D Haar wavelet basis is separable

• We’ll discuss two different decompositions (i.e.,


correspond to different basis functions):
– Standard decomposition
– Non-standard decomposition
Standard Haar wavelet decomposition

• Steps:

(1) Compute 1D Haar wavelet decomposition of


each row of the original pixel values.

(2) Compute 1D Haar wavelet decomposition of


each column of the row-transformed pixels.
Standard Haar wavelet decomposition
(cont’d)
average
detail
(1) row-wise Haar decomposition:
re-arrange terms
xxx … x … …
xxx … x …
… … . … … .
… … .
xxx ... x …
Standard Haar wavelet decomposition (cont’d)
average
(1) row-wise Haar decomposition: detail

row-transformed result

… …


… … . … … .

Standard Haar wavelet decomposition (cont’d)
average
detail
(2) column-wise Haar decomposition:

row-transformed result column-transformed result


… …
… …

… … . … … .
… …
Example

row-transformed result

re-arrange terms …

… … .

… … .
Example (cont’d)

column-transformed result

… … .

Low part High part

137-134=-3/2=1
135-141=-6/2=-3
138-134=4/2 =2
131-29=2/2 =1
129+131=260/2=130
133+132=-265/2=132
134+131=265/2=132
133+131=264/2=132
LL HL
135+138=273/2=136 1+ -3=-2/2=-1
136+130=266/2=133 2+1=3/2= 1
130+132=262/2=131 -1+0=-1/2= 0
136 131  1 0
132+132=264/2=132 133 LL132 1 HL 1 1+1=2/2= 1
 
  1  1 2 0 HH
HL  LH HH 
135-138=-3/2= -1  3 0 0 0 1- -3=4/2= 2
136-130=6/2= 3 2-1=1/2= 0
130-132=-2/2= -1 -1-0=-1/2= 0
132-132=0/2= 0 1-1=0/2= 0
Image representation
64 2 3 61 60 6 7 57
9 55 54 12 13 51 50 16 

17 47 49 20 21 43 42 24
 
A  40 26 27 37 36 30 31 33
 32 34 35 29 28 38 39 25
 
 41 23 22 44 45 19 18 48
49 15 14 52 53 11 10 56
 
 8 58 59 5 4 62 63 1 
[33 32 33 32 31 -29 27 -25]
[32.5 32.5 0.5 0.5 31 -29 27 -25]
[32.5 0 0.5 0.5 31 -29 27 -25]

38
Applying on rows
 32.5 0 0.5 0.5 31  29 27  25
 32.5 0  0.5  0.5  23 21  19 17 

 32.5 0  0.5  0.5  15 13  11 9 
 
 32.5 0 0.5 0.5 7 5 3 1 
 32.5 0 0.5 0.5 1 3 5 7 
 
 32.5 0  0.5  0.5 9  11 13  15 
 32.5 0  0.5  0.5 17  19 21  23
 
 32.5 0 0.5 0.5  25 27  29 31 
detail coefficients
row average
39
Applying on columns
 Choose a threshold δ
 32.5 0 0 0 0 0 0 0 
 0 0 0 0 0 0 0 0 

 0 0 0 0 4 4 4 4 
 
 0 0 0 0 4 4 4 4 
 0 0 0.5 0.5 27  25 23  21
 
 0 0  .5  .5  11 9 7 5 
 0 0 0.5 0.5  5 7  9 11 
 
 0 0  .5  .5 21  23 25  27 δ=5
40
Features of JPEG2000
• Multiple Resolution: Decomposes the image into a multiple resolution
representation.
• Progressive transmission: By pixel and resolution accuracy, referred to
as progressive decoding and signal-to-noise ratio (SNR) scalability:
This way, after a smaller part of the whole file has been received, the
viewer can see a lower quality version of the final picture.
• Lossless and lossy compression
• Random code-stream access and processing: JPEG 2000 supports
spatial random access or region of interest access at varying degrees
of granularity. This way it is possible to store different parts of the
same picture using different quality.
• Error resilience: JPEG 2000 is robust to bit errors introduced by noisy
communication channels, due to the coding of data in relatively small
independent blocks.
JPEG2000 Basics

General block diagram of the JPEG 2000 (a) encoder and (b) decoder
Compression algorithms using DWT

• Embedded zero-tree (EZW)


• Use DWT for the decomposition of an image at each
level
• Scans wavelet coefficients subband by subband in a
zigzag manner
• Set partitioning in hierarchical trees (SPHIT)
• Highly refined version of EZW
• Perform better at higher compression ratio for a wide
variety of images than EZW
Compression algorithms using DWT
• Zero-tree entropy (ZTE)
• Quantized wavelet coefficients into wavelet trees to reduce
the number of bits required to represent those trees
• Quantization is explicit instead of implicit, make it possible to
adjust the quantization according to where the transform
coefficient lies and what it represents in the frame
• Coefficient scanning, tree growing, and coding are done in
one pass
• Coefficient scanning is a depth first traversal of each tree

You might also like