MODULE I Image Transforms 2
MODULE I Image Transforms 2
Date: 19/2/2024
Outline
06 Discrete Cosine Transform
07 Haar Transform
08 Slant Transform
06
Discrete Cosine Transform
Image VS Frequency Transform(Amplitude and phase)
Image VS Frequency Transform(Amplitude and phase)
Low intensity
high frequency
4MB
438KB
Discrete Cosine Transform
❑ Like Fourier transform, DCT transforms a signal into its
frequency components.
❑ Unlike Fourier transform this uses only real component i.e.
cosine basis function.
❑ The signal is transformed into a sum of cosine functions with
different frequencies.
❑ Unlike Fourier transform this is applied for discrete signals.
❑ Unlike Fourier transform it tends to concentrate the energy
signal in a smaller number of coefficients.
Discrete Cosine Transform
❑ f(x,y) is the intensity of the pixels at position x and y in row p
and column q of the image.
❑ F(u,v) is the resultant DCT coefficient in row up and column vq
of DCT matrix.
❑ For standard cases, the image is divided into 8x8 segments.
Each block contain gray scale level/combination of RBG.
❑ It needs less computation and storage.
❑ Mostly used in image and video compression applications.
❑ It is lossy compression.
Discrete Cosine Transform
❑ The DCT coefficients are ordered from low frequency to high
frequency.
❑ For most images, much of the signal energy lies at low
frequencies. These appear in the upper left corner of the
DCT.
❑ Compression is achieved since the lower right values
represent higher frequencies, and are often small. Small
enough to be neglected with little visible distortion.
❑ Quantize low value DCT coefficients from the matrix for
compression.
DCT Transform
For a MxN segment:
1 1 𝜋 2𝑥+1 𝑢 𝜋 2𝑦+1 𝑣
F(u,v)= 𝑀−1 𝑁−1
w(u)w(v)σ𝑥=0 σ𝑦=0 𝑓 𝑥, 𝑦 cos[ ]cos[ ],
𝑀 𝑁 2𝑀 2𝑁
1
, if 𝑢, 𝑣 = 0
w(u)=w(v)= √2
1, otherwise
DCT Transform
Inverse of MxN segment:
1 1 𝜋 2𝑥+1 𝑢 𝜋 2𝑦+1 𝑣
𝑥=0 σ𝑦=0 𝐹 𝑢, 𝑣 w(u)w(v) cos[
σ𝑀−1 ]cos[ ],
𝑁−1
F(u,v)=
𝑀 𝑁 2𝑀 2𝑁
1
, if 𝑢, 𝑣 = 0
w(u)=w(v)= √2
1, otherwise
DCT of an Image with 8x8 segment
DCT Transform
Image Grid: 64/8=8 rows 64/8=8 columns
0,0
0,0 0,1 0,2 0,3 0,4 0,5 0,6 0,7
1,0 1,1 1,2 1,3 1,4 1,5 1,6 1,7
2,0 2,2
3,0
7,7
4,0
Image 64x64 pixels 5,0 Block:2,2
6,0
Each block is divided
7,0 7,7 into 8x8 segment
Grid representation of the image: 8x8 segment
Each block is of 8x8 size and will use a T8x8 DCT matrix
to compute corresponding DCT coefficient matrix of that
block (which gives 8x8 DCT coefficients of that block).
DCT Transform
DCT Transform:
F(u,v)=T*f(x,y)*T-1
If T is orthogonal matrix, then A-1=AT,
Otherwise compute invesre using the formula
1
,𝑢 = 0, 0≤v≤𝐾 − 1
√𝐾
T= 2 𝜋 2𝑣+1 𝑢
cos , 1≤u≤𝐾 − 1, 0≤v≤𝐾 − 1
𝐾 2𝐾
DCT Transformation Matrix
❑ Sample T for a 8x8 image segment
DCT Transformation Matrix
❑ Sample T for a 4x4 image segment
DCT Output Matrix: DCT Coefficients
07
Haar Transform
Haar Transform
❑ Widely used for its simplicity and fast computation.
❑ Haar Transform
❑ Here H is orthogonal,
❑
Haar Transform
❑ Haar Transform Matrix of order 2N is defined as:
,where
𝐻2 ⊗ [1,1]
H2x2=
𝐼2 ⊗ [1, −1]
Haar Transform
❑ That gives H4 as :
1
❑ H8=
√8
Haar Transform
Alternatively,
Forward Haar Transform:
❑ Initially, in Pass 1 computation all the arithmetical operations
Forward Pass 1:
❑ The adjacent values across the columns are added and
divided by 2.
❑ Correspondingly followed by the difference of those values
divided by 2.
❑ This is repeated until all values in the columns, against each
❑ The adjacent values across the rows are added and divided
by 2.
❑ Followed correspondingly by the difference of those values
divided by 2.
❑ The number of steps in this pass is equal to half the number
of columns.
Haar Transform
𝑐11 𝑐12 𝑐13 𝑐14
Pass1:
𝑐21 𝑐22 𝑐23 𝑐24
𝑐31 𝑐32 𝑐33 𝑐34
𝑐41 𝑐42 𝑐43 𝑐44
columns.
❑ The resulting matrix turn into the original input.
Inverse Pass 1:
❑ The alternate values across the rows are added and
100 50 60 150
20 60 40 30
50 90 70 82
74 66 90 58
Haar Transform
❑ F-Pass 1, Step 1:
75 105 25 -45
20 60 40 30
50 90 70 82
74 66 90 58
Haar Transform
❑ F-Pass 1, Step 2:
75 105 25 -45
40 35 -20 5
50 90 70 82
74 66 90 58
Haar Transform
❑ F-Pass 1, Step 3:
75 105 25 -45
40 35 -20 5
70 76 -20 -6
74 66 90 58
Haar Transform
❑ F-Pass 1, Step 4:
75 105 25 -45
40 35 -20 5
70 76 -20 -6
70 74 4 16
Haar Transform
❑ F-Pass 2, Step 1:
70 35 -20 5
17.5 76 -20 -6
0 74 4 16
Haar Transform
❑ F-Pass 2, Step 2:
57.5 70 25 -45
70 75 -20 5
17.5 35 -20 -6
0 1 4 16
Haar Transform
❑ F-Pass 2, Step 2:
75 70 25 -45
40 75 -20 5
70 35 -20 -6
70 1 4 16
Haar Transform
❑ I-Pass 1, Step 2 :
75 105 25 -45
40 35 -20 5
70 76 -20 -6
70 74 4 16
Haar Transform
❑ I-Pass 2, Step 1 :
100 50 60 150
40 35 -20 5
70 76 -20 -6
70 74 4 16
Haar Transform
❑ I-Pass 2, Step 2 :
100 50 60 150
20 60 40 30
70 76 -20 -6
70 74 4 16
Haar Transform
❑ I-Pass 2, Step 3 :
100 50 60 150
20 60 40 30
50 90 70 82
70 74 4 16
Haar Transform
❑ I-Pass 2, Step 4 :
100 50 60 150
20 60 40 30
50 90 70 82
74 66 90 58
08
Slant Transform
Slant Transform
❑ Uses discrete sawtooth like wavelets as basis functions.
1 0 1 0
1 0
𝑎2𝑁 𝑏2𝑁 −𝑎2𝑁 𝑏2𝑁
1 0 𝐼𝑁−2 0 𝐼𝑁−2 𝑆𝑁 0
S2N=
2 1 0 0 −1 0 𝑆𝑁
0 0
−𝑏2𝑁 𝑎2𝑁 𝑏2𝑁 𝑎2𝑁
0 𝐼𝑁−2 0 𝐼𝑁−2
3𝑁2 𝑁2 −1
a2N= and b2N=
4𝑁2 −1 4𝑁2 −1
Slant Transform
❑ S4 transformation matrix is defined as:
1 0 1 0
𝑎 𝑏4 −𝑎4 𝑏4 𝑆2 0
S4= 4 where n=2N, N=2.
0 1 0 −1 0 𝑆2
−𝑏4 𝑎4 𝑏4 𝑎4
1
Here a4=2/ 5, b4=
5
1 1 1 1
3/ 5 1/√5 −1/√5 −3/ 5
S4=
1 −1 −1 1
1/√5 −3/ 5 3/ 5 −1/√5
Slant Transform
❑ S is not symmetric or unitary.
❑ Let X be our input image and S be the Slant transformation
matrix, then
▪ Forward transform coefficients are computed as :