我有一个带有锐边的模糊图像,我想使用该锐边的轮廓来估计成像系统的点扩散函数(PSF)(假设它是对称的)。边缘的轮廓给出了“边缘扩散函数”(ESF),并且它的导数给出了“线扩散函数”(LSF)。我试图遵循我在一篇关于如何从LSF转换为PSF的旧论文中找到的这些指示:
“如果我们形成LSF的一维傅里叶变换并将得到的曲线绕其垂直轴旋转,那么这样生成的曲面就证明是PSF的二维傅立叶变换。因此,仅需要采用二维逆傅立叶变换以获得PSF“
我似乎无法让这个工作。类PSF函数的2D FFT(例如2d高斯函数)具有许多替代的正负值,但是如果我旋转1D 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
答案 0 :(得分:1)
我不知道IDL,但我认为你的问题在于你正在对中心信号进行FFT,其中默认情况下该函数需要数组开头的0频率分量。
快速搜索在IDL中执行此操作的正确方法表示CENTER
关键字正是您要查找的内容。
CENTER
设置此关键字可将零频率分量移至频谱中心。在正向方向上,所得到的傅立叶变换具有移位到阵列中心的零频率分量。在反方向上,假设输入是中心傅里叶变换,并且在执行逆变换之前系数被移回。
不让FFT例程知道信号中心的位置,它似乎会移动N / 2。在逆向域中,这是一个强烈的相移,看起来好像值正交替变为负值。
答案 1 :(得分:0)
好的,看起来我已经解决了这个问题。主要问题似乎是我需要使用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