I don't understand how to make frequency shift in fft2 or higher dimensions. Could anyone explain it, please?
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D %matplotlib inline 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)) # circle for i in range(numb_steps): for j in range(numb_steps): if x[i]**2+y[j]**2 > R: Z[i,j] = 0 else: Z[i,j] = 1 fig = plt.figure() ax = fig.gca(projection='3d') ax.plot_surface(X,Y,Z)
I only can get those plots
fig = plt.figure() ax = fig.gca(projection='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(range(len(x_ax)), np.round(x_ax)) plt.yticks(range(len(y_ax)), np.round(y_ax))
P.S. Yes, the ticks overlap is my problem as well
fftshift
and reducing the density of the tick marks are not about DSP though (?) $\endgroup$