Computer Vision HW 4
Computer Vision HW 4
Homework 4:
Fourier Transforms
Pesented by:
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
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.
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)');
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?
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;
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.