Image processing 旋转1d FFT以获得2D FFT?

Image processing 旋转1d FFT以获得2D FFT?,image-processing,fft,idl-programming-language,Image Processing,Fft,Idl Programming Language,我有一张带有锐利边缘的模糊图像,我想用锐利边缘的轮廓来估计成像系统的点扩散函数(PSF)(假设它是对称的)。边的轮廓给了我“边扩展函数”(ESF),它的导数给了我“线扩展函数”(LSF)。我试图遵循我在一篇关于如何从LSF转换为PSF的旧论文中找到的以下指导: “如果我们对LSF进行一维傅里叶变换,并将所得曲线绕其纵轴旋转,则由此生成的曲面证明是PSF的二维傅里叶变换。因此,只需进行二维逆傅里叶变换即可获得PSF。” 我好像没法让它工作。类PSF函数(例如2D gaussian函数)的2D FF

我有一张带有锐利边缘的模糊图像,我想用锐利边缘的轮廓来估计成像系统的点扩散函数(PSF)(假设它是对称的)。边的轮廓给了我“边扩展函数”(ESF),它的导数给了我“线扩展函数”(LSF)。我试图遵循我在一篇关于如何从LSF转换为PSF的旧论文中找到的以下指导:

“如果我们对LSF进行一维傅里叶变换,并将所得曲线绕其纵轴旋转,则由此生成的曲面证明是PSF的二维傅里叶变换。因此,只需进行二维逆傅里叶变换即可获得PSF。”

我好像没法让它工作。类PSF函数(例如2D gaussian函数)的2D FFT具有许多可选的正值和负值,但如果旋转一维FFT,则会得到正值或负值的同心环,而逆变换看起来与点扩展函数完全不同。我是错过了一步还是误解了什么?任何帮助都将不胜感激!谢谢

编辑:以下是一些代码,显示了我尝试按照所述步骤操作的情况

;generate x array
x=findgen(1000)/999*50-25
;generate gaussian test function in 1D
;P[0] = peak value
;P[1] = centroid
;P[2] = sigma
;P[3] = base level
P=[1.0,0.0,4.0,0.0]
test1d=gaussian_1d(x,P)

;Take the FFT of the test function
fft1d=fft(test1d)
;create an array with the frequency values for the FFT array, following the conventions     used by IDL
;This piece of code to find freq is straight from IDL documentation:  http://www.exelisvis.com/docs/FFT.html
N=n_elements(fft1d)
T=x[1]-x[0]  ;T = sampling interval
fftx=(findgen((N-1)/2)+1)
is_N_even=(N MOD 2) EQ 0
if (is_N_even) then $
freq=[0.0,fftx,N/2,-N/2+fftx]/(N*T) $
else $
freq=[0.0,fftx,-(N/2+1)+fftx]/(N*T)

;Create a 1000x1000 array where each element holds the distance from the center
dim=1000 
center=[(dim-1)/2.0,(dim-1)/2.0]
xarray=cmreplicate(findgen(dim),dim)
yarray=transpose(cmreplicate(findgen(dim),dim))
rarray=sqrt((xarray-center[0])^2+(yarray-center[1])^2)
rarray=rarray/max(rarray)*max(freq) ;scale rarray so max value is equal to highest freq    in 1D FFT

;rotate the 1d FFT about zero to get a 2d array by interpolating the 1D function to the    frequency values in the 2d array
fft2d=rarray*0.0
fft2d(findgen(n_elements(rarray)))=interpol(fft1d,freq,rarray(findgen(n_elements(rarray))))

;Take the inverse fourier transform of the 2d array
psf=fft(fft2d,/inverse)
;shift the PSF to be centered in the image 
psf=shift(psf,500,500)
window,0,xsize=1000,ysize=1000
tvscl,abs(psf) ;visualize the absolute value of the result from the inverse 2d FFT

我不知道IDL,但我认为你这里的问题是,你需要对居中的信号进行FFT,在默认情况下,函数期望在数组的开始处有0个频率分量

在IDL中快速搜索执行此操作的正确方法表明您正在查找
CENTER
关键字

居中

设置此关键字可将零频率分量移到频谱中心。在正向上,产生的傅里叶变换将零频率分量移到阵列的中心。在相反方向上,假设输入为中心傅里叶变换,并且在执行逆变换之前将系数向后移动


如果不让FFT例程知道信号的中心位置,它似乎会移动N/2。在相反的域中,这是一个强相移,看起来好像值是正负交替的。

好的,看起来我已经解决了这个问题。主要的问题似乎是我需要使用FFT结果的绝对值,而不是默认情况下返回的复杂数组。使用/CENTER关键字也有助于使FFT结果的索引比IDL的默认值简单得多。以下是代码的工作版本:

;generate x array
x=findgen(1000)/999*50-25
;generate lorentzian test function in 1D
;P[0] = peak value
;P[1] = centroid
;P[2] = fwhm
;P[3] = base level
P=[1.0,0.0,2,0.0]
test1d=lorentzian_1d(x,P)

;Take the FFT of the test function
fft1d=abs(fft(test1d,/center))

;Create an array of frequencies corresponding to the FFT result
N=n_elements(fft1d)
T=x[1]-x[0]  ;T = sampling interval
freq=findgen(N)/(N*T)-N/(2*N*T)
;Create an array where each element holds the distance from the center
dim=1000 
center=[(dim-1)/2.0,(dim-1)/2.0]
xarray=cmreplicate(findgen(dim),dim)
yarray=transpose(cmreplicate(findgen(dim),dim))
rarray=sqrt((xarray-center[0])^2+(yarray-center[1])^2)
rarray=rarray/max(rarray)*max(freq) ;scale rarray so max value is equal to highest freq     in 1D FFT
;rotate the 1d FFT about zero to get a 2d array by interpolating the 1D function to the     frequency values in the 2d array
fft2d=rarray*0.0
fft2d(findgen(n_elements(rarray)))=interpol(fft1d,freq,rarray(findgen(n_elements(rarray))))

;Take the inverse fourier transform of the 2d array
psf=abs(fft(fft2d,/inverse,/center))
;shift the PSF to be centered in the image 
psf=shift(psf,dim/2.0,dim/2.0)
psf=psf/max(psf)
window,0,xsize=1000,ysize=1000
tvscl,real_part(psf) ;visualize the resulting PSF

;Test the performance by integrating the PSF in one dimension to recover the LSF
psftotal=total(psf,1)
plot,x*sqrt(2),psftotal/max(psftotal),thick=2,linestyle=2
oplot,x,test1d

你能发一些代码吗?你可能把径向对称的PSF和可分离的PSF混淆了。实际上,根据你的描述(2D高斯的2D FFT具有“许多可选的正负值”),我猜你在某处缺少FFT移位。二维高斯函数的FFT在真实信号中应该是完全正的,具有厄米对称性。同样,发布代码将有助于解决这个问题。