3/14/2011 1 Digital Image Processing Filtering in the Frequency Domain (Circulant Matrices and Convolution) Christophoros Niko University of Ioannina - Department of Computer Science Christophoros Nikou [email protected]2 Toeplitz matrices • Elements with constant value along the main diagonal and sub-diagonals. • For a NxN matrix, its elements are determined by a (2N-1)-length sequence { } ( 1) 1 | n N n N t − − ≤ ≤ − ( 1) 0 1 2 1 0 1 N t t t t t t t − − − − ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ … % # ( ,) m n mn t − = T C. Nikou – Digital Image Processing (E12) 1 1 0 1 2 2 1 2 1 0 N N N t t t t t t t − − − − × ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ T % % % # % % % …
24
Embed
Chapter 04c Frequency Filtering (Circulant Matrices) 2spp
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
3/14/2011
1
Digital Image Processing
Filtering in the Frequency Domain (Circulant Matrices and Convolution)
Christophoros Niko
University of Ioannina - Department of Computer Science
• Elements with constant value along the main diagonal and sub-diagonals.
• For a NxN matrix, its elements are determined by a (2N-1)-length sequence { }( 1) 1|n N n Nt − − ≤ ≤ −
( 1)0 1 2
1 0 1
Nt t t tt t t
− −− −⎡ ⎤⎢ ⎥⎢ ⎥
…( , ) m nm n t −=T
C. Nikou – Digital Image Processing (E12)
1
1 0 1
2 2
1
2 1 0N N N
t tt
t t t t−
−
−
−
×
⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦
T
…
3/14/2011
2
3 Toeplitz matrices (cont.)
• Each row (column) is generated by a shift of the previous row (column).− The last element disappears.− A new element appears.
( 1)0 1 2
1 0 1
Nt t t tt t t
− −− −⎡ ⎤⎢ ⎥⎢ ⎥
…( , ) m nm n t −=T
C. Nikou – Digital Image Processing (E12)
1
1 0 1
2 2
1
2 1 0N N N
t tt
t t t t−
−
−
−
×
⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦
T
…
4 Circulant matrices
• Elements with constant value along the main diagonal and sub-diagonals.
• For a NxN matrix, its elements are determined by a N-length sequence { }0 1|n n Nc ≤ ≤ −
1
1
0 1 2
0 1
N
N
c c c cc c c
−
−
⎡ ⎤⎢ ⎥⎢ ⎥
…( )mod( , ) m n Nm n c −=C
C. Nikou – Digital Image Processing (E12)
2
1
2
1
1 2 0
N
N N N
c cc
c c c c
−
− ×
⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦
C
…
3/14/2011
3
5 Circulant matrices (cont.)
• Special case of a Toeplitz matrix.• Each row (column) is generated by a circular shift( ) g y
(modulo N) of the previous row (column).
1
1
0 1 2
0 1
N
N
c c c cc c c
−
−
⎡ ⎤⎢ ⎥⎢ ⎥
…( )mod( , ) m n Nm n c −=C
C. Nikou – Digital Image Processing (E12)
2
1
2
1
1 2 0
N
N N N
c cc
c c c c
−
− ×
⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦
C
…
6Convolution 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
C. Nikou – Digital Image Processing (E12)
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.
3/14/2011
4
71D linear convolution using Toeplitz
matrices
1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N= = − = =
• The linear convolution g[n]=f [n]*h [n] will be of length N=N1+N2-1=3+2-1=4.
• We create a Toeplitz matrix H from the elements of h [n] (zero-padded if needed) with
C. Nikou – Digital Image Processing (E12)
− N=4 lines (the length of the result).− N1=3 columns (the length of f [n]).− The two signals may be interchanged.
81D linear convolution using Toeplitz
matrices (cont.)
1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N= = − = =
1 0 01 1 00 1 10 0 1
⎡ ⎤⎢ ⎥−⎢ ⎥=⎢ ⎥−⎢ ⎥−⎣ ⎦
H Length of the result =4
Notice that H is not
C. Nikou – Digital Image Processing (E12)
4 30 0 1×⎣ ⎦
Length of f [n] = 3
Notice that H is not circulant (e.g. a -1 appears in the second line which is not present in the first line.
Zero-padded h[n] in the first column
3/14/2011
5
91D linear convolution using Toeplitz
matrices (cont.)
1 2[ ] {1, 2, 2}, [ ] {1, 1}, 3, 2f n h n N N= = − = =
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 nj j knkw e w eπ π
− −Ν Ν= ⇔ =
C. Nikou – Digital Image Processing (E12)
N Nw e w eΝ Ν= ⇔ =
be the DFT basis elements of length N with:
0 1, 0 1,k N n N≤ ≤ − ≤ ≤ −
38Diagonalization of circulant matrices
(cont.)We know that the DFT F [k] of a 1D signal f [n]
may be expressed in matrix-vector form:may be expressed in matrix vector form:
whereF = Af
[ ] [ ][0], [1],..., [ 1] , [0], [1],..., [ 1]T Tf f f N F F F N− −f = F =
( ) ( ) ( ) ( )0 1 2 10 0 0 0 N
N N N Nw w w w−⎡ ⎤
⎢ ⎥…
C. Nikou – Digital Image Processing (E12)
( ) ( ) ( ) ( )( ) ( ) ( ) ( )
( ) ( ) ( ) ( )
0 1 2 11 1 1 1
0 1 2 11 1 1 1
N N N N
N
N N N N
NN N N NN N N N
w w w w
w w w w
−
−− − − −
⎢ ⎥⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦
A …
…
3/14/2011
20
39Diagonalization of circulant matrices
(cont.)The inverse DFT is then expressed by:
-1f = A F
where
f = A F
( )
( ) ( ) ( ) ( )( ) ( ) ( ) ( )
*0 1 2 10 0 0 0
0 1 2 11 1 1 11 *1 1
TN
N N N N
NT N N N N
w w w w
w w w wN N
−
−
−
⎛ ⎞⎡ ⎤⎜ ⎟⎢ ⎥⎜ ⎟⎢ ⎥⎜ ⎟⎢ ⎥= = ⎜ ⎟⎢ ⎥⎜ ⎟⎢ ⎥⎜ ⎟
A A
…
…
C. Nikou – Digital Image Processing (E12)
( ) ( ) ( ) ( )0 1 2 11 1 1 1 NN N N NN N N Nw w w w
−− − − −⎢ ⎥⎜ ⎟⎢ ⎥⎜ ⎟⎣ ⎦⎝ ⎠
…
The theorem implies that any circulant matrix has eigenvectors the columns of A-1.
40Diagonalization of circulant matrices
(cont.)Let H be a NxN circulant matrix generated by the 1D N-length signal h[n], that is:
[ ]mod( , ) ( ) [ ]N Nm n h m n h m n= − −H
Let also αk be the k-th column of the inverse DFT matrix A-1. We will prove that αk for any k is an eigenvector of H
C. Nikou – Digital Image Processing (E12)
We will prove that αk, for any k, is an eigenvector of H.The m-th element of the vector Hαk, denoted by is the result of the circular convolution of the signal h[n] with αk.
[ ]k mHα
3/14/2011
21
41Diagonalization of circulant matrices
(cont.)
[ ]1
0
[ ] [ ]N
k N kmn
h m n nα−
= −∑Hα1
0
1 [ ]N
k nN Nh m n w
N
−−= −∑
0n= 0nN =
( 1)( )1 [ ]
m Nl m nk m l
N Nl m
h l wN
− −= −− −
=
= ∑( 1)1 [ ]
m Nk m k l
N N Nl m
w h l wN
− −−
=
= ∑
11 ⎡ ⎤
C. Nikou – Digital Image Processing (E12)
1
( 1) 0
1 [ ] [ ]m
k m k l k lN N N N N
l m N l
w h l w h l wN
−−
= − − =
⎡ ⎤= +⎢ ⎥
⎣ ⎦∑ ∑
We will break it into two parts
42Diagonalization of circulant matrices
(cont.)1 1 11 [ ] [ ] [ ]
N Nk m k l k l k l
N N N N N N Nw h l w h l w h l w− − −
− ⎡ ⎤= + −⎢ ⎥∑ ∑ ∑
( 1) 0 1
[ ] [ ] [ ]N N N N N N Nl m N l l mN = − − = = +⎢ ⎥⎣ ⎦∑ ∑ ∑
Periodic with respect to N.
1 1 1
( 1) 0 1
1 [ ] [ ] [ ]N N N
k m k l k l k lN N N N N N N
l N m N l l m
w h l w h l w h l wN
− − −−
= + − − = = +
⎡ ⎤= + −⎢ ⎥
⎣ ⎦∑ ∑ ∑
C. Nikou – Digital Image Processing (E12)
1 1 1
1 0 1
1 [ ] [ ] [ ]N N N
k m k l k l k lN N N N N N N
l m l l mw h l w h l w h l w
N
− − −−
= + = = +
⎡ ⎤= + −⎢ ⎥⎣ ⎦∑ ∑ ∑ ⇔
3/14/2011
22
43Diagonalization of circulant matrices
(cont.)
[ ]1
0
1 [ ]N
k m k lk N N Nm
lw h l w
N
−−
=
⎡ ⎤= ⎢ ⎥⎣ ⎦∑Hα [ ][ ] k m
H k= α0lN =⎣ ⎦
DFT of h[n] at k.
This holds for any value of m. Therefore:
[ ]k kH k=Hα α
C. Nikou – Digital Image Processing (E12)
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 .
44Diagonalization of circulant matrices
(cont.)The above expression may be written in terms of the inverse DFT matrix:the inverse DFT matrix:
1 1− −=HA A Λ{ }=diag [0], [1],..., [ 1]H H H N −Λ
or equivalently: 1−=Λ ΑHA
C. Nikou – Digital Image Processing (E12)
Based on this diagonalization, we can prove the property between circular convolution and DFT.
q y
3/14/2011
23
45Diagonalization of circulant matrices
(cont.)g = Hf ⇔ -1g = HA Af ⇔ -1Ag = AHA Af ⇔ G = ΛF
circulant matrices • These properties may be generalized in 2D.• We need to define the Kronecker product:
11 12 1Na a a⎡ ⎤⎢ ⎥
B B B…
,M N K L× ×∈ ∈A B
C. Nikou – Digital Image Processing (E12)
21 22 2
1 2
N
M M MN MK NL
a a a
a a a×
⎢ ⎥⎢ ⎥⊗ =⎢ ⎥⎢ ⎥⎣ ⎦
B B BA B
B B B
…
…
3/14/2011
24
47Diagonalization of doubly block
circulant matrices (cont.) • The 2D signal f [m,n], 0 1, 0 1,m M n N≤ ≤ − ≤ ≤ −
may be vectorized in lexicographic ordering (stacking one column after the other) to a vector:
1MN×∈f
• The DFT of f [m n] may be obtained in
C. Nikou – Digital Image Processing (E12)
The DFT of f [m,n], may be obtained in matrix-vector form:
( )F = ⊗A A f
48Diagonalization of doubly block
circulant matrices (cont.) Theorem: The columns of the inverse 2D DFT matrix
( ) 1
are eigenvectors of any doubly block circulantmatrix. The corresponding eigenvalues are the 2D DFT values of the 2D signal generating the doubly block circulant matrix:
( ) 1−⊗A A
C. Nikou – Digital Image Processing (E12)
( ) ( ) 1−= ⊗ ⊗Λ A A H A A
block circulant matrix:
Doubly block circulantDiagonal, containing the 2D DFT of h[m,n] generating H