0% found this document useful (0 votes)
33 views4 pages

The final

final final project

Uploaded by

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

The final

final final project

Uploaded by

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

Fourier Transform of waves

李杰倫 B092030023 余奕霆 B092030038

1. Fourier Transform of sound


Purpose: To implement the 1D Fourier Transform in Python and to see how frequencies are

distributed in a single tone and different instruments.

(1) Fourier Transform in integral and for loop


First, we wrote a Fourier transform using integral and for loop, the initial signal we set is 𝑓(𝑡) =
0.5 sin(2𝜋 ∗ 80 ∗ 𝑡) + 0.3sin⁡(2𝜋 ∗ 100 ∗ 𝑡), where 80 and 100 are the frequencies. The integral method

used the original definition of the Fourier Transform: 𝐹(𝑤) = ⁡ ∫−∞ 𝑓(𝑡)𝑒 −𝑖𝑤𝑡 𝑑𝑡, and then we separated
the real part and imaginary part by Euler’s formula, and calculated them individually. Because we’re
𝑛
only interested in positive frequencies, we just consider frequencies range of + 1,where 𝑛 means
2

how many points you want to calculate in time range [a, b] (in the code we take a = 0, b = 1).
For the for loop method we used the definition of DFT (Discrete Fourier Transform):𝑋[𝑘] =
𝑖2𝜋𝑘𝑛

∑𝑁−1
𝑛=0 𝑥[𝑛]𝑒 𝑁 . iimilarly, we separate them in real and imaginary part, and calculated them
𝑁
individually. For the same reason we only calculate to + 1, where 𝑁 means the length of the signal.
2

After the calculation we did above, we compare the result with the real Fourier transform in numpy, and
it came out really good( due to the length of the report, the result can be seen in the supplementary
materials file).
The main difference between FT and DFT is that FT provides a comprehensive spectrum of non-
periodic continuous signals but requires whole signal processing. DFT, useful for digital signals, it can
process discrete and finite data, so DFT is more efficient than FT.

(2) Fourier analysis of different instruments


Next, we start analyzing the single tone of piano(G5), guitar(G4), and clarinet(G4). We used librosa
to read the audio file: , ”sr” is the sampling
rate, it indicates how many samples are recorded per second. And then we define a function called
, ”signal” is the first variable we get
from ”librosa.load()”, ”sr” is the sampling rate, ”title” means the title of the spectrum, and ”f_ratio=1”
means the length of the spectrum we want to see, we set it initially equals to 1 because the real FFT
will return the symmetric spectrum at the latter half of the spectrum, so when we call the function, we
set it equals to 0.5, it won’t show the symmetric part. Because we set f_ratio=0.5, but the sampling rate
remains the same, the frequency on the spectrum will double, so we double the space between x-data
,then the frequency remains the same.

f_bins indicates the length of the x-axis we want.

find_peaks will return the index of the maximum value


of the amplitude in the distance of 200 Hz(in x-direction), and the adjust_text() function is to adjust
every label of max frequency and max amplitude automatically.
As you can see, the frequency
corresponding to the maximum amplitude
is 392.48 Hz, it’s the same frequency we
saw on the tuner. The other interesting
thing is that the peaks shown on the
spectrum have the same distance
between them. (Due to the length of the report, the result can be seen in the supplementary materials
file).
This is called the ”Harmonic series”, the reason of this phenomena is because a single tone is
actually composed by a lot of frequencies, and adding of the frequencies will acting like standing waves,
the fundamental tone is the frequency you play, and only the integer multiple of the fundamental tone
will exist. Different instruments have different timbre, and it results in the difference between the
amplitude of peaks.
2. Two-dimensional Fourier transform

This is Patrick and his Fourier transform. In frequency domain, “low frequency” is in the center of
the picture and the “high frequency” is at the edge of the picture. The frequency of 2D Fourier transform
means the variance ratio of luminance.

↑picture 1
For example, let’s do Fourier transform alone the red line. The black part in picture 1 will be the
high frequency signal and the gray part will be the low frequency signal.
In order to prove that the low frequency is in the
middle of the frequency domain picture. We dig out
the center of the frequency domain Patrick, and
then do inverse Fourier transform on it.The
frequency domain Patrick left only the edge of itself,
where the variance ratio of luminace is the biggest.
3. Image denoising
Purpose: To erase or reduce the noise of picture.

↑pepper noise ↑white noise


First of all we have two different types of noise, the first one is pepper noise and the second one
is white noise.The Y-axis represents the number(pixels) of the noise and the X-asix represents the
luminance of the noise.
iecond, we choose three types of filters, and I will explain how they works separately.
(1) Median filter

(the number represents the luminance of a pixel)

Median filter will compare a pixel and pixels around it, and arrange them in ascending order of
luminance, and then change the pixel in center into the median of the arrangement.
The number 3 in the code means the size to compare. Because median filter needs a center to
calculate, therefore the number can only be odds. The “noise” in the code is the picture that need
to denoise.
(2) Mean filter

Mean filter will compare a pixel and pixels around it, and then change its luminance into the mean
luminance of all pixels in the area you choose.
The (3,3) in the code means the size to compare, the first one is the width and the second one is
the height. The “noise” in the code is the picture that need to denoise.
(3) Gaussian filter
Gaussian filter is a little bit similar to mean filter, the difference between them is that the weights
of every pixel is the same, but the weights of gaussian filter is like the gaussian distribution, the
more it close to the center the higher the weight.
The (3,3) is the size to calculate. The number “0.8” is the standard deviation, the smaller it is the
bigger the weight of the center. The “noise” in the code is the picture that need to denoise.

Pepper noise after denoising

↑picture with noise ↑median filter ↑mean filter ↑gaussian filter

These are pictures with pepper noise after denoising. Due to the way median filter calculate, it can
erase the noise that extremely high or low, so it can erase the pepper noise perfectly. Basically,
mean filter and gaussian filter just blur the picture.

White noise after denoising

These are pictures with white noise after denoising. Because white noises are noises with all
luminance, therefore median filter can’t do its job well. In this case, the effect of mean filter and
gaussian filter is pretty good, and the result of gaussian filter is sharper than mean filter.

You might also like