Image Transformations
Image Transformations
𝑥′ 𝑎 𝑏 𝑥 𝛼
= +
𝑦′ 𝑐 𝑑 𝑦 𝛽
𝑥′ 1 0 𝑥 𝛼
= +
𝑦′ 0 1 𝑦 𝛽
′
𝑥 =𝑥+𝛼
′
𝑦 =𝑦+𝛽
16 SCALING
➢ The translation operation is performed
using the equation below:
𝑥′ 𝑠𝑥 0 𝑥 0
= 0 𝑠𝑦 𝑦 +
𝑦′ 0
′
𝑥 = 𝑠𝑥 . 𝑥
′
𝑦 = 𝑠𝑦 . 𝑦
17 ROTATION
(2,3) (3,3)
(2,2) (3,2)
19 INTERPOLATION AND RESAMPLING
➢ Basic requirement of a interpolation function
𝑥 𝑡 = 𝑃𝑖 𝐵𝑖,𝑘 (𝑡)
𝑖=0
Where, 𝑃𝑖 -Control Points
And 𝐵𝑖,𝑘 (𝑡)- normalized B-spline function of order 𝑘
21 INTERPOLATION
Now, 𝐵𝑖,𝑘 (𝑡) is defined as:
1 𝑡𝑖 ≤ 𝑡 < 1
𝐵𝑖,1 𝑡 =
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
𝑡2
0≤𝑡<1
2
−𝑡 2 + 3𝑡 − 1.5 1 ≤ 𝑡 < 2
𝐵0,3 𝑡 =
(3 − 𝑡)2
2≤𝑡<3
2
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Interpolation done using above function is known as
quadratic interpolation
24 INTERPOLATION
➢ The B-Spline function of order 4 is represented as:
𝑡3
0≤𝑡<1
6 Interpolation done
−3𝑡 3 + 12𝑡 2 − 12𝑡 + 4 using above function
1≤𝑡<2
6 is known as cubic
𝐵0,4 𝑡 = 3𝑡 3 − 24𝑡 2 + 60𝑡 − 44 interpolation
2≤𝑡<3
6
(4 − 𝑡)3
3≤𝑡<4
6
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
25 INTERPOLATION
𝐵𝑖,1 𝑡 constant interpolation 𝐵𝑖,2 𝑡 linear interpolation
Transform
Transformed
Image
Image
NXN
NXN
Inverse
Transform
33 IMAGE TRANSFORM
➢ What does the image transformation do?
It represents a given image as a series summation of a set of
unitary matrices
➢ What is unitary matrix?
A matrix ‘𝐴’ is a unitary matrix if
𝑇
𝐴−1 = 𝐴∗
Where, 𝐴∗ is conjugate of 𝐴
Unitary matrices basis images
34 IMAGE TRANSFORM
➢ In case of one dimensional continuous signal, the signal can be
represented as series summation of a set of orthogonal basis functions.
➢ What does orthogonal function mean here?
Consider a set of real valued continuous function
𝑎𝑛 𝑡 = 𝑎0 𝑡 , 𝑎1 𝑡 , 𝑎2 𝑡 , …
This set of real valued function is said to be orthogonal over period t,
when
𝑘 𝑖𝑓 𝑚 = 𝑛
𝑚𝑎 𝑡 . 𝑎𝑛 𝑡 =
0 𝑖𝑓 𝑚 ≠ 𝑛
If k=1, it is called orthonormal.
35 IMAGE TRANSFORM
If we have a series of discrete samples The inverse is given as:
𝑇
𝑢 𝑛 :0 ≤ 𝑛 ≤ 𝑁 −1 𝑢 = 𝑣. 𝐴−1 = 𝑣. 𝐴∗
The transformation can be given as:
𝑁−1
𝑣 = 𝑢. 𝐴
𝑢 𝑛 = 𝑣 𝑘 . 𝑎∗ 𝑘, 𝑛
Where, 𝑣 is transformed vector and 𝐴 is 𝑘=0
transformation matrix
𝑁−1 𝑛 = 0,1,2, … , 𝑁 − 1
𝑣 𝑘 = 𝑢 𝑛 . 𝑎 𝑘, 𝑛
𝑛=0
𝑘 = 0,1,2, … , 𝑁 − 1
36 IMAGE TRANSFORM
𝑁−1 𝑁−1
𝑁−1 𝑁−1 𝑢 𝑚, 𝑛 = 𝑣 𝑘, 𝑙 . 𝑎∗ 𝑘,𝑙 𝑚, 𝑛
𝑣 𝑘, 𝑙 = 𝑢 𝑚, 𝑛 . 𝑎𝑘,𝑙 𝑚, 𝑛 𝑘=0 𝑙=0
𝑚=0 𝑛=0
Where, 0 ≤ 𝑚, 𝑛 ≤ 𝑁 − 1
Where, 0 ≤ 𝑘, 𝑙 ≤ 𝑁 − 1
37 IMAGE TRANSFORM
Condition for orthogonal matrices is:
𝑁−1 𝑁−1
And
𝑁−1 𝑁−1
𝑣 𝑘, 𝑙 = 𝑎 𝑘, 𝑚 . 𝑢 𝑚, 𝑛 . 𝑎 𝑙, 𝑛
Then the matrix is known as a separable matrix.
𝑚=0 𝑛=0
So, This can also be represented as: v = 𝐴 𝑈 𝐴𝑇
𝑎𝑘 𝑚 : 𝑘 = 0,1, … , 𝑁 − 1
𝑏𝑙 𝑛 : 𝑙 = 0,1, … , 𝑁 − 1
The inverse separable transformation is given as:
Are 1-D complete orthonormal basis vectors 𝑁−1 𝑁−1
𝑢 𝑚, 𝑛 = 𝑎∗ 𝑘, 𝑚 . 𝑣 𝑘, 𝑙 . 𝑎∗ 𝑙, 𝑛
So, if we assume 𝐴 ≈ {𝑎 𝑘, 𝑚 } and B ≈ {𝑏 𝑙, 𝑛 }
𝑘=0 𝑙=0
Then A and B are both unitary matrices. This can also be represented as: 𝑈 = 𝐴∗ 𝑇 𝑉𝐴∗
39 BASIS IMAGES
➢ How to compute the basis images: ➢ Problem: for the given orthogonal matrix a
and image u find the transformed image
using separable transform and obtain all the
𝑎∗ 𝑘 → 𝑘 𝑡ℎ 𝑐𝑜𝑙𝑢𝑚𝑛 𝑜𝑓 𝐴∗ 𝑇 possible basis functions.
𝑎∗ 𝑙 → 𝑙𝑡ℎ 𝑟𝑜𝑤 𝑜𝑓 𝐴∗ 𝑇
1 1 1 1 2
𝐴= ,𝑈 =
So the basis image is: 2 1 −1 3 4
𝐴∗ 𝑘,𝑙 = 𝑎∗ 𝑘 . 𝑎∗ 𝑙
Find the inverse transform also
40 IMAGE TRANSFORM
➢A general transform of a two dimensional square ➢Here if transformation kernel can be
represented as:
digital image 𝑓(𝑥, 𝑦) of size 𝑁 × 𝑁 can be represented
as: 𝑔 𝑥, 𝑦, 𝑢, 𝑣 = 𝑔1 𝑥, 𝑢 . 𝑔2 (𝑦, 𝑣)
𝑁−1 𝑁−1
➢ Feature Extraction:
• Edge Detection
• Corner Detection etc.
42 2-D FOURIER TRANSFORM
➢Fourier transform of a two dimensional signal ➢The Fourier spectrum can be given as:
1
𝑓(𝑥, 𝑦) can be represented as: 2 2
𝐹(𝑢, 𝑣) = 𝑅𝑒 𝑢, 𝑣 + 𝐼𝑚 𝑢, 𝑣 2
∞
➢The Phase can be given as:
𝐹 𝑢, 𝑣 = ඵ 𝑓(𝑥, 𝑦)𝑒 −𝑗2𝜋(𝑢𝑥+𝑣𝑦) 𝑑𝑥𝑑𝑦 𝐼𝑚 (𝑢, 𝑣)
𝜑 𝑢, 𝑣 = 𝑡𝑎𝑛−1
−∞ 𝑅𝑒 (𝑢, 𝑣)
➢Inverse fourier transform can be represented
➢The Power Spectrum can be computed
as: by:
∞ 𝑃 𝑢, 𝑣 = 𝐹(𝑢, 𝑣) 2
𝐴
sin(𝜋𝑢𝑋) sin(𝜋𝑣𝑌)
𝐹(𝑢, 𝑣) = 𝐴𝑋𝑌
𝜋𝑢𝑋 𝜋𝑣𝑌
𝑌 𝑦
𝑋
𝑥
44 2-D DISCRETE FOURIER TRANSFORM
➢ Fourier transform of a two dimensional digital ➢Inverse Fourier Transform can be
image 𝑓(𝑥, 𝑦) of size 𝑀 × 𝑁 can be represented represented as
as: 𝑀−1 𝑁−1
𝑢𝑥 𝑣𝑦
𝑗2𝜋( 𝑀 + 𝑁 )
𝑓 𝑥, 𝑦 = 𝐹 𝑢, 𝑣 𝑒
𝑢=0 𝑣=0
𝑀−1 𝑁−1
1 𝑢𝑥 𝑣𝑦
−𝑗2𝜋( 𝑀 + 𝑁 )
𝐹 𝑢, 𝑣 = 𝑓(𝑥, 𝑦)𝑒 Here, x= 0,1, … , 𝑀 − 1
𝑀𝑁
𝑥=0 𝑦=0 And y = 0,1, … , 𝑁 − 1
HERE, 𝑢 = 0,1, … , 𝑀 − 1
AND V = 0,1, … , 𝑁 − 1
45 2-D DFT RESULT
Original Image Magnitude spectrum Phase spectrum
➢Rotation:
𝐹 𝑓1 𝑥, 𝑦 + 𝑓2 𝑥, 𝑦 = 𝐹 𝑓1 𝑥, 𝑦 + 𝐹 𝑓2 𝑥, 𝑦
To explain rotation property we consider the polar But
coordinate system i.e. 𝐹 𝑓1 𝑥, 𝑦 . 𝑓2 𝑥, 𝑦 ≠ 𝐹 𝑓1 𝑥, 𝑦 . 𝐹 𝑓2 𝑥, 𝑦
So, the distributivity property says that both DFT and IDFT
𝑥 = 𝑟𝑐𝑜𝑠𝜃 𝑎𝑛𝑑 𝑦 = 𝑟𝑠𝑖𝑛𝜃
are distributive over addition operation but not distributive
𝑢 = ω𝑐𝑜𝑠∅ 𝑎𝑛𝑑 𝑣 = ω𝑠𝑖𝑛∅
over multiplication operation.
So, 𝑓 𝑥, 𝑦 → 𝑓 𝑟, 𝜃 𝑎𝑛𝑑 𝐹(𝑢, 𝑣) → 𝐹(𝜔, ∅) ➢Scaling:
If the Fourier transform is given as If there are scalar quantities 𝑎, 𝑏
➢A discrete cosine transform of a two dimensional square digital image 𝑓(𝑥, 𝑦) of size 𝑁 × 𝑁 can
be represented as:
𝑁−1 𝑁−1
2𝑥 + 1 𝑢𝜋 2𝑦 + 1 𝑣𝜋
𝐶 𝑢, 𝑣 = 𝛼 𝑢 . 𝛼 𝑣 𝑓 𝑥, 𝑦 . 𝑐𝑜𝑠 . 𝑐𝑜𝑠
2𝑁 2𝑁
𝑥=0 𝑦=0
Here, 𝑢, 𝑣 = 0,1, … , 𝑁 − 1
➢And inverse DCT can be given as:
𝑁−1 𝑁−1
2𝑥 + 1 𝑢𝜋 2𝑦 + 1 𝑣𝜋
𝑓 𝑥, 𝑦 = 𝛼 𝑢 . 𝛼 𝑣 𝐶 𝑢, 𝑣 . 𝑐𝑜𝑠 . 𝑐𝑜𝑠
2𝑁 2𝑁
𝑢=0 𝑣=0
Here, x, y = 0,1, … , 𝑁 − 1
52 OUTPUT OF DCT
Original Image Transformed Image