remove_static_background#

EBSD.remove_static_background(operation: str = 'subtract', static_bg: Optional[Union[ndarray, Array]] = None, scale_bg: bool = False, show_progressbar: Optional[bool] = None) None[source]#

Remove the static background inplace.

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.

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#