Skip to content

Latest commit

 

History

History
92 lines (70 loc) · 3.05 KB

feature_maps.rst

File metadata and controls

92 lines (70 loc) · 3.05 KB

Feature maps

This section details methods for extracting information from pattern intensities, called feature maps (for lack of a better description).

Image quality

The image quality metric Q presented by Krieger Lassen [Lassen1994] can be calculated for an ~kikuchipy.signals.EBSD object with ~kikuchipy.signals.EBSD.get_image_quality, or, for a single pattern (numpy.ndarray), with ~kikuchipy.pattern.get_image_quality. Following the notation in [Marquardt2017], it is given by

$$\begin{aligned} \begin{align} Q &= 1 - \frac{J}{J_{\mathrm{res}}w_{\mathrm{tot}}},\\\ J &= \sum_{h = -N/2}^{N/2} \sum_{k = -N/2}^{N/2} w(h, k) \left|\mathbf{q}\right|^2,\\\ J_{\mathrm{res}} &= \frac{1}{N^2} \sum_{h = -N/2}^{N/2} \sum_{k = -N/2}^{N/2} \left|\mathbf{q}\right|^2,\\\ w_{\mathrm{tot}} &= \sum_{h = -N/2}^{N/2} \sum_{k = -N/2}^{N/2} w(h, k). \end{align} \end{aligned}$$

The function w(h, k) is the Fast Fourier Transform (FFT) power spectrum of the EBSD pattern, and the vectors q are the frequency vectors with components (h, k). The sharper the Kikuchi bands, the greater the high frequency content of the power spectrum, and thus the closer Q will be to unity. To visualize parts of the computation, we compute the power spectrum of a pattern in an ~kikuchipy.signals.EBSD object s and the frequency vectors, shift the zero-frequency components to the centre, and plot them:

>>> import kikuchipy as kp
>>> import matplotlib.pyplot as plt
>>> import numpy as np

>>> p = s.inav[0, 0].data
>>> plt.figure()
>>> plt.imshow(p)
>>> plt.colorbar()

>>> p_fft = kp.pattern.fft(p, shift=True)
>>> plt.figure()
>>> plt.imshow(np.log(kp.pattern.fft_spectrum(p_fft)))
>>> plt.colorbar()

>>> q = kp.pattern.fft_frequency_vectors(shape=p.shape)
>>> plt.figure()
>>> plt.imshow(np.fft.fftshift(q))
>>> plt.colorbar()
A background corrected EBSD pattern (left), the logarithm of the shifted power spectrum w(h, k) of its FFT (middle), and the shifted frequency vectors \mathbf{q} (right).A background corrected EBSD pattern (left), the logarithm of the shifted power spectrum w(h, k) of its FFT (middle), and the shifted frequency vectors q (right).

If we don't want the EBSD patterns to be zero-mean normalized <normalize-intensity> before computing Q, we must pass normalized=False. Let's compute the image quality Q and plot it for a Nickel data set from [Anes2019]:

>>> iq = s.get_image_quality(normalize=True)  # Default
>>> plt.figure()
>>> plt.imshow(iq)
>>> plt.colorbar()
The image quality map of a Nickel data set from [Anes2019].The image quality map of a Nickel data set from [Anes2019].

If we want to use this map to navigate around in when plotting patterns, we can easily do that as explained in the visualizing patterns <visualizing_patterns> guide.