MATLAB中circshift函数是psf2otf函数的核心,在MATLAB中circshift函数的原理分析——psf2otf函数的核心直观解释了为什么需要循环移位。
MATLAB提出了psf2otf函数,先做循环移位,再计算离散傅里叶变换。如果有空域的卷积核,通过这个函数实现频域滤波。psf2otf默认的是周期延拓的边界扩展方式。

psf2otf函数
   % Circularly shift otf so that the "center" of the PSF is at the% (1,1) element of the array.psf    = circshift(psf,-floor(psfSize/2));% Compute the OTFotf = fftn(psf);
otf2psf函数
   psf = ifftn(otf);% Circularly shift psf so that (1,1) element is moved to the% appropriate center position.psf    = circshift(psf,floor(outSize/2));
循环移位将中心移到矩阵左上角的位置。
这是一个高斯核
移位前
 
 移位后
 
补零与psf2otf的区别
在频域滤波中默认的边界条件——补零与不补零(答作者问)中,说明了补零与psf2otf的区别。使用fft2是错误的。
 