ForwardCompositional

class menpofit.lk.ForwardCompositional(template, transform, residual, eps=1e-10)[source]

Bases: LucasKanade

Forward Compositional (FC) Lucas-Kanade algorithm

Parameters
  • template (menpo.image.Image or subclass) – The image template.

  • transform (subclass of DP and DX, optional) – A differential affine transform object, e.g. DifferentiableAlignmentAffine.

  • residual (class subclass, optional) –

    The residual that will get applied. All possible residuals are:

    Class

    Description

    SSD

    Sum of Squared Differences

    FourierSSD

    Sum of Squared Differences on Fourier domain

    ECC

    Enhanced Correlation Coefficient

    GradientImages

    Image Gradient

    GradientCorrelation

    Gradient Correlation

  • eps (float, optional) – Value for checking the convergence of the optimization.

run(image, initial_shape, gt_shape=None, max_iters=20, return_costs=False)[source]

Execute the optimization algorithm.

Parameters
  • image (menpo.image.Image) – The input test image.

  • initial_shape (menpo.shape.PointCloud) – The initial shape from which the optimization will start.

  • gt_shape (menpo.shape.PointCloud or None, optional) – The ground truth shape of the image. It is only needed in order to get passed in the optimization result object, which has the ability to compute the fitting error.

  • max_iters (int, optional) – The maximum number of iterations. Note that the algorithm may converge, and thus stop, earlier.

  • return_costs (bool, optional) – If True, then the cost function values will be computed during the fitting procedure. Then these cost values will be assigned to the returned fitting_result. Note that the costs computation increases the computational cost of the fitting. The additional computation cost depends on the fitting method. Only use this option for research purposes.

Returns

fitting_result (LucasKanadeAlgorithmResult) – The parametric iterative fitting result.

warped_images(image, shapes)

Given an input test image and a list of shapes, it warps the image into the shapes. This is useful for generating the warped images of a fitting procedure stored within a LucasKanadeResult.

Parameters
  • image (menpo.image.Image or subclass) – The input image to be warped.

  • shapes (list of menpo.shape.PointCloud) – The list of shapes in which the image will be warped. The shapes are obtained during the iterations of a fitting procedure.

Returns

warped_images (list of menpo.image.MaskedImage or ndarray) – The warped images.