Matlab psf2otf与fft2函数的关系
psf2otf
Syntax
Description
fft2
Syntax
两者之间的官方解释也说了,psf2otf,其作用是将一个空间点扩散函数转换为频谱面的光学传递函数,执行的也是对PSF的FFT变换。真的只是这样吗?
大胆假设 小心求证
我们用matlab验证一下,首先我们生成PSF函数(其实就是空间卷积嘛,囧),随便来一个拉普拉斯模板吧,So easy。
如果使用psf2otf函数呢
这样两者就一样了。
实际上psf2otf中最后还舍弃由于浮点数运算带来的微小误差。
Matlab中psf2otf源码如下:
[psf, psfSize, outSize] = ParseInputs(varargin{:}); if ~all(psf(:)==0), % Pad the PSF to outSize padSize = outSize - psfSize; psf = padarray(psf, padSize, 'post'); % 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 OTF otf = fftn(psf); % Estimate the rough number of operations involved in the % computation of the FFT. nElem = prod(psfSize); nOps = 0; for k=1:ndims(psf) nffts = nElem/psfSize(k); nOps = nOps + psfSize(k)*log2(psfSize(k))*nffts; end % Discard the imaginary part of the psf if it's within roundoff error. if max(abs(imag(otf(:))))/max(abs(otf(:))) <= nOps*eps otf = real(otf); end else otf = zeros(outSize); end
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!