fft_filter#

EBSD.fft_filter(transfer_function: Union[ndarray, Window], function_domain: str, shift: bool = False, show_progressbar: Optional[bool] = None) None[source]#

Filter an EBSD scan inplace in the frequency domain.

Patterns are transformed via the Fast Fourier Transform (FFT) to the frequency domain, where their spectrum is multiplied by the transfer_function, and the filtered spectrum is subsequently transformed to the spatial domain via the inverse FFT (IFFT). Filtered patterns are rescaled to input data type range.

Note that if function_domain is "spatial", only real valued FFT and IFFT is used.

Parameters:
transfer_function

Filter to apply to patterns. This can either be a transfer function in the frequency domain of pattern shape or a kernel in the spatial domain. What is passed is determined from function_domain.

function_domain

Options are "frequency" and "spatial", indicating, respectively, whether the filter function passed to filter_function is a transfer function in the frequency domain or a kernel in the spatial domain.

shift

Whether to shift the zero-frequency component to the center. Default is False. This is only used when function_domain="frequency".

show_progressbar

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

Examples

Applying a Gaussian low pass filter with a cutoff frequency of 20:

>>> import kikuchipy as kp
>>> s = kp.data.nickel_ebsd_small()
>>> pattern_shape = s.axes_manager.signal_shape[::-1]
>>> w = kp.filters.Window(
...     "lowpass", cutoff=20, shape=pattern_shape
... )
>>> s.fft_filter(
...     transfer_function=w,
...     function_domain="frequency",
...     shift=True,
... )