# ECC¶

class menpofit.lk.ECC[source]

Bases: Residual

Class for Enhanced Correlation Coefficient residual.

References

1

G.D. Evangelidis, and E.Z. Psarakis. “Parametric Image Alignment Using Enhanced Correlation Coefficient Maximization”, IEEE Transactions on Pattern Analysis and Machine Intelligence, 30(10): 1858-1865, 2008.

cost_closure()[source]

Method to compute the optimization cost.

Returns

cost (float) – The cost value.

classmethod gradient(image, forward=None)

Calculates the gradients of the given method.

If forward is provided, then the gradients are warped (as required in the forward additive algorithm)

Parameters
• image (menpo.image.Image) – The image to calculate the gradients for

• forward (tuple or None, optional) – A tuple containing the extra weights required for the function warp (which should be passed as a function handle), i.e. (menpo.image.Image, menpo.transform.AlignableTransform>). If None, then the optimization algorithm is assumed to be inverse.

hessian(sdi, sdi2=None)[source]

Calculates the Gauss-Newton approximation to the Hessian.

This is abstracted because some residuals expect the Hessian to be pre-processed. The Gauss-Newton approximation to the Hessian is defined as:

$\mathbf{J J^T}$
Parameters
• sdi ((N, n_params) ndarray) – The steepest descent images.

• sdi2 ((N, n_params) ndarray or None, optional) – The steepest descent images.

Returns

H ((n_params, n_params) ndarray) – The approximation to the Hessian

steepest_descent_images(image, dW_dp, forward=None)[source]

Calculates the standard steepest descent images.

Within the forward additive framework this is defined as

$\nabla I \frac{\partial W}{\partial p}$

The input image is vectorised (N-pixels) so that masked images can be handled.

Parameters
• image (menpo.image.Image) – The image to calculate the steepest descent images from, could be either the template or input image depending on which framework is used.

• dW_dp (ndarray) – The Jacobian of the warp.

• forward (tuple or None, optional) – A tuple containing the extra weights required for the function warp (which should be passed as a function handle), i.e. (menpo.image.Image, menpo.transform.AlignableTransform>). If None, then the optimization algorithm is assumed to be inverse.

Returns

VT_dW_dp ((N, n_params) ndarray) – The steepest descent images

steepest_descent_update(sdi, image, template)[source]

Calculates the steepest descent parameter updates.

These are defined, for the forward additive algorithm, as:

$\sum_x [ \nabla I \frac{\partial W}{\partial p} ]^T [ T(x) - I(W(x;p)) ]$
Parameters
• sdi ((N, n_params) ndarray) – The steepest descent images.

• image (menpo.image.Image) – Either the warped image or the template (depending on the framework)

• template (menpo.image.Image) – Either the warped image or the template (depending on the framework)

Returns

sd_delta_p ((n_params,) ndarray) – The steepest descent parameter updates.