prtools — Utility functions for image-based phase retrieval#
Version: 1.2.1
Useful links: Source Repository | Issue Tracker | Releases
The prtools
library provides functionality and tools that may be
useful when performing image-based phase retrieval including:
Image processing, reduction, and analysis
Creating, fitting, and removing Zernike polynomials
Drawing various shapes in arrays
Computing statistics and optical simulation parameters
Install prtools
with pip:
pip install prtools
Array manipulation#
Compute array centroid location. |
|
Zero-pad an array. |
|
Extract a contiguous subarray from a larger array. |
|
Find bounding row and column indices of data within an array. |
|
Rebin an image by an integer factor. |
|
Rescale an image by interpolation. |
|
Fix masked entries in a 2-dimensional array via median filtering. |
|
Normalizie the power in an array. |
|
Shift an array via FFT. |
|
Compute the subpixel image translation to register the input array to a reference array. |
Array metrics#
Compute the root-mean-square of the nonzero entries |
|
Compute peak-to-valley or max(a) - min(a) |
|
Compute the average radial profile of the input |
|
Compute the encircled energy diameter for a given energy fraction. |
Fourier transforms#
Miscellaneous#
Calculate a point spread function using far-field diffraction. |
|
Compute the output plane sampling that is Nyquist sampled for intensity. |
|
Compute the minimum pupil plane sampling to satisfy given constraints. |
|
Compute FFT pad shape to satisfy requested sampling condition |
|
Compute the peak-to-valley defocus imparted by a given translation along the optical axis |
|
Attempt to find phase wrapping using gradient edge detection while automatically ignoring large gradients at mask edges. |
Shapes#
Draw a circle |
|
Draw a rectangle |
|
Draw a hexagon |
|
Draw a segmented aperture made up of hexagonal segments |
|
Draw a spider |
|
Generate a 2D Gaussian function. |
|
Generate a 2D sine function. |
|
Generate a 2D waffle function. |
|
Generate a standard mesh. |
Note
The shape functions support both Cartesian (xy
) and matrix (ij
)
indexing conventions for specifying the shift parameter via the
indexing
parameter. The default is matrix (indexing='ij'
) for
all functions.
Sparse matrices#
Sparse coordinate list (COO) index |
|
Create a sparse array from a dense matrix |
|
Create a dense matrix from a sparse array |
|
Create a sparse coordinate list (COO) index object from a mask. |
|
Create a mask from a sparse coordinate list (COO) index. |
Zernike polynomials#
Compute the circular Zernike polynomial for a given mask. |
|
Fit a Zernike basis set to an OPD. |
|
Fit and remove a Zernike basis set from an OPD. |
|
Create an OPD based on the supplied Zernike coefficients. |
|
Compute a Zernike basis set for a given mask. |
|
Compute the Zernike coordinate system for a given mask. |