# 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 `EBSD`

object with
`get_image_quality()`

, or, for a single pattern
(`numpy.ndarray`

), with `get_image_quality()`

.
Following the notation in [Marquardt2017], it is given by

The function \(w(h, k)\) is the Fast Fourier Transform (FFT) power spectrum
of the EBSD pattern, and the vectors \(\mathbf{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 `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()
```

If we *don’t* want the EBSD patterns to be
zero-mean normalized 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()
```

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 guide.