Contenido principal

centroid

R2026b

Compute centroid of point spread function

Since R2026b

Description

Add-On Required: This feature requires the Optical Design and Simulation Library for Image Processing Toolbox add-on.

centroidCoord = centroid(psfr) computes the centroid of each point spread function (PSF) intensity distribution in psfr. The function returns centroid coordinates for each PSF object and wavelength.

example

Examples

collapse all

Load the sample Double Gauss lens system using zmximport. Define a field point at an angle of 4 degrees along the x-axis, specify a wavelength of 587.56 nm, and calculate the geometric PSF.

opsys = zmximport("DoubleGaussLens.zmx");
fp = fieldPoint(Angles=[4 0]);
lambda = 587.56;
psfr = psf(opsys, FieldPoints=fp, Wavelengths=lambda, Method="Geometric");

Calculate the center of mass of the PSF intensity distribution using the centroid function.

centroidCoord = centroid(psfr)
centroidCoord = 
centroidCoord(:,:,1) =

  -3.0278e-07


centroidCoord(:,:,2) =

  -2.6128e-04

Load the sample Double Gauss lens system using zmximport. Define a field point at an angle of 4 degrees along the x-axis and specify an array of three wavelengths (486.13 nm, 587.56 nm, and 656.28 nm).

opsys = zmximport("DoubleGaussLens.zmx");
fp = fieldPoint(Angles=[4 0]);
lambdas = [486.13 587.56 656.28];

Compute the Huygens PSF across all specified wavelengths by setting the Method name-value argument to "Huygens". Use the centroid function to return the coordinate pairs for each wavelength result.

psfr = psf(opsys, FieldPoints=fp, Wavelengths=lambdas, Method="Huygens");
centroidCoord = centroid(psfr)
centroidCoord = 
centroidCoord(:,:,1) =

   1.0e-17 *

    0.2282   -0.1750    0.0738


centroidCoord(:,:,2) =

   1.0e-03 *

   -0.5762   -0.4819    0.1504

Input Arguments

collapse all

Point spread function results, specified as a GeometricPSF object, a HuygensPSF object, or an array of PSF result objects. Create these objects by using the psf object function.

When you specify an array of PSF result objects, all objects in the array must use the same wavelengths.

Output Arguments

collapse all

Centroid coordinates, returned as an M-by-N-by-2 numeric array. M is the number of PSF objects in psfr, and N is the number of wavelengths. The third dimension contains the centroid coordinates in the form [x y]. Units are in millimeters.

The coordinates are measured in the local PSF image coordinate system. If the CenterOnChiefRay property of the PSF object is true, the origin corresponds to the chief ray hit position for the reference wavelength. If CenterOnChiefRay is false, the origin corresponds to the center of the PSF image.

If a PSF object contains an empty Image value, the corresponding centroid coordinates are NaN.

Data Types: double

Algorithms

The centroid object function computes the centroid as the intensity-weighted center of the PSF image for each wavelength. Use the centroid to quantify shifts in the PSF caused by aberrations, wavelength-dependent effects, or alignment differences. The returned coordinates are in the local image-plane coordinate system, relative to the center of the PSF image.

Version History

Introduced in R2026b