0% found this document useful (0 votes)
144 views3 pages

A) Keeping The Central Values of The Centralized DFT

The document discusses the discrete Fourier transform (DFT) and its implementation in SciPy. It provides an overview of the key DFT functions in SciPy like fft, ifft, fftshift, ifftshift. These functions allow computing the DFT and inverse DFT in 1, 2 or n dimensions. It also mentions window functions in NumPy that can be used for tapering. The DFT is used for fast convolutions in SciPy. SciPy wraps the FFTPACK library for computing DFTs, though it may not be the fastest implementation.

Uploaded by

Mule Won Tege
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views3 pages

A) Keeping The Central Values of The Centralized DFT

The document discusses the discrete Fourier transform (DFT) and its implementation in SciPy. It provides an overview of the key DFT functions in SciPy like fft, ifft, fftshift, ifftshift. These functions allow computing the DFT and inverse DFT in 1, 2 or n dimensions. It also mentions window functions in NumPy that can be used for tapering. The DFT is used for fast convolutions in SciPy. SciPy wraps the FFTPACK library for computing DFTs, though it may not be the fastest implementation.

Uploaded by

Mule Won Tege
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Discrete Fourier Transform (DFT) May 10, 2021

Load the image “cameraman.tif” and convert its type to double.

1. Understanding the DFT of an Image

Compute the DFT of the image (fft2).

Compute the inverse (ifft2, real) and display it using subplot, imagesc, log10 and abs.

Did you get the original image back?

Why do we apply a logarithmic scale log10 to display the DFT image?

Why do we have to use the absolute value when displaying the DFT?

Display the centralized DFT by applying fftshift. It has index (0,0) in the middle of the image.

Where, in the centralized DFT, do you find the low frequency values and where do you find the high
frequency values?

2. Filtering in the Frequency Domain

a) Keeping the central values of the centralized DFT

Create a filtering mask using the following code.

[x,y]=meshgrid(-127:128,-127:128);

z=sqrt(x.^2+y.^2);

filMask1=(z<20); % radius of the mask

Display the image filMask1 and see what it looks like.

Perform pixel-wise multiplication of filMask1 and the centralized DFT image, and display the result,
say “filDFT1”.

Perform the inverse process of fftshift (using ifftshift) on “filDFT1” to take indices back to their
original locations, and then apply ifft2 to get the image in spatial domain.

Describe the resultant image by inspecting the operations that you have performed. Justify your
answer by changing the radius of the mask to 5, 10, 50, 100.

b) Eliminating the central values of the centralized DFT

Repeat Question a) above by changing the filtering mask to:

filMask2=(z>20); % radius of the mask

c) Keeping the middle values of the centralized DFT


Discrete Fourier Transform (DFT) May 10, 2021

Repeat Question a) above by changing the filtering mask to:

filMask3=((z>20)&(z<50)); % radii of the mask

Here, you should justify your answer by changing one or both radii, but the first radius should be less
than the second.

3. Spatial Domain vs. Frequency Domain

Discuss the advantages of filtering in the frequency domain as compared to doing it in the spatial
domain.

Solution
History
Tracing the exact origins of the Fourier transform is tricky. Some related
procedures go as far back as Babylonian times, but it was the hot topics of
calculating asteroid orbits and solving the heat (flow) equation that led to
several breakthroughs in the early 1800s. Whom exactly among Clairaut,
Lagrange, Euler, Gauss, and D’Alembert we should thank is not exactly
clear, but Gauss was the first to describe the fast Fourier transform (an
algorithm for computing the DFT, popularized by Cooley and Tukey in
1965). Joseph Fourier, after whom the transform is named, first claimed
that arbitrary periodic5 functions can be expressed as a sum of
trigonometric functions.

Implementation
The DFT functionality in SciPy lives in the scipy.fftpack module. Among
other things, it provides the following DFT-related functionality:

fft, fft2, fftn

Compute the DFT using the FFT algorithm in 1, 2, or n dimensions.

ifft, ifft2, ifftn
Discrete Fourier Transform (DFT) May 10, 2021

Compute the inverse of the DFT.

dct, idct, dst, idst

Compute the cosine and sine transforms, and their inverses.

fftshift, ifftshift

Shift the zero-frequency component to the center of the spectrum


and back, respectively (more about that soon).

fftfreq

Return the DFT sample frequencies.

rfft

Compute the DFT of a real sequence, exploiting the symmetry of the


resulting spectrum for increased performance. Also used
by fft internally when applicable.

This list is complemented by the following functions in NumPy:

np.hanning, np.hamming, np.bartlett, np.blackman, np.kaiser

Tapered windowing functions.

The DFT is also used to perform fast convolutions of large inputs


by scipy.signal.fftconvolve.

SciPy wraps the Fortran FFTPACK library—it is not the fastest out there,
but unlike packages such as FFTW, it has a permissive free software
license

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy