Digital filters based on Fourier transform
Eugeniy E. Mikhailov and Greg Bentsen
Today
- DFT and spectrum of the signal
- Filters
DFT recap
Often in literature instead of
is used instead of
:
The operator notation:
Where the time domain signal
and
is its spectrum.
Note that DFT itself does not care about time, it is in the
“eye of the beholder” and usually accounted separately.
Recall that
,
with
time domain
Sample spacing
.
Sample rate
.
Spectrum (amplitude vs frequency)
Resolution bandwidth
.
Frequency of
-th
component
.
Nyquist frequency
If we take
data points with the sampling rate
,
what is the maximum frequency which we can expect to see in our
spectrum?
Naively, we can say
,
since in the DFT spectrum all points are separated by the fundamental
frequency
However, recall that
Thus,
,
i.e., the higher half of the vector
contains negative frequency. So at most, we can hope to obtain a
spectrum with the highest real frequency smaller than
Nyquist frequency
Nyquist criteria
You must sample your signal more than twice
faster than the highest frequency component of it. I.e., the
Nyquist frequency of your sample should be
than the highest signal frequency.
Aliasing: wrong/slow sampling frequency
Sampling with
i.e.
Sampled signal appeared to be DC
example of sampling at Nyquist frequency
Aliasing: too slow sampling frequency - reflection
Under sampling
The sampled signal seems to have a lower frequency.
The sampled signal appears to have a slower frequency. This is case
of the reflection/folding where the signal frequency is slightly higher
than the sampling frequency.
example undersampling
Aliasing: too slow sampling frequency - ghosts
Under sampling
The sampled signal looks very different.
example of under sampling
DFT filters
Once you get a signal, you can filter the unwanted frequencies out of
it.
The recipe is the following
- sample the signal
- calculate DFT (use Python
numpy.fft.fft )
- have a look at the spectrum and decide which frequencies are
unwanted
- apply a filter which attenuates unwanted frequencies amplitudes
- If you attenuate the component of the frequency
by
,
you need to attenuate the component at
by
.
Otherwise, the inverse Fourier transform will have non zero imaginary
part.
- calculate inverse DFT (
numpy.fft.ifft) of the filtered
spectrum
- repeat if needed
Applications
- noise reduction
- compression
Brick wall low-pass filter
Filter gain function

freq = np.fft.fftfreq(N, dt)
g = np.ones(N)
g[np.abs(freq) > Fcutoff] = 0
y_filtered = np.fft.ifft( np.fft.fft(y) * g)
Brick wall low-pass filter (continued)

Brick wall high-pass filter
Filter gain function

freq = np.fft.fftfreq(N, dt)
g = np.ones(N)
g[np.abs(freq) < Fcutoff] = 0
y_filtered = np.fft.ifft( np.fft.fft(y) * g)
Brick wall high-pass filter (continued)

Brick wall band-pass filter
Filter gain function

Brick wall band-pass filter (continued)

Brick wall band-stop filter
Filter gain function

Brick wall band-stop filter (continued)

Brick wall filters artifacts
Sharp features in the Fourier spectrum produce ring-down like
signals
Filter gain function

Low pass smoothed
Sharp features in the Fourier spectrum produce ring-down like
signals
Filter gain function

Windowing
Windowing artifacts
Similarly, sharp features in the time domain take the wider
spectrum
Implicitly assumed
Rectangular window
The Hann window
- Note: spectral resolution
.
Search for other windowing functions: Hamming, Tukey, Cosine,
Lanczos, Triangulars, Gaussians, Bartlett-Hann, Blackmans, Kaisers.
They all decrease a signal at the beginning and at the end to
zero.
Other DFT applications
Fun one: merging of two dimensional high- and low-pass image
filters
Depending on distance to the image, you should see either
Prof. Mikhailov or Prof. Novikova in the middle.
To see the other person in the image, either step aside or decrease
zoom till you do not see details on the right most image.
If you can take off your glasses, the illusion is stronger.