EXP 3 Report
EXP 3 Report
Vikas P S - 19EC39050
Vanaja C Kodali - 18EC39002
EXPERIMENT-3
FREQUENCY DOMAIN
TRANSFORMATION
THEORY
Image filtering is useful for many applications, including smoothing,
sharpening, removing noise, and edge detection. A filter is defined by a
kernel, which is a small array applied to each pixel and its neighbours within
an image. In most applications, the centre of the kernel is aligned with the
current pixel, and is a square with an odd number (3, 5, 7, etc.) of elements in
each dimension. The process used to apply filters to an image is known as
convolution, and may be applied in either the spatial or frequency domain.
Within the frequency domain, convolution can be performed by multiplying
the FFT (Fast Fourier Transform) of the image by the FFT of the kernel, and
then transforming back into the spatial domain. The kernel is padded with
zero values to make it of the same size as the image before the forward FFT is
applied. Other method could be that filters are usually specified within the
frequency domain itself and then it is straightaway multiplied with image
pixels element by element and the IFFT is found to get the original image.
FUNCTIONS
Inverse fft is calculated using the same “find_img_fft” where the value of bool
inverse is set to “true”.
So, to find this we calculate the Fourier transform of even terms, let that
be Xe and Fourier transform of odd terms, let that be Xo then we can
calculate X(k) as 𝑋𝑒 + 𝑊𝑁 𝑘 ∗ 𝑋𝑜.
Omega:
Returns the omega value to be used in fft_rec as per which the
operation will be FFT or IFFT.
Find_img_fft:
Compute FFT/IFFT of all columns using the fft_rec function.
Compute FFT/IFFT of all the rows of the new matrix we got after computing
the FFT/IFFT of all the columns.
Takes input the image in complex number form and a Boolean value
“inverse” which if false, computes the FFT or else computes the IFFT.
Real_weight_conv:
To multiply real part with (-1)^(x+y)
OUTPUT RESULTS:
PART A
PART B:
DISCUSSIONS
First part, we computed the FFT of the image and we got the coefficients
then we converted 2D array into image and then plotted the Magnitude
Spectrum of FFT of the image.
For the phase spectrum, we computed the phases of each values using a
Formula tan(imag/real) and scaled them into the range [0,255] and plotted it.
Second part, we computed the FFT of the image, calculated its complex
conjugate, took out its IFFT and then got the result by multiplying the real
part with (-1). This resulted in the picture being rotated by 1800.
This happened so, as when complex conjugating the FFT components of the
image we made the imaginary parts of the components get mirrored w.r.t.
the real axis. And after getting the IFFT and negating the real part too, the
component turned out to be 1800 rotated from its original.