Challenge - 5 Problems
Fourier Image Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of 2D Fourier Transform Magnitude
What is the shape of the magnitude spectrum after applying a 2D Fourier transform on a 256x256 grayscale image using numpy's fft2 function?
Signal Processing
import numpy as np image = np.random.rand(256, 256) ft = np.fft.fft2(image) magnitude_spectrum = np.abs(ft) print(magnitude_spectrum.shape)
Attempts:
2 left
💡 Hint
The Fourier transform output has the same shape as the input image.
✗ Incorrect
The 2D Fourier transform using numpy's fft2 returns a complex array with the same shape as the input image. Taking the magnitude does not change the shape.
❓ data_output
intermediateResult of Centering the Fourier Spectrum
After computing the 2D Fourier transform of an image, which numpy function centers the zero-frequency component to the middle of the spectrum?
Signal Processing
import numpy as np image = np.random.rand(128, 128) ft = np.fft.fft2(image) centered_ft = np.fft.fftshift(ft) print(centered_ft[0,0])
Attempts:
2 left
💡 Hint
Centering moves the low frequencies to the center of the array.
✗ Incorrect
The function fftshift rearranges the Fourier transform output so that the zero-frequency component is at the center.
❓ visualization
advancedVisualizing the Magnitude Spectrum
Which code snippet correctly plots the log magnitude spectrum of a 2D Fourier transform of an image using matplotlib?
Signal Processing
import numpy as np import matplotlib.pyplot as plt image = np.random.rand(64, 64) ft = np.fft.fft2(image) ft_shifted = np.fft.fftshift(ft) magnitude_spectrum = np.log(np.abs(ft_shifted) + 1) plt.imshow(magnitude_spectrum, cmap='gray') plt.title('Magnitude Spectrum') plt.axis('off') plt.show()
Attempts:
2 left
💡 Hint
Log scale helps visualize wide range of values; fftshift centers the spectrum.
✗ Incorrect
Taking the log of the magnitude after fftshift centers the low frequencies and improves visualization contrast.
🔧 Debug
advancedIdentify the Error in Inverse 2D Fourier Transform
What error will occur when running this code to reconstruct an image from its Fourier transform?
Signal Processing
import numpy as np image = np.random.rand(32, 32) ft = np.fft.fft2(image) reconstructed = np.fft.ifft(ft) print(reconstructed.shape)
Attempts:
2 left
💡 Hint
Check the correct inverse function for 2D FFT and the data type of the output.
✗ Incorrect
np.fft.ifft is the 1D inverse FFT. For 2D, np.fft.ifft2 should be used. Using ifft returns a complex array of shape (32, 32), but the original image is real.
🚀 Application
expertEffect of Zeroing High Frequencies in Fourier Domain
What is the visual effect on an image after setting all Fourier coefficients with frequency magnitude above a threshold to zero and then applying the inverse 2D Fourier transform?
Attempts:
2 left
💡 Hint
High frequencies correspond to edges and fine details in images.
✗ Incorrect
Removing high-frequency components removes edges and fine details, causing the image to appear blurred.
