slmsuite.holography.analysis.image_positions#
- image_positions(images, grid=None, normalize=True, nansum=False)[source]#
Computes the two first order moments, equivalent to spot position \(\left<x\right>\) relative to image center, for a stack of images. Specifically, returns \(M_{10}\) and \(M_{01}\).
- Parameters:
images (numpy.ndarray) – A matrix in the style of the output of
take(), with shape(image_count, h, w), where(h, w)is the width and height of the 2D images andimage_countis the number of images. A single image is interpreted correctly as(1, h, w)even if(h, w)is passed.grid (float OR (float, float) OR (array_like, array_like) OR None) –
If
None(the default), the moment is reported in pixels of the image. However, the user may specify other units:Providing the scaling factor between pixels and the desired units as a
floator an anisotropic(float, float). This corresponds to the pixel’s \(\Delta x\), \(\Delta y\).Providing lists of length
wandhas a tuple as the grid dimension.Providing full grids of shape
(w, h)in each direction. Note that this case is the most general, and can lead to a rotated grid if a transformed grid is provided.
normalize (bool) – Whether to normalize
images. IfFalse, normalization is assumed to have been precomputed.nansum (bool) – Whether to use
numpy.nansum()in place ofnumpy.sum().
- Returns:
Stack of \(M_{10}\), \(M_{01}\) in an array of shape
(2, image_count).- Return type:
numpy.ndarray