normalize_intensity#

VirtualBSEImage.normalize_intensity(num_std: int = 1, divide_by_square_root: bool = False, dtype_out: str | dtype | type | None = None, show_progressbar: bool | None = None, inplace: bool = True, lazy_output: bool | None = None) None | VirtualBSEImage | LazyVirtualBSEImage[source]#

Normalize image intensities to a mean of zero with a given standard deviation.

Parameters:
num_std

Number of standard deviations of the output intensities. Default is 1.

divide_by_square_root

Whether to divide output intensities by the square root of the signal dimension size. Default is False.

dtype_out

Data type of normalized images. If not given, the input images’ data type is used.

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

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

Notes

Data type should always be changed to floating point, e.g. float32 with change_dtype(), before normalizing the intensities.

Rescaling RGB images is not possible. Use RGB channel normalization when creating the image instead.

Examples

>>> import numpy as np
>>> import kikuchipy as kp
>>> s = kp.data.nickel_ebsd_small()
>>> np.mean(s.data)
146.0670987654321
>>> s.normalize_intensity(dtype_out=np.float32)
>>> np.mean(s.data)
2.6373216e-08