Frequency-domain filtering
1 Exercise: Fourier transform
Solve this Fourier transform problem using Excel. We will create a spreadsheet to calculate each term in the DFT and inverse DFT equations. That is, $f(x)e^{-2i\pi ux/M}$ and $F(u)e^{2i\pi ux/M}$.
1.1 Complex numbers in Excel
COMPLEX(a, b)
: $a+ib$IMREAL(COMPLEX(a, b))
: $a$IMAGINARY(COMPLEX(a, b))
: $b$IMEXP(COMPLEX(a, b))
: $e^{a+ib}$IMEXP(COMPLEX(0, -2*PI()))
: $e^{-2i\pi}$IMPRODUCT(c, IMEXP(COMPLEX(a, b)))
: $ce^{a+ib}$IMSUM(...)
: $\sum\cdots$
1.2 State the problem
First, copy the problem. What is $M$?
x | 0 | 1 | 2 |
---|---|---|---|
f(x) | 5 | 3 | 2 |
M | ? |
1.3 $f(x)e^{-2i\pi ux/M}$
\[F(u)=\frac{1}{M}\sum_{x=0}^{M-1}f(x)e^{-2i\pi ux/M}\]
For each $u=0,\cdots,M-1$, we need $x=0,\cdots,M-1$.
u | x | f(x) | f(x)*exp() |
---|---|---|---|
0 | 0 | 5 | =IMPRODUCT( $f(x)$, IMEXP(COMPLEX(0, -2*PI()* $u$* $x$/ $M$))) |
0 | 1 | 3 | |
0 | 2 | 2 | |
1 | 0 | 5 | |
1 | 1 | 3 | |
1 | 2 | 2 | |
2 | 0 | 5 | |
2 | 1 | 3 | |
2 | 2 | 2 |
1.4 $F(u)$
Now, for each $u$, we need to sum $f(x)e^{-2i\pi ux/M}$ and divide it by $M$ to get $F(u)$.
u | x | f(x) | f(x)*exp() | F(u) |
---|---|---|---|---|
0 | 0 | 5 | =IMPRODUCT(IMSUM( $f(x)e^{-2i\pi ux/M}$), 1/ $M$) | |
0 | 1 | 3 | ||
0 | 2 | 2 | ||
1 | 0 | 5 | =IMPRODUCT(IMSUM( $f(x)e^{-2i\pi ux/M}$), 1/ $M$) | |
1 | 1 | 3 | ||
1 | 2 | 2 | ||
2 | 0 | 5 | =IMPRODUCT(IMSUM( $f(x)e^{-2i\pi ux/M}$), 1/ $M$) | |
2 | 1 | 3 | ||
2 | 2 | 2 |
1.5 $F(u)e^{2i\pi ux/M}$
\[f(x)=\sum_{u=0}^{M-1}F(u)e^{2i\pi ux/M}\]
For each $x=0,\cdots,M-1$, we need $u=0,\cdots,M-1$.
x | u | F(u) | F(u)*exp() |
---|---|---|---|
0 | 0 | =IMPRODUCT( $F(u)$, IMEXP(COMPLEX(0, 2*PI()* $u$* $x$/ $M$))) | |
0 | 1 | ||
0 | 2 | ||
1 | 0 | ||
1 | 1 | ||
1 | 2 | ||
2 | 0 | ||
2 | 1 | ||
2 | 2 |
1.6 $f(x)$
For each $x$, we need to sum $F(u)e^{2i\pi ux/M}$ and take its real part to get $f(x)$.
x | u | F(u) | F(u)*exp() | f(x) |
---|---|---|---|---|
0 | 0 | =IMREAL(IMSUM( $F(u)e^{-2i\pi ux/M}$)) | ||
0 | 1 | |||
0 | 2 | |||
1 | 0 | =IMREAL(IMSUM( $F(u)e^{-2i\pi ux/M}$)) | ||
1 | 1 | |||
1 | 2 | |||
2 | 0 | =IMREAL(IMSUM( $F(u)e^{-2i\pi ux/M}$)) | ||
2 | 1 | |||
2 | 2 |
2 Exercise: Ideal low-pass filter
\[H(u,v)= \begin{cases} 1& \text{if }D(u,v)\leq D_0\\ 0& \text{otherwise} \end{cases}\]
filt = ideal_lowpass_filter
This filter smooths the image, but it has a ringing effect because of a sudden drop in the filter surface.
3 Exercise: Gaussian low-pass filter
\[H(u,v)=e^{-D^2(u,v)/(2D_0^2)}\]
filt = gaussian_lowpass_filter
This filter also smooths the image, but it does not have the same ringing effect by the ideal low-pass filter because it has a smooth drop in the filter surface.
4 Exercise: Gaussian high-pass filter
\[H(u,v)=1-e^{-D^2(u,v)/(2D_0^2)}\]
filt = gaussian_highpass_filter
This filter highlights transitions between smooth areas, which in effect, sharpens the image.
5 Homework: Fourier transform
Solve this Fourier transform problem using Excel. Please submit your Excel file and the final answer in the table below (only real parts).