在我的2D傅里叶变换中,我有两个可选的正值和负值,我的图像是中心对称的(检查虚部,它等于零),所有的值都是正值
我不明白为什么我在FFT的实部有这些可选的正值和负值,我还指出,当我的图像不是中心对称时,我的虚部也有同样的问题(对于这个简单而简短的示例,这里的情况并非如此):
图像
FFT的实部放大
FFT的实部
实部的模量
下面是能够重现这项工作和我的问题的代码:
import numpy as np
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
from numpy.fft import fft2, ifft2, fftshift, ifftshift
def imaging_model(rho,I_profile, R_image, **kwargs):
method = kwargs.get('method', 'linear')
# image_TOT = []
xv = np.linspace(-R_image, R_image, len(rho)*2, endpoint=False) # Taille de la fenetre
# WARNING
if np.sqrt(R_image**2+R_image**2)>=max(rho):
print('WARNING points out of the computation range are needed to display the image, they are set to 0')
interpol_index = interp1d(rho, I_profile,kind=method)
X, Y = np.meshgrid(xv, xv)
profilegrid2 = np.zeros(X.shape, float)
current_radius = np.sqrt(X**2 + Y**2)
cond=np.logical_and(current_radius<=max(rho),current_radius>=min(rho)) # Min et max des données
profilegrid2[cond] = interpol_index(current_radius[cond])
# image_TOT.append(profilegrid2)
# plt.figure()
# plt.imshow(profilegrid2,extent=[-R_image,R_image,-R_image,R_image])
# plt.xlabel(r'$\alpha$ [mas]')
# plt.ylabel(r'$\delta$ [mas]')
# plt.colorbar(label=r'Intensity Ratio [I_tot/I_star]')
# plt.title('Image of the model at %.2f µm'%wavel_UD)
return xv, profilegrid2
def FFT(image):
FFT_image = fftshift(fft2(image))
return FFT_image
test_x = np.linspace(0,270,256)
test_y = np.ones(256)
test_y[test_x>10] = 0
image_test_x, image_test = imaging_model(test_x, test_y, max(test_x))
FFT_image = FFT(image_test)
plt.figure()
plt.imshow(image_test)
plt.figure()
plt.imshow(np.real(FFT_image))
plt.figure()
plt.imshow(np.abs(np.real(FFT_image)))
plt.figure()
plt.imshow(np.imag(FFT_image))
问题来自FFT定义:
更正的是:
相关问题 更多 >
编程相关推荐