remove_static_background#

EBSD.remove_static_background(operation: str = 'subtract', static_bg: ndarray | Array | None = None, scale_bg: bool = False, show_progressbar: bool | None = None, inplace: bool = True, lazy_output: bool | None = None) EBSD | LazyEBSD | None[source]#

Remove the static background.

The removal is performed by subtracting or dividing by a static background pattern. Resulting pattern intensities are rescaled loosing relative intensities and stretched to fill the available grey levels in the patterns’ data type range.

Parameters:
operation

Whether to "subtract" (default) or "divide" by the static background pattern.

static_bg

Static background pattern. If not given, the background is obtained from the EBSD.static_background property.

scale_bg

Whether to scale the static background pattern to each individual pattern’s data range before removal. Default is False.

show_progressbar

Whether to show a progressbar. If not given, the value of hyperspy.api.preferences.General.show_progressbar is used.

inplace

Whether to operate on the current signal or return a new one. Default is True.

lazy_output

Whether the returned signal is lazy. If not given this follows from the current signal. Can only be True if inplace=False.

Returns:
s_out

Background corrected signal, returned if inplace=False. Whether it is lazy is determined from lazy_output.

Examples

It is assumed that a static background pattern of the same shape and data type (e.g. 8-bit unsigned integer, uint8) as the patterns is available in signal metadata:

>>> import kikuchipy as kp
>>> s = kp.data.nickel_ebsd_small()
>>> s.static_background
array([[84, 87, 90, ..., 27, 29, 30],
       [87, 90, 93, ..., 27, 28, 30],
       [92, 94, 97, ..., 39, 28, 29],
       ...,
       [80, 82, 84, ..., 36, 30, 26],
       [79, 80, 82, ..., 28, 26, 26],
       [76, 78, 80, ..., 26, 26, 25]], dtype=uint8)

The static background can be removed by subtracting or dividing this background from each pattern:

>>> s.remove_static_background(operation="divide")

If the static_background property is None, this must be passed in the static_bg parameter as a numpy or dask array.

Examples using EBSD.remove_static_background#

Pattern binning

Pattern binning

Static background correction

Static background correction

Dynamic background correction

Dynamic background correction

Neighbour pattern averaging

Neighbour pattern averaging

Crop navigation axes

Crop navigation axes

Crop signal axes

Crop signal axes

Extract patterns from a grid

Extract patterns from a grid