fft_filter#
- EBSD.fft_filter(transfer_function: ndarray | Window, function_domain: str, shift: bool = False, show_progressbar: bool | None = None, inplace: bool = True, lazy_output: bool | None = None) EBSD | LazyEBSD | None[source]#
Filter patterns 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_domainis"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 tofilter_functionis 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 whenfunction_domain="frequency".- show_progressbar
Whether to show a progressbar. If not given, the value of
hyperspy.api.preferences.General.show_progressbaris 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
Trueifinplace=False.
- Returns:
s_outFiltered signal, returned if
inplace=False. Whether it is lazy is determined fromlazy_output.
See also
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, ... )