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?
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?
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;
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
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.
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
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
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
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
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.