How we can calculculate the MTF from PSF?

I want to calculate the MTF from this PSF.

1 Comment

You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). If your main issue is with understanding the underlying concept, you may consider re-reading the material you teacher provided and ask them for further clarification.
In this case you forgot to ask an actual question in this post. However your message contained more information:
[the message below was sent around the time this question was posted]
Dear sir, I need your help on how to calculate the MTF from PSF in the MATLAB code. I am in a deadline condition. I am able to generate the PSF but am not able to generate the MTF. Please help me.
I need this type of MTF figure from my code
NUM= 1080;
pixel=6.4e-6;
aa=NUM*pixel/2;
lambda=0.532e-6;
y=(-NUM/2:1:NUM/2-1);
[x,y]=meshgrid(x,y);
Unrecognized function or variable 'x'.
M=ones(NUM,NUM);
M0=imread('c.bmp');
M0=double(M0);
M0=M0./max(max(M0));
M0=1-M0;
f= 0.18632;
z0=f;
h0=exp(1i*2*pi*z0*sqrt(1/(lambda)^2-(x/(NUM*pixel)).^2-(y/(NUM*pixel)).^2));
E0=ifft2(fftshift(fftshift(fft2(M.*exp(1i*HZP))).*h0));
psfHZP=abs(E0).^2;
[a,b]=max(max(psfHZP));
% Normalize the PSF
psfHZP_normalized = psfHZP / max(psfHZP(:));
% Display the normalized PSF
imagesc(psfHZP_normalized);
title('PSF HZP');
axis image;
%
[a1, b1]=max(max(psfHZP));
figure(10)
plot(psfHZP(:,b1));
title('HZP psf');
I am able to generate PSF, so how can I generate the MTF from this PSF .

Sign in to comment.

Answers (1)

Matt J
Matt J on 3 Aug 2025
Edited: Matt J on 3 Aug 2025
MTF=abs(fft2(PSF));
MTF=fftshift(MTF/MTF(1));

4 Comments

anjanjb
anjanjb on 28 Oct 2025
Edited: anjanjb on 28 Oct 2025
@Matt J Thank you so much for your reply. I want to plot MTF as a function of spatial frequency in 1 D , could you please help me ? I uploaded one sample i want to plot like this figure.
Matt J
Matt J on 28 Oct 2025
Edited: Matt J on 28 Oct 2025
Once you have the 2D MTF image, you can extract whatever 1D cross section you want, e.g. by indexing particular pixels in the image or by using improfile.
@Matt JCould you please help me generate a sample figure like the MTF for one sample from the code above? I would be very grateful for your kind support. Please, sir, help me.
@Matt JCould you please help me generate a sample figure like the MTF for one sample from the code above? I would be very grateful for your kind support. Please, sir, help me.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2025a

Tags

Asked:

on 3 Aug 2025

Commented:

on 4 Nov 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!