remove_static_background#

de_ebsd.index.preprocess.remove_static_background(patterns, static_bg, operation='subtract', device=None, dtype=torch.float32)[source]#

Remove the fixed detector/beam background from a stack of patterns.

Parameters:
patterns

Detector images, (H, W) / (N, H, W) / (rows, cols, H, W), numpy or torch. H, W are the detector shape.

static_bg

The static background image (H, W) (e.g. a kikuchipy signal’s static_background, or the scan mean), numpy or torch.

operation

"subtract" (default) or "divide".

device

Torch device to run on. None (default) keeps the patterns’ device ("cuda" recommended for a whole scan).

dtype

Working floating dtype (default float32).

Returns:
torch.Tensor

The cleaned patterns, same leading shape as the input, each rescaled to [0, 1] (indexing is invariant to the per-pattern affine scale).