slmsuite.holography.analysis.image_remove_field

image_remove_field(images, deviations=1, out=None)[source]

Zeros the field of a stack of images such that moment calculations will succeed. Consider, for example, a small spot on a field with strong background. Moment calculations in this situation will dominantly measure the moments of the background (i.e. the field). This function zeros the image below some threshold. This threshold is set to either the mean plus deviations standard deviations, computed uniquely for each image, or the median of each image if deviations is None. This is equivalent to background subtraction.

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 and image_count is the number of images. A single image is interpreted correctly as (1, h, w) even if (h, w) is passed, though the returned image remains shape (h, w) in that case.

  • deviations (int OR None) – Number of standard deviations above the mean to set the threshold. If None, uses the median as the threshold instead. Defaults to None.

  • out (numpy.ndarray or None) – The array to place the output data into. Should be the same shape as images. This function operates in-place if out equals images.

Returns

outimages or a copy of images, with each image background-subtracted.

Return type

numpy.ndarray