skued.mask_from_collection
- skued.mask_from_collection(images, px_thresh=(0, 30000.0), std_thresh=None)
Determine binary mask from a set of images. These images should represent identical measurements, e.g. a set of diffraction patterns before photoexcitation. Pixels are rejected on the following two criteria:
Pixels with a value above a certain threshold or below zero, for any image in the set, are considered dead;
Pixels with a cumulative standard deviation above a certain threshold are considered uncertain.
This function operates in constant-memory; it is therefore safe to use on a large collection of images (>10GB).
- Parameters:
images (iterable of ndarray) – These images should represent identical measurements.
images
can also be a generator.px_thresh (float or iterable, optional) – Pixels with a value outside of [
min(px_thresh)
,max(px_thresh)
] in any of the images inimages
are rejected. Ifpx_thresh
is a single float, it is assumed to be the maximal intensity, and no lower bound is enforced.std_thresh (int or float or None, optional) – Standard-deviation threshold. If the standard deviation of a pixel exceeds
std_thresh
, it is rejected. If None (default), a threshold is not enforced.
- Returns:
mask – Pixel mask. Pixels where
mask
is True are invalid.- Return type:
~numpy.ndarray, dtype bool
Notes
numpy.inf
can be used to have a lower pixel value bound but no upper bound. For example, to reject all negative pixels only, setpx_thresh = (0, numpy.inf)
.