- class kikuchipy.filters.Window(window: None | str | ndarray | Array = None, shape: Sequence[int] | None = None, **kwargs)#
A window/kernel/mask/filter of a given shape with some values.
This class is a subclass of
numpy.ndarraywith some additional convenience methods.
It can be used to create a transfer function for filtering in the frequency domain, create an averaging window for averaging patterns with their nearest neighbours, and so on.
Window type to create. Available types are listed in
"gaussian", in addition to a
"circular"window (default) filled with ones in which corner data are set to zero, a
"highpass"FFT windows. A window element is considered to be in a corner if its radial distance to the origin (window center) is shorter or equal to the half width of the windows’s longest axis. A 1D or 2D
dask.array.Arraycan also be passed.
Shape of the window. Not used if a custom window is passed to
window. This can be either 1D or 2D, and can be asymmetrical. Default is
Required keyword arguments passed to the window type.
>>> import numpy as np >>> import kikuchipy as kp
The following passed parameters are the default
>>> w = kp.filters.Window(window="circular", shape=(3, 3)) >>> w Window (3, 3) circular [[0. 1. 0.] [1. 1. 1.] [0. 1. 0.]]
A window can be made circular
>>> w = kp.filters.Window(window="rectangular") >>> w Window (3, 3) rectangular [[1. 1. 1.] [1. 1. 1.] [1. 1. 1.]] >>> w.make_circular() >>> w Window (3, 3) circular [[0. 1. 0.] [1. 1. 1.] [0. 1. 0.]]
A custom window can be created
>>> w = kp.filters.Window(np.arange(6).reshape(3, 2)) >>> w Window (3, 2) custom [[0 1] [2 3] [4 5]]
To create a Gaussian window with a standard deviation of 2, obtained from
>>> w = kp.filters.Window(window="gaussian", std=2) >>> w Window (3, 3) gaussian [[0.7788 0.8825 0.7788] [0.8825 1. 0.8825] [0.7788 0.8825 0.7788]]
Return whether the window is circular.
Return the radial distance for each pixel to the window origin.
Return whether the window is in a valid state.
Return the maximum number of nearest neighbours in each navigation axis to the origin.
Return the name of the window.
Return the window origin.
Make the window circular.
Window.plot([grid, show_values, textcolors, ...])
Plot window values with indices relative to the origin.
Return whether the window shape is compatible with another shape.