0% found this document useful (0 votes)
12 views53 pages

MODULE I Image Transforms 2

The document discusses various image transforms including discrete cosine transform and Haar transform. The discrete cosine transform transforms an image into frequency components using cosine basis functions and concentrates energy in fewer coefficients. The Haar transform uses simple step functions as basis and allows for fast computation, with applications in compression and processing.

Uploaded by

jacksonb200743cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views53 pages

MODULE I Image Transforms 2

The document discusses various image transforms including discrete cosine transform and Haar transform. The discrete cosine transform transforms an image into frequency components using cosine basis functions and concentrates energy in fewer coefficients. The Haar transform uses simple step functions as basis and allows for fast computation, with applications in compression and processing.

Uploaded by

jacksonb200743cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Image Transforms

CS4043D Image Processing

Anu Maria Sebastian


CSE, NIT Calicut

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

High intensity low


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𝑁

0≤u ≤M-1, 0≤v ≤N-1

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𝑁

0≤u ≤M-1, 0≤v ≤N-1

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

Inverse DCT Transform:


F(x,y)=T-1*F(u,v)*T
Input Pixel Matrix
DCT Transformation Matrix
❑ For different values of K in KxK segments, different
transformation matrix need to be computed.
❑ Lets compute T for KxK segment, K ∈2r :

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.

❑ The basis function consists values of 1, -1, 0 (multiplied by


powers of 2 for normalization).

❑ It involves computing two sets of coefficients:


▪ Coarse approximation (high intensity)
▪ Fine detail(low intensity)
Haar Transform
❑ The input will length will be 2n,for insufficient length we can
pad the input with enough zeros to meet this.

❑ Haar transform is reversible.

❑ Haar transform vary both in scale(width) and position,


whereas FT differs only in frequency.

❑ Applications in compression, pattern recognition, denoising


etc.
Haar Transform
❑ Given,

❑ Haar Transform

❑ Normalized basic Haar transform matrix H for 2x2 is defined as:

❑ Here H is orthogonal,


Haar Transform
❑ Haar Transform Matrix of order 2N is defined as:

,where

H2N is of order (2n), n=log22N is a non-negative number.

So H4 is computed as Kronecker product :

𝐻2 ⊗ [1,1]
H2x2=
𝐼2 ⊗ [1, −1]
Haar Transform
❑ That gives H4 as :

❑ By normalizing the values it becomes:


Haar Transform
❑ For H2N ,the common scaling factor for the unitary
1
normalization of the matrix is , [Unitary(1/ √2𝑁 ),
√2𝑁
Orthogonal (1/2N) ].

❑ Correspondingly IN is scaled by a factor of √2𝑁

1
❑ H8=
√8
Haar Transform
Alternatively,
Forward Haar Transform:
❑ Initially, in Pass 1 computation all the arithmetical operations

are carried out across columns.


❑ In Pass 2 all arithmetic operations are done across the rows.

❑ The resulting matrix is a Haar Transform.

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

row are covered.


Haar Transform
𝑝 𝑞 𝑟 𝑠
Input: , 22, 4x4 input
𝑡 𝑢 𝑣 𝑤
𝑔 ℎ 𝑖 𝑗
𝑘 𝑙 𝑚 𝑛

Pass1: (Steps equal to the number of rows)


Step1: c11=(p+q)/2 c13=(p-q)/2
c12=(r+s)/2 c14=(r-s)/2
Haar Transform
Forward Pass 2:
❑ On completion of Pass 1(whole column wise transform).

❑ 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

Forward Pass2: (Number of steps equal to half the number of


columns)
Step1: r11=(c11+c21)/2 r31=(c11-c21)/2
r21=(c31+c41)/2 r41=(c31-c41)/2
Haar Transform
Inverse Haar Transform:
❑ Initially pass 1 computations are carried out across rows.

❑ In Pass 2 all arithmetic operations are done across the

columns.
❑ The resulting matrix turn into the original input.

Inverse Pass 1:
❑ The alternate values across the rows are added and

subtracted for corresponding values.


❑ This is repeated across all rows for number of steps equal to

half the number of columns.


Haar Transform
𝑟11 𝑟12 𝑐13 𝑐14
Inverse Pass1:
𝑟21 𝑟22 𝑐23 𝑐24
𝑟31 𝑟32 𝑐33 𝑐34
𝑟41 𝑟42 𝑐43 𝑐44

Inverse Pass1: (Number of steps equal to half the number of


columns)
Step1: r”11=(r11+r31) r”31=(r21+r41)
r”21=(r11-r31) r”41=(r21-r41)
Haar Transform
Inverse Pass 2:
❑ On completion of Inverse Pass 1.

❑ The alternate values across the columns are added and

subtracted for corresponding values.


❑ This is repeated across all columns for number of steps equal

to the number of rows.


Haar Transform
r”11 r”12 𝑐13 𝑐14
Inverse Pass2:
r”21 r”22 𝑐23 𝑐24
r”31 r”32 𝑐33 𝑐34
r”41 r”42 𝑐43 𝑐44

Inverse Pass2: (Steps equal to the number of rows)


Step1: c”11=(r”11+c13) c”13=(r”12+c14)
c”12 =(r”11-c13) c”14 =(r”12-c14)
Haar Transform
❑ Input matrix :

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:

57.5 105 25 -45

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.

❑ The wavelets have fixed time duration and its frequency


might vary with the duration.
Slant Transform
❑ Linear brightness variations can be effectively represented.
❑ Better directional sensitivity to capture diagonal edges and
structures in images.
❑ It is reversible (extent of retrieval is subjected to
quantization, and precision of coefficients).
❑ Applications in image coding, horizontal and vertical feature
extraction.
❑ The transformation matrix is defined based on filter bank
approach.
❑ The matrix representation involves the low-pass and high-
pass filters.
Slant Transform
❑ The basic Slant transform matrix of order 2 is defined as:
S2=

❑ The 2N order transformation matrix is defined as:

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 :

▪ Inverse Slant transform is computed as:


Slant Transform
❑ Let X be our input image and S be the Slant transformation
matrix, then
▪ Forward transform coefficients are computed as :

▪ Inverse Slant transform is computed as:

You might also like