NormalizedCrossCorrelationMean.grad#

NormalizedCrossCorrelationMean.grad()#

Calculate the normalized gradient of the cost function w.r.t. translation and rotation.

\[\begin{split}\nabla f = -\frac{1}{N|w||v|^3} \begin{bmatrix} (\sum_i w_i \nabla v(x_i))|v|^2 - (\sum_i v(x_i) \nabla v(x_i))(w \cdot v) \\ (\sum_i w_i (r_i \times \nabla v(x_i)))|v|^2 - (\sum_i v(x_i) (r_i \times \nabla v(x_i)))(w \cdot v) \end{bmatrix}\end{split}\]

where \(N\) is the number of points, \(w\) are weights, \(v\) are target values, \(x_i\) are rotated template positions, and \(r_i\) are positions relative to the template center.

Returns:
np.ndarray

Negative normalized gradient: [dx, dy, dz, dRx, dRy, dRz].