The regular 2D convolution equation is
g[m,n]=
(
(f[k,l]h[m−k,n−l]))(5)
Below we go through the steps of convolving two two-dimensional arrays. You can think of f as representing an image and h represents a PSF, where h[m,n]=0 form∧n>1 and m∧n<0. h=(
h[0,0] | h[0,1] |
h[1,0] | h[1,1] |
) f=(
f[0,0] | … | f[0,N−1] |
⋮ | ⋱ | ⋮ |
f[N−1,0] | … | f[N−1,N−1] |
) Step 1 (Flip
h):
h[−m,−n]=(
h[1,1] | h[1,0] | 0 |
h[0,1] | h[0,0] | 0 |
0 | 0 | 0 |
)(6)
Step 2 (Convolve):
g[0,0]=h[0,0]f[0,0](7)
We use the standard 2D convolution equation (
Equation 5) to find the first element of our convolved image. In order to better understand what is happening, we can think of this visually. The basic idea is to take
h[−m,−n] and place it "on top" of
f[k,l], so that just the bottom-right element,
h[0,0] of
h[−m,−n] overlaps with the top-left element,
f[0,0], of
f[k,l]. Then, to get the next element of our convolved image, we slide the flipped matrix,
h[−m,−n], over one element to the right and get the following result:
g[0,1]=h[0,0]f[0,1]+h[0,1]f[0,0] We continue in this fashion to find all of the elements of our convolved image,
g[m,n]. Using the above method we define the general formula to find a particular element of
g[m,n] as:
g[m,n]=h[0,0]f[m,n]+h[0,1]f[m,n−1]+h[1,0]f[m−1,n]+h[1,1]f[m−1,n−1](8)
What does H[k,l]F[k,l] produce?
Due to periodic extension by DFT (
Figure 2):
Based on the above solution, we will let
g[m,n]=IDFT(H[k,l]F[k,l])(10)
Using this equation, we can calculate the value for each position on our final image,
g[m,n]. For example, due to the periodic extension of the images, when circular convolution is applied we will observe a
wrap-around effect.
g[0,0]=h[0,0]f[0,0]+h[1,0]f[N−1,0]+h[0,1]f[0,N−1]+h[1,1]f[N−1,N−1](11)
Where the last three terms in
Equation 11 are a result of the wrap-around effect caused by the presence of the images copies located all around it.
If the support of
h is
Mx
M and
f is
Nx
N, then we zero pad
f and
h to
M+N−1 x
M+N−1 (see
Figure 3).
Circular Convolution = Regular Convolution
F[k,l]=
(
(f[m,n]ⅇ(−ⅈ)
ⅇ(−ⅈ)
))(12)
where in the above equation,
(f[m,n]ⅇ(−ⅈ)
) is simply a 1D DFT over
n. This means that we will take the 1D FFT of each row; if we have
N rows, then it will require
NlogN operations per row. We can rewrite this as
F[k,l]=
(f′[m,l]ⅇ(−ⅈ)
)(13)
where now we take the 1D FFT of each column, which means that if we have
N columns, then it requires
NlogN operations per column.
Therefore the overall complexity of a 2D FFT is O(N2logN) where N2 equals the number of pixels in the image.
No comments:
Post a Comment