NormalizedCrossCorrelationMetric#
- class kikuchipy.indexing.NormalizedCrossCorrelationMetric(n_experimental_patterns: int | None = None, n_dictionary_patterns: int | None = None, navigation_mask: ndarray | None = None, signal_mask: ndarray | None = None, dtype: str | dtype | type = 'float32', rechunk: bool = False)[source]#
Bases:
SimilarityMetric
Similarity metric implementing the normalized cross-correlation, or Pearson Correlation Coefficient [Gonzalez and Woods, 2017].
The metric is defined as
\[r = \frac {\sum^n_{i=1}(x_i - \bar{x})(y_i - \bar{y})} { \sqrt{\sum ^n _{i=1}(x_i - \bar{x})^2} \sqrt{\sum ^n _{i=1}(y_i - \bar{y})^2} },\]where experimental patterns \(x\) and simulated patterns \(y\) are centered by subtracting out the mean of each pattern, and the sum of cross-products of the centered patterns is accumulated. The denominator adjusts the scales of the patterns to have equal units.
Equivalent results are obtained with
dask.array.tensordot()
withaxes=([2, 3], [1, 2]))
for 4D and 3D experimental and simulated data sets, respectively.See
SimilarityMetric
for the description of the initialization parameters and the list of attributes.Attributes
Methods
Match all experimental patterns to all dictionary patterns and return their similarities.
Prepare dictionary patterns before matching to experimental patterns in
match()
.Prepare experimental patterns before matching to dictionary patterns in
match()
.