I have been experimenting a little bit with simple examples of the 2D DFT to get a better sense for it's interpretation.
For this purpose I have been using sinus gratings with the following code:
import matplotlib.pyplot as plt
x = np.arange(-500, 501, 1)
X, Y = np.meshgrid(x, x)
wavelength = 100
angle = np.pi/9
# use np.sign(np.sin(...)) for square wave grating instead of sine wave grating
grating = np.sin(
2*np.pi*(X*np.cos(angle) + Y*np.sin(angle)) / wavelength
)
plt.set_cmap("gray")
plt.subplot(131)
plt.imshow(grating)
plt.axis("off")
ft = np.fft.ifftshift(grating)
ft = np.fft.fft2(ft)
ft = np.fft.fftshift(ft)
plt.subplot(132)
plt.imshow(abs(ft))
plt.axis("off")
plt.xlim([480, 520])
plt.ylim([520, 480])
plt.show()
Now I get the following outcome:
So my question is why I am not getting further diagonal frequencies for the image with the rotated sine grating from the points on the diagonal line? It only has energiy along the horizontal and vertical axes. Where does this energy come from?
np.fft.ifftshift(grating)
? It will contain a horizontal and vertical line where the sinus wave doesn't match up. If you apply a window function to your image first, you will strongly reduce the horizontal and vertical streaks. $\endgroup$np.fft.ifftshift(grating)
first is, because without this line I get the same result just less blurrly in some cases. Do you know what the point of performing the window function here is? I am not familiar with their application. $\endgroup$