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
ifinplace=False
.
- Returns:
s_out
Background corrected signal, returned if
inplace=False
. Whether it is lazy is determined fromlazy_output
.
See also
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 isNone
, this must be passed in thestatic_bg
parameter as anumpy
ordask
array.