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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM