MaskedCrossCorrelation#

class MaskedCrossCorrelation(target, template_coordinates, template_weights, template_mask_coordinates=None, target_mask=None, negate_score=True, return_gradient=False, interpolation_order=1, **kwargs)[source]#

Bases: _MatchCoordinatesToDensity

The Masked Cross-Correlation computes the similarity between target_weights and template_weights under respective masks. The score provides a measure of similarity even in the presence of missing or masked data.

The formula for the Masked Cross-Correlation is:

\[\text{numerator} = \text{dot}(\text{target_weights}, \text{template_weights}) - \frac{\text{sum}(\text{mask_target}) \times \text{sum}(\text{mask_template})} {\text{mask_overlap}}\]
\[\text{denominator1} = \text{sum}(\text{mask_target}^2) - \frac{\text{sum}(\text{mask_target})^2} {\text{mask_overlap}}\]
\[\text{denominator2} = \text{sum}(\text{mask_template}^2) - \frac{\text{sum}(\text{mask_template})^2} {\text{mask_overlap}}\]
\[\text{denominator} = \sqrt{\text{denominator1} \times \text{denominator2}}\]
\[\text{score} = \frac{\text{numerator}}{\text{denominator}} \text{ if denominator } \neq 0 \text{ else } 0\]

Where:

  • mask_target and mask_template are binary masks for the target_weights and template_weights respectively.

  • mask_overlap represents the number of overlapping non-zero elements in the masks.

Parameters:
targetNDArray

A d-dimensional target to match the template coordinate set to.

template_coordinatesNDArray

Template coordinate array with shape (d,n).

template_weightsNDArray

Template weight array with shape (n,).

template_mask_coordinatesNDArray, optional

Template mask coordinates with shape (d,n).

target_maskNDArray, optional

A d-dimensional mask to be applied to the target.

negate_scorebool, optional

Whether the final score should be multiplied by negative one. Default is True.

return_gradientbool, optional

Invoking __call_ returns a tuple of score and parameter gradient. Default is False.

**kwargsDict, optional

Keyword arguments propagated to downstream functions.

References

[1]

Masked FFT registration, Dirk Padfield, CVPR 2010 conference

Methods

MaskedCrossCorrelation.rotate_array(arr, ...)

MaskedCrossCorrelation.score(x)

Compute the matching score for the given transformation parameters.

MaskedCrossCorrelation.score_angles(x)

Computes the score after a given rotation.

MaskedCrossCorrelation.score_translation(x)

Computes the score after a given translation.