core.mask Module

This module is for functions specific to mask or threshold an image basically to clean images

skbeam.core.mask.bad_to_nan_gen(images, bad)

Convert the images marked as “bad” in bad by their index in images into a np.nan array

Parameters
imagesiterable

Iterable of 2-D arrays

badlist

List of integer indices into the images parameter that mark those images as “bad”.

Yields
imgarray

if image is bad it will convert to np.nan array otherwise no change to the array

skbeam.core.mask.binned_outlier(img, r, alpha, bins, mask=None)

Generates a mask by identifying outlier pixels in bins and masks any pixels which have a value greater or less than alpha * std away from the mean

Parameters
img: 2darray

The image

r: 2darray

The array which maps pixels to bins

alpha: float or tuple or, 1darray

Then number of acceptable standard deviations, if tuple then we use a linear distribution of alphas from alpha[0] to alpha[1], if array then we just use that as the distribution of alphas

bins: list

The bin edges

mask: 1darray, bool

A starting flattened mask

Returns
2darray:

The mask

skbeam.core.mask.margin(img_shape, edge_size)

Mask the edge of an image

Parameters
img_shape: tuple

The shape of the image

edge_size: int

Number of pixels to mask from the edge

Returns
2darray:

The mask array, bad pixels are 0

skbeam.core.mask.threshold(images, threshold, mask=None)

This generator sets all pixels whose value is greater than threshold to 0 and yields the thresholded images out

Parameters
imagesiterable

Iterable of 2-D arrays

thresholdfloat

threshold value to remove the hot spots in the image

maskarray

array with values above the threshold marked as 0 and values below marked as 1. shape is (num_columns, num_rows) of the image, optional None

Yields
maskarray

array with values above the threshold marked as 0 and values below marked as 1. shape is (num_columns, num_rows) of the image