我不明白如何在 fft2 或更高维度上进行频移。有人可以解释一下吗?
将 numpy 导入为 np
将 matplotlib.pyplot 导入为 plt
从 mpl_toolkits.mplot3d 导入 Axes3D
%matplotlib 内联
numb_steps = 100
x = np.linspace(-10, 10, numb_steps)
y = np.linspace(-10, 10, numb_steps)
X,Y = np.meshgrid(x,y)
R = 1
Z = np.zeros((100, 100))
# 圆圈
对于我在范围内(numb_steps):
对于范围内的 j(numb_steps):
如果 x[i]**2+y[j]**2 > R:
Z[i,j] = 0
别的:
Z[i,j] = 1
无花果 = plt.figure()
ax = fig.gca(投影='3d')
ax.plot_surface(X,Y,Z)
我只能得到那些情节
无花果 = plt.figure() ax = fig.gca(投影='3d') Z_fft = np.fft.fft2(Z) FreqCompRows = np.fft.fftfreq(Z.shape[0],d=2) FreqCompCols = np.fft.fftfreq(Z.shape[1],d=2) FreqCompRows = np.fft.fftshift(FreqCompRows) FreqCompCols = np.fft.fftshift(FreqCompCols) S,D = np.meshgrid(FreqCompRows, FreqCompCols) ax.plot_surface(S, D, np.abs(Z_fft))
plt.imshow(np.abs(Z_fft)) plt.xticks(范围(len(x_ax)), np.round(x_ax)) plt.yticks(范围(len(y_ax)),np.round(y_ax))
PS是的,刻度重叠也是我的问题



