Difference between revisions of "Converting Gaussian fit to Rayleigh resolution"
Steven Nagle (Talk | contribs) |
|||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
[[Category:20.309]] | [[Category:20.309]] | ||
+ | [[Category:Matlab]] | ||
[[Category:Optical Microscopy Lab]] | [[Category:Optical Microscopy Lab]] | ||
{{Template:20.309}} | {{Template:20.309}} | ||
− | [[Image:Gaussian versus Airy.png|right|thumb| | + | [[Image:Gaussian versus Airy.png|right|thumb|300px|Plot of an Airy function with Rayleigh resolution R=1, and a best-fit Gaussian function with σ=0.46869. ]] |
One method for measuring resolution is to fit a Gaussian function to an image of a very small source such as a fluorescent PSF microsphere. If the source is small enough, the image approximates the optical system's point spread function. As evidenced by the plot at right, the Gaussian function looks a lot like the central maximum of the Airy function. | One method for measuring resolution is to fit a Gaussian function to an image of a very small source such as a fluorescent PSF microsphere. If the source is small enough, the image approximates the optical system's point spread function. As evidenced by the plot at right, the Gaussian function looks a lot like the central maximum of the Airy function. | ||
− | The Rayleigh resolution of the Airy function shown is 1. The σ of the corresponding Gaussian is 0. | + | The Rayleigh resolution of the Airy function shown is 1. The σ of the corresponding Gaussian is 0.34493. Thus, to convert the Gaussian fit to Rayleigh resolution, multiply σ by 1/0.34493 = 2.8991. |
− | Note that | + | Note that some Gaussian fitting functions (such as <code>gaussfit</code>) return sqrt(2) * σ, instead of σ. In this case, multiply the value returned by 1/(sqrt(2) * 0.46869) = 1.50869. This occurs because the <code>gaussfit</code> function does not include the customary factor of two in its denominator. The equation implemented by <code>gaussfit</code> is: |
+ | |||
+ | <pre> | ||
+ | F = (a(1) * exp(-((X - a(5)) .^ 2 / (a(2) ^ 2) + (Y-a(6)) .^ 2 / (a(3) ^ 2))) + a(4)); | ||
+ | </pre> | ||
Here is the code that generated the plot: | Here is the code that generated the plot: | ||
− | < | + | <pre> |
xAxis = -10:0.01:10; | xAxis = -10:0.01:10; | ||
% generate an Airy disk profile with a normalized resolution R=1 | % generate an Airy disk profile with a normalized resolution R=1 | ||
firstBesselZero = 3.8317; | firstBesselZero = 3.8317; | ||
− | airyFunction = 2 * | + | airyFunction = (2 * besselj( 1, firstBesselZero * xAxis)./ (firstBesselZero * xAxis) ).^2; |
airyFunction(xAxis == 0) = 1; | airyFunction(xAxis == 0) = 1; | ||
Line 37: | Line 41: | ||
plot(xAxis, bestFitGaussian, 'r'); | plot(xAxis, bestFitGaussian, 'r'); | ||
title(texlabel(['Airy Function (R=1) versus Gaussian (sigma = ' num2str(sigma) ' FWHM = ' num2str(fwhm) ')'])); | title(texlabel(['Airy Function (R=1) versus Gaussian (sigma = ' num2str(sigma) ' FWHM = ' num2str(fwhm) ')'])); | ||
− | </ | + | </pre> |
{{Template:20.309 bottom}} | {{Template:20.309 bottom}} |
Latest revision as of 23:08, 22 February 2015
One method for measuring resolution is to fit a Gaussian function to an image of a very small source such as a fluorescent PSF microsphere. If the source is small enough, the image approximates the optical system's point spread function. As evidenced by the plot at right, the Gaussian function looks a lot like the central maximum of the Airy function.
The Rayleigh resolution of the Airy function shown is 1. The σ of the corresponding Gaussian is 0.34493. Thus, to convert the Gaussian fit to Rayleigh resolution, multiply σ by 1/0.34493 = 2.8991.
Note that some Gaussian fitting functions (such as gaussfit
) return sqrt(2) * σ, instead of σ. In this case, multiply the value returned by 1/(sqrt(2) * 0.46869) = 1.50869. This occurs because the gaussfit
function does not include the customary factor of two in its denominator. The equation implemented by gaussfit
is:
F = (a(1) * exp(-((X - a(5)) .^ 2 / (a(2) ^ 2) + (Y-a(6)) .^ 2 / (a(3) ^ 2))) + a(4));
Here is the code that generated the plot:
xAxis = -10:0.01:10; % generate an Airy disk profile with a normalized resolution R=1 firstBesselZero = 3.8317; airyFunction = (2 * besselj( 1, firstBesselZero * xAxis)./ (firstBesselZero * xAxis) ).^2; airyFunction(xAxis == 0) = 1; % use nonlinear regression to fit a Gaussian function to the Airy disk gaussianFunction = @(parameters, xdata) parameters(2) * exp( -xdata .^ 2 / (2 * parameters(1) .^ 2) ); bestFitGaussianParameters = nlinfit(xAxis, airyFunction, gaussianFunction, [1 1]); lsqcurvefit(gaussianFunction, [1 1], xAxis, airyFunction); bestFitGaussian = gaussianFunction(bestFitGaussianParameters, xAxis); sigma = bestFitGaussianParameters(1); sigmaToFwhmConversionFactor = 2 * sqrt(2*log(2)); fwhm = sigmaToFwhmConversionFactor * sigma; % plot the results plot(xAxis, airyFunction); hold on; plot(xAxis, bestFitGaussian, 'r'); title(texlabel(['Airy Function (R=1) versus Gaussian (sigma = ' num2str(sigma) ' FWHM = ' num2str(fwhm) ')']));