Skip to main content
Solved

How to get MTF from PSF


Shun
  • Infrared
  • 10 replies

HI everyone

How do I use PSF to plot MTF in MATLAB?

The resulting plot may differ from the commonly used MTF plot.

 

How to plot the MTF with separate tangential (TAN) and sagittal (SAG) components?

 

Best answer by Jeff.Wilde

Hi Shun,

Yes, it’s fairly straightforward to use the API to extract the intensity PSF and then apply an FFT in Matlab to calculate the OTF.

Here’s what I find using the lens model you attached:

In this case I simply used the polychromatic PSF from OpticStudio, but it’s not much harder to extract the individual monochromatic PSF’s, then combine them in Matlab and take an FFT.

 

Regards,

Jeff

View original
Did this topic help you find an answer to your question?

8 replies

Brian.Catanzaro
Fully Spectral
Forum|alt.badge.img+4

Hi,

I strongly recommend you use the API to collect the MTF directly from your model.  It looks like you already know how to interface Matlab to OpticStudio.  This code snippet should help:

analysisCurrent = TheApplication.PrimarySystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.FftMtf);
settingsCurrent = analysisCurrent.Settings;

settingsCurrent.Field.SetFieldNumber(1);
settingsCurrent.Wavelength.SetWavelengthNumber(1);
settingsCurrent.SampleSize = ZOSAPI.Analysis.SampleSizes.S_128x128;
analysisCurrent.ApplyAndWaitForCompletion;

resultsCurrent = analysisCurrent.GetResults;
dataSeriesCurrent = resultsCurrent.GetDataSeries(0);
frequencySpatial = dataSeriesCurrent.XData.Data.double;
mtfNominal = dataSeriesCurrent.YData.Data.double;

analysisCurrent.Close;

r.frequency = frequencySpatial;
r.mtfNominal = mtfNominal;

 


Shun
  • Author
  • Infrared
  • 10 replies
  • May 19, 2023

Thanks for your help

But what I am currently doing is adding the PSFs of three different wavelengths and plotting the MTF to match Zemax. Is it possible to achieve this with the API?

 

 

-shun


Brian.Catanzaro
Fully Spectral
Forum|alt.badge.img+4

The MTF analysis in OpticStudio performs a weighted average of the MTFs at several wavelengths.  So you can configure your wavelengths in your OpticStudio model with equal or specific weighting to achieve the aggregate wavelength weighted MTF. 

Alternatively, you can get the (x3) MTFs at separate wavelengths and then combine then yourself outside of OpticStudio.

If you want to generate an MTF from PSFs, I recommend Goodman’s Introduction to Fourier Optics.  Following the math in that textbook leads you to a 2-D convolution that produces MTFs directly from PSFs.


Jeff.Wilde
Luminary
Forum|alt.badge.img+3
  • Luminary
  • 490 replies
  • Answer
  • May 20, 2023

Hi Shun,

Yes, it’s fairly straightforward to use the API to extract the intensity PSF and then apply an FFT in Matlab to calculate the OTF.

Here’s what I find using the lens model you attached:

In this case I simply used the polychromatic PSF from OpticStudio, but it’s not much harder to extract the individual monochromatic PSF’s, then combine them in Matlab and take an FFT.

 

Regards,

Jeff


Shun
  • Author
  • Infrared
  • 10 replies
  • May 27, 2023

 

hi Jeff

I'm sorry for taking so long to get back to you, and thank you for providing me with this method.

It was my fault for not describing my situation properly.

At filed2, I need to move the red and blue lights in the y-direction because the system has lateral color, and only by superimposing them can I obtain a similar  PSF.

Therefore, I need to import each psf.txt file into Excel, combine them with weights, and then import them into MATLAB to convert them into  MTF.

 

 

-shun


Shun
  • Author
  • Infrared
  • 10 replies
  • June 3, 2023

Hi Jeff

 

I made some slight modifications to the code you provided in order to achieve my goal. However, the resulting MTF image doesn't match yours. Is it possible that I made an error?

 

 

 

-Shun


Jeff.Wilde
Luminary
Forum|alt.badge.img+3
  • Luminary
  • 490 replies
  • June 5, 2023

Hi Shun,

Check your x & f vectors.  They should be consistent with the PSF sample spacing, which in your file dx = 1 um.  Otherwise, it looks okay.

Regards,

Jeff


Shun
  • Author
  • Infrared
  • 10 replies
  • June 6, 2023

Hi Jeff

I can confirm that x is correct, but I am unable to convert it into the correct f .

How do you define your f ?

Thanks for your help

 

-shun


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings