0% found this document useful (0 votes)
6 views6 pages

Computer Vision HW 4

The document discusses Homework 4 on Fourier Transforms, focusing on the differences between the Discrete Fourier Transform (DFT) and the Discrete-Time Fourier Transform (DTFT) for spline and difference filters. It includes MATLAB code to evaluate and plot the magnitude and phase spectra of these filters, highlighting the effects of zero-padding on the frequency representation. Key observations include the low-pass nature of the spline filter and the high-pass characteristics of the difference filter, along with the impact of filter symmetry on their phase spectra.

Uploaded by

eng24310051
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)
6 views6 pages

Computer Vision HW 4

The document discusses Homework 4 on Fourier Transforms, focusing on the differences between the Discrete Fourier Transform (DFT) and the Discrete-Time Fourier Transform (DTFT) for spline and difference filters. It includes MATLAB code to evaluate and plot the magnitude and phase spectra of these filters, highlighting the effects of zero-padding on the frequency representation. Key observations include the low-pass nature of the spline filter and the high-pass characteristics of the difference filter, along with the impact of filter symmetry on their phase spectra.

Uploaded by

eng24310051
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/ 6

Computer Vision

Homework 4:
Fourier Transforms

Pesented by:

Zahraa muhaned mohammed faeq

MSc stg 1
Homework 4 – Fourier Transforms:
1.In section 2.5.1 of the lecture notes (lecture 4, page 5), the DTFT of the
spline filter V(ωk) is real symmetric. In comparison, the DFT of the same
spline filter V(m) is not purely real (also see section 2.5). If calculating the
DFT is “equivalent” to sampling the DTFT at discrete frequencies

ωk =2πm/K , m = 0, ... ,K – 1

why do they have different values at these frequencies?

The difference between the Discrete Fourier Transform (DFT) and the Discrete-
Time Fourier Transform (DTFT) values at the same frequencies is due to the
fundamental differences in their computation. The DTFT is derived from an
infinite-length signal, resulting in a continuous and symmetric frequency spectrum,
while the DFT is computed for a finite-length sequence, assuming periodicity. This
truncation introduces spectral leakage and aliasing, altering the frequency
representation and causing imaginary components to appear in the DFT, even
when the DTFT remains purely real. These effects highlight the impact of finite-
length sampling on Fourier analysis.

2.Similarly, in section 2.5.1 of the lecture notes (lecture 4, page 5), the DTFT
of the 1st order difference filter U(ωl) is imaginary anti-symmetric, while the
corresponding DFT U(n) is not purely imaginary.

Why?

The DTFT (Discrete-Time Fourier Transform) of the 1st order difference filter is
imaginary and anti-symmetric because the filter involves a differentiation
operation, which corresponds to a jωj\omega factor in the frequency domain,
resulting in an imaginary frequency response.

On the other hand, the DFT (Discrete Fourier Transform) is computed at discrete
frequency points. Due to the discrete nature and the finite number of points, the
DFT does not exhibit the same anti-symmetry or pure imaginary characteristics as
the DTFT. As a result, the DFT contains both real and imaginary components.
3. Use MATLAB to evaluate V(ωk) and U(ωl) given in the lecture notes at 512 different
points on the frequency range [-π, π), then plot the magnitude and phase spectra.

omega = linspace(-pi, pi, 512);


V = 4 * cos(omega / 2).^2;
U = -2j * sin(omega);
magnitude_V = abs(V);
phase_V = angle(V);

magnitude_U = abs(U);
phase_U = angle(U);
% Plot magnitude and phase spectra for V(ωk)
figure;
subplot(2, 1, 1);
plot(omega, magnitude_V);
title('Magnitude Spectrum of V(\omega_k)');
xlabel('\omega_k');
ylabel('Magnitude');

subplot(2, 1, 2);
plot(omega, phase_V);
title('Phase Spectrum of V(\omega_k)');
xlabel('\omega_k');
ylabel('Phase (radians)');

% Plot magnitude and phase spectra for U(ωl)


figure;
subplot(2, 1, 1);
plot(omega, magnitude_U);
title('Magnitude Spectrum of U(\omega_l)');
xlabel('\omega_l');
ylabel('Magnitude');

subplot(2, 1, 2);
plot(omega, phase_U);
title('Phase Spectrum of U(\omega_l)');
xlabel('\omega_l');
ylabel('Phase (radians)');
4.Use MATLAB to zero-pad each of the filters v(k) and u(l) to make 512 point-long vectors,
then calculate the DFT of each (or simply use, e.g., fft(v, 512) to zero-pad v(k)automatically
during DFT evaluation). Plot the magnitude and phase spectra on the frequency range [-π,
π). What do you notice?

% Define the original filters v(k) and u(l)


v = [1, 2, 1];
u = [-1, 0, 1];

% Zero-pad the filters to 512 points and compute their DFTs


N = 512; % Desired length after zero-padding
V = fft(v, N);
U = fft(u, N);

% Define the frequency range [-π, π)


omega = linspace(-pi, pi, N);

% Compute the magnitude and phase spectra


magnitude_V = abs(V);
phase_V = angle(V);
magnitude_U = abs(U);
phase_U = angle(U);

% Plot the magnitude and phase spectra for V


figure;
subplot(2, 1, 1);
plot(omega, fftshift(magnitude_V), 'b', 'LineWidth', 1.5);
title('Magnitude Spectrum of V(\omega_k) (Zero-padded to 512 points)');
xlabel('\omega_k');
ylabel('Magnitude');
grid on;

subplot(2, 1, 2);
plot(omega, fftshift(phase_V), 'r', 'LineWidth', 1.5);
title('Phase Spectrum of V(\omega_k) (Zero-padded to 512 points)');
xlabel('\omega_k');
ylabel('Phase (radians)');
grid on;

% Plot the magnitude and phase spectra for U


figure;
subplot(2, 1, 1);
plot(omega, fftshift(magnitude_U), 'b', 'LineWidth', 1.5);
title('Magnitude Spectrum of U(\omega_l) (Zero-padded to 512 points)');
xlabel('\omega_l');
ylabel('Magnitude');
grid on;

subplot(2, 1, 2);
plot(omega, fftshift(phase_U), 'r', 'LineWidth', 1.5);
title('Phase Spectrum of U(\omega_l) (Zero-padded to 512 points)');
xlabel('\omega_l');
ylabel('Phase (radians)');
grid on;
What do you notice?
1. For v(k)={1,2,1}:
o The magnitude spectrum shows a peak at ω=0 and decreases
symmetrically as we move away from zero frequency. This indicates
that v(k)is a low-pass filter.
o The phase spectrum is flat (close to zero) for all frequencies, which is
expected because v(k) is a symmetric (even) filter.
2. For u(l)={−1,0,1}:
o The magnitude spectrum shows peaks at high frequencies (ω=±π2),
indicating that u(l) is a high-pass filter.
o The phase spectrum alternates between −π2and π2, which is expected
because u(l) is an anti-symmetric (odd) filter.
3. General Observations:
o Zero-padding the filters to 512 points resulted in smoother and more
detailed frequency spectra.
o The symmetry of v(k)and the anti-symmetry of u(l) are clearly reflected in
their phase spectra.

You might also like