Title: Local Transform
1Local Transform
- Apart from the square template, other template
shapes may also be used.
Vertical 1x3 template
Horizontal 3x1 template
Cross template
2Global Transform
- Block based transformations
- Discrete Cosine Transform
- Wavelet Transform
- Linear Geometric Transform
3Global Transform
- Ideally, a transform should be applied to an
image to fully exploit the spatial correlation
among pixels - Block based transform coding
- Divides an image into non-overlapping blocks
- Apply the transform over each block
- ? Reduce computational complexity
4Global Transforms
image
5Global Transforms
...
Divide into non-overlapping image blocks
image
6Global Transforms
...
Transform each block into coefficients
image
7Global Transform
- Block based transform coding
- ? Reduce computational complexity
- ? Discontinuity at the edge of blocks
Lena 100x100 block based Transform
8Global Transform
Input samples
Output samples
Forward transform
Inverse transform
Transform coefficients
Transform coefficients
Quantizer
Dequantizer
Quantized coefficients
Quantized coefficients
Coded bit stream
Binary encoder
Binary decoder
Block diagram for the encoding and decoding of a
block-transform coding system
9Global Transform
- An image block can be represented as a linear
combination of a set of basic patterns (transform
basis functions). - The amount of contribution from each basic
pattern is controlled by the transform
coefficient corresponding to that transform basis
function.
10Global Transform
T1,1
T1,2
T2,1
T2,2
Transform basis basic block patterns to make up
the image
11Global Transform
- A good transform design should
- Decorrelate the signal to be quantized
- Compact the energy into as few coefficients as
possible - E.g. Fourier Transform, DCT, wavelet
12Fourier Transform
- Transform an image into spatial frequency
coefficients - Fourier functions exist in image processing
software like MathCAD, MathLab, etc. - 2D FT can be separated into a 1D FT followed by
another 1D FT on the transformed coefficients.
13Discrete Cosine Transform
- Adjacent pixels in an image are usually
correlated, independent representation of each
pixel value is inefficient - Energy compact
14Discrete Cosine Transform
- Program codes
- View source code in Excel
- Depth of loop
- X Y Index step by blocksize
- u v
- X1 Y1 index from 0 to N-1
- Refer to cells in worksheet
- Cosine function
15Discrete Cosine Transform
For Y 1 To maxY Step blocksizeY For X 1 To
maxX Step blocksizeX For v 0 To blocksizeY -
1 For u 0 To blocksizeX - 1 If u 0 And v 0
Then For Y1 0 To blocksizeY - 1 For X1 0
To blocksizeX - 1 DCTRed DCTRed
Worksheets("Red").Cells(Y Y1, X X1).Value
same for green blue Next X1 Next Y1
DCTRed DCTRed / (blocksizeX blocksizeY) Else
...
16Discrete Cosine Transform
For Y1 0 To blocksizeY - 1 For X1 0 To
blocksizeX - 1 DCTRed DCTRed
Worksheets("Red").Cells(Y Y1, X X1).Value
Cos((2 X1 1) u Pi / 2 / blocksizeX)
Cos((2 Y1 1) v Pi / 2 / blocksizeY)
Next X1 Next Y1 DCTRed sqrt2 DCTRed /
(blocksizeX blocksizeY) End If Worksheets("DCTRe
d").Cells(Y v, X u).Value DCTRed Next
u Next v Next X Next Y
17Wavelet Transform
- Wavelet analysis was proposed as an alternative
method of representing a function (a signal or an
image) using frequency and spatially localized
basis function functions that are finite over a
restricted range of frequencies and locations. - An infinite number of functions can be defined
that have this property. The function F is
usually called the Mother Wavelet and it is given
as - the index l defines the wavelets location and s
its scale.
18Mother Wavelet Transform
- The data domain is spanned at varying resolutions
by using the mother wavelet in a scaling equation - Four other conditions must be satisfied before
the coefficient ck can be qualified as wavelet
coefficients - Even number coefficients must sum to one.
- Odd number coefficients must sum to one.
- The sum of the products of adjacent odd or even
coefficients must be zero. - The sum of the products of a coefficient and its
complex conjugate must be two.
19Haar Wavelet Transform
- Haar Wavelet Transform is given as
20Haar Wavelet Transform
- f(x) and ?(x) are defined as non-zero in the
range 0,1 and zero elsewhere.
?(x)
1
x
1
-1
21Geometric Transform
- Geometric transformations
- An arbitrary geometric transformation moves a
pixel at (x, y) to (x, y). - Thus,
22Geometric Transform
- For linear transformations, the two coordinates
are related using linear polynomial
23Geometric Transform
Translation of an image pixel by (x0, y0)
is Thus, we have a0 b11, a1b00, a2x0 and
b2y0.
y
yy0
p
x
p
xx0
Original image
New image
24Geometric Transform
To scale an image by s, we have Thus, we have
a0 b1 s, a1 b0 a2 b20.
25Geometric Transform
To rotate an image by ?, we let the pixels
position at a distance of L and angle a from the
origin. We have
a
y
y
L
?
?
x
x
p
p
p
Original image
New image
26Geometric Transform
The new position (x, y) of the pixel is
thus Expand both sin(a?) and cos(a?) and
substitute x and y into the equations, we
get Thus, we have a0 b1 cos?, a1-sin?, b0
sin?, a2 b20.
27Geometric Transform
Using appropriate values for the six parameters,
the various linear transformations of
translation, rotation, scaling, and shearing can
be realised.
28Geometric Transforms
- These linear transformations can be done one
after another. - We may compute a compound matrix by multiplying
the individual matrices, and simply transform the
image once. - Non-integral coordinates may be found from the
calculations. The pixels of the new image are
found as mapping from interpolation between
pixels in the original image.
29Geometric Transforms
- Example
- Find the new coordinate of the pixel at (14, 20)
if we translate it by (2, 4), rotate the image by
p/6, and scale the image by 1.5. - The translation moves (14, 20) to (142, 204)
(16,24). - The rotation moves the pixel to
(16cos(p/6)-24sin(p/6),16sin(p/6)24cos(p/6))
(1.856, 28.78) - The scaling moves the pixel to (1.51.856,
1.528.78) (2.784, 43.17)
30Geometric Transforms
- Exercise
- Find the new coordinate of the pixel at (30, 20)
if we translate it by (-5, 5), rotate the image
by -p/6, and vertically shear the image by 0.8. - A line with two end points at (30, 20) and (20,
30) is translated by (40, 60) and scaled by 1.2.
Find the new position of the two end points of
the line.
31Geometric Transforms
- Exercise solution
- Find the new coordinate of the pixel at (30, 20)
if we translate it by (-5, 5), rotate the image
by -p/6, and vertically shear the image by 0.8. - The translation moves (30, 20) to (30-5,205)
(25, 25). - The rotation moves the pixel to
(25cos(-p/6)-25sin(-p/6), 25sin(-p/6)25cos(-p/6))
(21.6512.5, -12.521.65) (34.15, 9.15) - The scaling moves the pixel to (34.150.8,
9.150.8) (27.32, 7.32).
32Geometric Transforms
- Exercise solution
- A line with two end points at (30, 20) and (20,
30) is translated by (40, 60) and scaled by 1.2.
Find the new position of the two end points of
the line. - The translation moves the end points of the line
to (70, 80) and (60, 90). - The scaling moves the end points to (84, 96) and
(72, 108).