Digital Image Processing
Download
Report
Transcript Digital Image Processing
Digital Image Processing
Unitary Transforms
7/18/2015
Duong Anh Duc - Digital Image Processing
1
Unitary Transforms
Sort samples f(x,y) in an MxN image (or a rectangular
block in the image) into colunm vector of length MN
Compute transform coefficients
c Af
where A is a matrix of size MNxMN
1
The transform A is unitary, iff A
A
A
*T
H
Hermitian conjugate
If A is real-valued, i.e., A-1=A*, transform is
„orthonormal“
7/18/2015
Duong Anh Duc - Digital Image Processing
2
Energy conservation with unitary
transforms
For any unitary transform c Af we obtain
2
2 H H H
c c c f A Af f
Interpretation: every unitary transform is simply
a rotation of the coordinate system.
Vector lengths („energies“) are conserved.
7/18/2015
Duong Anh Duc - Digital Image Processing
3
Energy distribution for unitary
transforms
Energy is conserved, but often will be unevenly
distributed among coefficients.
Autocorrelation matrix
H H
H
H
Rcc E c c E Af f A AR ff A
Mean squared values („average energies“) of
the coefficients ci are on the diagonal of Rcc
E c Rcc i ,i AR ff A
2
i
7/18/2015
H
i ,i
Duong Anh Duc - Digital Image Processing
4
Eigenmatrix of the autocorrelation
matrix
Definition: eigenmatrix F of autocorrelation matrix Rff
F is unitary
The columns of F form an orthonormalized set of eigenvectors
of Rff, i.e.,
Rff F FL
0
0
1
is a diagonal matrix of eigenvalues.
L
0
MN 1
Rff is symmetric nonnegative definite, hence i 0 for all i
Rff is normal matrix, i.e., R Hff R ff R ff R Hff , hence unitary
eigenmatrix exists
7/18/2015
Duong Anh Duc - Digital Image Processing
5
Karhunen-Loeve transform
Unitary transform with matrix
A = FH
where the columns of F are ordered according to
decreasing eigenvalues.
Transform coefficients are pairwise uncorrelated
Rcc = ARffAH = FHRffF = FHFL = L
Energy concentration property:
No other unitary transform packs as much energy into the
first J coefficients, where J is arbitrary
Mean squared approximation error by choosing only first J
coefficients is minimized.
7/18/2015
Duong Anh Duc - Digital Image Processing
6
Optimum energy concentration by KL
transform
To show optimum energy concentration property, consider the truncated
coefficient vector
b IJc
where IJ contain ones on the first J diagonal positions, else zeros.
Energy in first J coefficients for arbitrary transform A
J 1
E Tr Rbb Tr I J Rcc I J Tr I J AR ff A I J akT R ff ak*
H
k 0
where akT is the k - th row of A.
Lagrangian cost function to enforce unit-length basis vectors
J 1
J 1
J 1
L E k 1 a a a R ff a k 1 akT ak*
k 0
T
k
*
k
k 0
T
k
*
k
k 0
Differentiating L with respect to aj yields neccessary condition
R ff a*j j a*j for all j J
7/18/2015
Duong Anh Duc - Digital Image Processing
7
Basis images and eigenimages
For any unitary transform,
the inverse transform
f A c
H
can be interpreted in terms of the superposition of
„basis images“ (columns of AH) of size MN.
If the transform is a KL transform, the basis images,
which are the eigenvectors of the autocorrelation
matrix Rff , are called „eigenimages.“
If energy concentration works well, only a limited
number of eigenimages is needed to approximate a
set of images with small error. These eigenimages
form an optimal linear subspace of dimensionality J.
7/18/2015
Duong Anh Duc - Digital Image Processing
8
Computing eigenimages from a
training set
How to measure MNxMN
autocorrelation matrix?
Use training set 1 , 2 ,, L
Define training set matrix S 1 , 2 ,, L
and calculate
1 L
1
R
L
l 1
H
l l
L
SS H
Problem 1: Training set size should be L >> MN
If L < MN, autocorrelation matrix Rff is rank - deficient
Problem 2: Finding eigenvectors of an MNxMN matrix.
Can we find a small set of the most important eigenimages
from a small training set L << MN
7/18/2015
Duong Anh Duc - Digital Image Processing
9
Sirovich and Kirby method
Instead of eigenvectors of SSH, consider the
eigenvectors of SHS, i.e.,
H
S Svi i vi
Premultiply both sides by S: SS H Svi i Svi
By inspection, we find that Svi are eigenvectors of SSH
For this gives rise to great computational savings, by
Computing the LxL matrix SHS
Computing L eigenvectors Svi of SHS
Computing eigenimages corresponding to the L0 L largest
eigenvalues according as Svi
7/18/2015
Duong Anh Duc - Digital Image Processing
10
Example: eigenfaces
The first 8 eigenfaces obtained from a training set of
500 frontal views of human faces.
Can be used for face recognition by nearest neighbor
search in 8-d „face space.“
Can be used to generate faces by adjusting 8
coefficients.
7/18/2015
Duong Anh Duc - Digital Image Processing
11
Gender recognition using eigenfaces
Task: Male or female?
Eigenimages from a data base of 20 and 20
female training images
7/18/2015
Duong Anh Duc - Digital Image Processing
12
Gender recognition using eigenfaces
(cont.)
Recognition accuracy using 8 eigenimages
7/18/2015
Duong Anh Duc - Digital Image Processing
13
Block-wise image processing
Subdivide image into
small blocks
Process each block
independently from the
others
Typical blocksizes: 8x8,
16x16
7/18/2015
Duong Anh Duc - Digital Image Processing
14
Separable blockwise transforms
Image block written as a square matrix f
(NxN coefficients)
T
c = A .f.A
This can only be done, if transform is
separable in x and y, i.e.,
(N xN )
AT = AA
Inverse transform
f = A*.c.AH
2
7/18/2015
2
Duong Anh Duc - Digital Image Processing
15
Haar transform
Haar transform matrix for sizes N=2,4,8
1 1 1
Hr2
2 1 1
1 1
2
1 1 1 2
Hr4
4 1 1
0
1 1
0
1
1
1
0
1 1
0 Hr8 8 1
2
1
2
1
1
1
2
1
2
1 2
1 2
1
0
1
0
1
0
1
0
0
0
0
0
2
2
2
2
2
0
0
0
2 0
0
0
0
2
0
0
0 2 0
0
0
0
2
0
0
0 2 0
0
0
0
2
0
0
0 2
Can be computed by taking sums and differences
Fast algorithms by recursively applying Hr2
7/18/2015
Duong Anh Duc - Digital Image Processing
16
Haar transform example
Original Cameraman
256x256
7/18/2015
256x256 Haar transform
of Cameraman
Duong Anh Duc - Digital Image Processing
17
Haar transform example
Original Einstein
256x256
7/18/2015
256x256 Haar transform
of Einstein
Duong Anh Duc - Digital Image Processing
18
Haar transform example
Original Lena
512x512
7/18/2015
512x512 Haar transform
of Lena
Duong Anh Duc - Digital Image Processing
19
Hadamard transform
Transform matrices can be recursively generated
1 1 1
2 1 1
Hd 4 Hd 2 Hd 2
Hd 2 Hr2
Hd 8 Hd 4 Hd 2 Hd 2 Hd 2 Hd 2
1
Example
1
1
1 1
Hd 8
8 1
1
1
1
7/18/2015
1
1
1
1
1
1
1
1
1
1
1
1
1 1 1
1 1 1
1
1
1 1
1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1
1
1
1
1
1
1
1
1
1
1
1
1
Note that Hadamard
Coefficients need
reordering to concentrate
energy
Duong Anh Duc - Digital Image Processing
20
Discrete Fourier transform
j 2
For DFT of order N, define WN exp
N
Transform
WN0 WN0
WN0
0
matrix
WN2
WN WN1
1 0
2
DTFN
W
W
N
N
N
0
N 1
WN2( N 1)
WN WN
N 1
WN
WN2( N 1)
WN( N 1)( N 1)
WN0
Definition for general N, fast algorithms for N=2m
DFT coefficients are complex (even if input image is
real)
Inverse transform DFTN-1 = DTFH = DTF*
7/18/2015
Duong Anh Duc - Digital Image Processing
21
Discrete cosine transform
Transform matrix
1
0 n N 1 k 0
N
DCTN ak ,n ak ,n
2
2n 1k
cos
0 n N 1 1 k N 1
2N
N
Can be interpreted as DFT
of a mirror-extended image block
(shown here for 2-d DCT)
Transform is used in many
coding standards (JPEG, MPEG)
7/18/2015
Duong Anh Duc - Digital Image Processing
22
Basis images of an 8x8 DCT
7/18/2015
Duong Anh Duc - Digital Image Processing
23
Blockwise DCT example
Original Lena
256x256
7/18/2015
Blockwise 8x8 DCT
of Lena
Duong Anh Duc - Digital Image Processing
24
Comparison of block transforms
Comparison of 1-D
basis functions for
block size N=8
7/18/2015
Duong Anh Duc - Digital Image Processing
25
Comparison of block transforms (cont.)
DCT
7/18/2015
Hadamard
Duong Anh Duc - Digital Image Processing
Haar
26
Transform Coding
7/18/2015
Duong Anh Duc - Digital Image Processing
27
Transform Coding (cont.)
7/18/2015
Duong Anh Duc - Digital Image Processing
28
DCT coding artifacts
DCT coding with increasingly coarse quantization, block size 8x8
quantizer stepsize
for AC coefficients: 25
7/18/2015
quantizer stepsize
for AC coefficients: 100
Duong Anh Duc - Digital Image Processing
quantizer stepsize
for AC coefficients: 200
29