Chapter 04c Frequency Filtering (Circulant Matrices) 2
Chapter 04c Frequency Filtering (Circulant Matrices) 2
Christophoros Nikou
[email protected]
c0 c1 c2 cN 1
C(m, n) c( mn ) mod N c
N 1 c0 c1
C cN 2 c2
c1
c1 c2 cN 1 c0 N N
C. Nikou – Digital Image Processing (E12)
5 Circulant matrices (cont.)
• Special case of a Toeplitz matrix.
• Each row (column) is generated by a circular shift
(modulo N) of the previous row (column).
c0 c1 c2 cN 1
C(m, n) c( mn ) mod N c
N 1 c0 c1
C cN 2 c2
c1
c1 c2 cN 1 c0 N N
C. Nikou – Digital Image Processing (E12)
6
Convolution by matrix-vector
operations
• 1-D linear convolution between two discrete
signals may be expressed as the product of a
Toeplitz matrix constructed by the elements of
one of the signals and a vector constructed by the
elements of the other signal.
• 1-D circular convolution between two discrete
signals may be expressed as the product of a
circulant matrix constructed by the elements of
one of the signals and a vector constructed by the
elements of the other signal.
• Extension to 2D signals.
C. Nikou – Digital Image Processing (E12)
7
1D linear convolution using Toeplitz
matrices
f [n] {1, 2, 2}, h[n] {1, 1}, N1 3, N 2 2
1 0 0
1 1 0
H Length of the result =4
0 1 1
0 0 1 43 Notice that H is not
circulant (e.g. a -1
appears in the second line
Length of f [n] = 3 which is not present in the
first line.
Zero-padded h[n] in the first column
C. Nikou – Digital Image Processing (E12)
9
1D linear convolution using Toeplitz
matrices (cont.)
f [n] {1, 2, 2}, h[n] {1, 1}, N1 3, N 2 2
1 0 0 1
1 1 0 1 1
g = Hf 2
0 1 1 0
2
0 0 1 2
g[n] {1, 1, 0, 2}
1 0 1
H 1 1 0
0 1 1 33
1 0 1 1 1
g = Hf 1 1 0 2 1
0 1 1 2 0
g[n] { 1, 1, 0}
AM 1 AM 2 AMN
• Aij are matrices.
• If the structure of A, with respect to its sub-matrices, is
Toeplitz (circulant) then matrix A is called block-Toeplitz
(block-circulant).
• If each individual Aij is also a Toeplitz (circulant) matrix then
A is called doubly block-Toeplitz (doubly block-circulant).
1 4 1 1 1
2 5 3 1 -1
n n
f [m,n] h [m,n]
1 4 1 1 1
2 5 3 1 -1
n n
f [m,n] h [m,n]
1 0 0 1 0 0 0 0 0
1 1 0 1 0 0
1 0 0
H1 H2 H3
0 1 1 0 1 1 0 0 0
0 0 1 0 0 1 0 0 0
1 4 1 1 1
2 5 3 1 -1
n n
f [m,n] h [m,n]
1 4 1 1 1
2 5 3 1 -1
n n
f [m,n] h [m,n]
2
5
• We now construct 3 (2 5 3)T
a vector from the f T
elements of f [m,n]. 1 (1 4 1)
4
1
C. Nikou – Digital Image Processing (E12)
19
2D linear convolution using doubly
block Toeplitz matrices (cont.)
m m
1 4 1 1 1
2 5 3 1 -1
n n
f [m,n] h [m,n]
2
5
H1 H3
3
g = Hf H 2
H1
1
H 3 H 2
4
1
C. Nikou – Digital Image Processing (E12)
20
2D linear convolution using doubly
block Toeplitz matrices (cont.)
1 0 0 0 0 0 2
1 1 0 0 0 0 3
0 1 1 0 0 0 2
0 0 1 0 0 0 3
2
1 0 0 1 0 0 5 3
(2 3 2 3)T
1 1 0 1 1 0 3 10 T
g = Hf (3 10 5 2)
0 1 1 0 1 1 1 5
(1 5 5 1)T
0 0 1 0 0 1 4 2
0 0 0 1 0 0 1 1
0 0 0 1 1 0 5
0 0 0 0 1 1 5
0 0 0 0 0 1 1
C. Nikou – Digital Image Processing (E12)
21
2D linear convolution using doubly
block Toeplitz matrices (cont.)
m m
1 4 1 1 1
2 5 3
n
* 1 -1
n
f [m,n] h [m,n]
m
1 5 5 1 (2 3 2 3)T
T
= 3 10 5 2
2 3 -2 3
g = (3 10 5 2)
(1 5 5 1)T
n
g [m,n]
C. Nikou – Digital Image Processing (E12)
22
2D linear convolution using doubly
block Toeplitz matrices (cont.)
Another example
m m
3 4
1 2 1 -1
n n
f [m,n] h [m,n]
3 4
1 2 1 -1
n n
f [m,n] h [m,n]
• At first, h[m,n] is zero-padded
to 2 x 3 (the size of the m
result).
• Then, for each line of h[m,n], 0 0 0
a Toeplitz matrix with 2 1 -1 0
columns (the number of n
h[m,n]
columns of f [m,n]) is
constructed. C. Nikou – Digital Image Processing (E12)
24
2D linear convolution using doubly
block Toeplitz matrices (cont.)
m • For each row of h[m,n], a Toeplitz
matrix with 2 columns (the
0 0 0 number of columns of f [m,n]) is
1 -1 0 constructed.
n
h[m,n]
1 0 0 0
H1 1 1 H 2 0 0
0 1 0 0
3 4
1 2 1 -1
n n
f [m,n] h [m,n]
• Using matrices H1 and
H2 as elements, a
doubly block Toeplitz H1 H2
H
matrix H is then H2 H1 64
constructed with 2
columns (the number of
rows of f [m,n]).
C. Nikou – Digital Image Processing (E12)
26
2D linear convolution using doubly
block Toeplitz matrices (cont.)
m m
3 4
1 2 1 -1
n n
f [m,n] h [m,n]
1
2 (1 2)T
• We now construct a f T
vector from the elements 3 (3 4)
of f [m,n].
4
3 4
1 2 1 -1
n n
f [m,n] h [m,n]
1
H1 H 2 2
g = Hf
H2 H1 3
4
C. Nikou – Digital Image Processing (E12)
28
2D linear convolution using doubly
block Toeplitz matrices (cont.)
1 0 0 0 1
1 1 0 0 1 1
0 1 0 0 2 2 (1 1 2)T
g = Hf T
0 0 1 0 3 3
(3 1 4)
0 0 1 1 4 1
0 0 0 1 4
3 4
1 2
* 1 -1
n n
f [m,n] h [m,n]
m
(1 1 2)T
= 3 1 4
1 1 -2
g= T
(3 1 4)
n
g [m,n]
C. Nikou – Digital Image Processing (E12)
30
2D circular convolution using doubly
block circulant matrices
The circular convolution g[m,n]=f [m,n]h [m,n]
with 0 m M 1, 0 n N 1,
g = Hf
h [ j , 0] h [ j, N 1] h [ j,1]
h [ j ,1] h [ j , 0] h [ j, 2]
Hj
h [ j , N 1] h [ j , N 2] h [ j, 0] N N
1 0 1 1 0 0 0 0 0
H 0 1 1 0 H1 0 1 0 H 2 0 0 0
0 1 1 0 0 1 0 0 0
H1
T
H0 H2 1 2 1
g = Hf H1
H 2 1 3 1
T
H0
H 2 H1 H 0 0 1 0 T
m 0 2 1T
1 4 -2
= 3 4 -3 g = 3 4 3
T
T
0 2 -1
n 1 4 2
g [m,n]
C. Nikou – Digital Image Processing (E12)
37 Diagonalization of circulant matrices
Theorem: The columns of the inverse DFT matrix
are eigenvectors of any circulant matrix. The
corresponding eigenvalues are the DFT values of
the signal generating the circulant matrix.
Proof: Let
2 2 n
j j k
wN e
w e nk
N
w0 0 w 0 1
w
0 2
w 0 N 1
N N N N
1 0 1 N 1
w w 1 1
w w
1 2
A N N N N
w N 1 0 w w
N 1 1 N 1 2
wNN 1
N 1
N N N
1 k m 1 m
kl
wN h [l ]N wN h [l ]N wN
kl
N l m( N 1) l 0
1 k m N 1 N 1 N 1
kl
wN h [l ]N wN h [l ]N wN h [l ]N wN
kl kl
1 k m N 1 N 1 N 1
kl
wN h [l ]N wN h [l ]N wN h [l ]N wN
kl kl
N l m1 l 0 l m 1
Hα k H [k ]α k
which means that αk, for any k, is an eigenvector of
H with corresponding eigenvalue the k-th element
of H[k], the DFT of the signal generating H .
C. Nikou – Digital Image Processing (E12)
44
Diagonalization of circulant matrices
(cont.)
The above expression may be written in terms of
the inverse DFT matrix:
1 1
HA A Λ
Λ=diag H[0], H[1],..., H [ N 1]
or equivalently: Λ ΑHA 1
aM 1B aM 2B aMN B MK NL
C. Nikou – Digital Image Processing (E12)
47
Diagonalization of doubly block
circulant matrices (cont.)
• The 2D signal f [m,n], 0 m M 1, 0 n N 1,
may be vectorized in lexicographic ordering
(stacking one column after the other) to a
vector:
f MN1
• The DFT of f [m,n], may be obtained in
matrix-vector form:
F A A f
Λ A A H A A
1