# MultiScaleNonParametricFitter¶

class menpofit.fitter.MultiScaleNonParametricFitter(scales, reference_shape, holistic_features, algorithms)[source]

Bases: object

Class for defining a multi-scale fitter for a non-parametric fitting method, i.e. a method that does not optimise over a parametric shape model.

Parameters
• scales (list of int or float) – The scale value of each scale. They must provided in ascending order, i.e. from lowest to highest scale.

• reference_shape (menpo.shape.PointCloud) – The reference shape that will be used to normalise the size of an input image so that the scale of its initial fitting shape matches the scale of the reference shape.

• holistic_features (list of closure) – The features that will be extracted from the input image at each scale. They must provided in ascending order, i.e. from lowest to highest scale.

• algorithms (list of class) – The list of algorithm objects that will perform the fitting per scale.

fit_from_bb(image, bounding_box, max_iters=20, gt_shape=None, return_costs=False, **kwargs)[source]

Fits the multi-scale fitter to an image given an initial bounding box.

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

• bounding_box (menpo.shape.PointDirectedGraph) – The initial bounding box from which the fitting procedure will start. Note that the bounding box is used in order to align the model’s reference shape.

• max_iters (int or list of int, optional) – The maximum number of iterations. If int, then it specifies the maximum number of iterations over all scales. If list of int, then specifies the maximum number of iterations per scale.

• gt_shape (menpo.shape.PointCloud, optional) – The ground truth shape associated to the image.

• 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.

• kwargs (dict, optional) – Additional keyword arguments that can be passed to specific implementations.

Returns

fitting_result (MultiScaleNonParametricIterativeResult or subclass) – The multi-scale fitting result containing the result of the fitting procedure.

fit_from_shape(image, initial_shape, max_iters=20, gt_shape=None, return_costs=False, **kwargs)[source]

Fits the multi-scale fitter to an image given an initial shape.

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

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

• max_iters (int or list of int, optional) – The maximum number of iterations. If int, then it specifies the maximum number of iterations over all scales. If list of int, then specifies the maximum number of iterations per scale.

• gt_shape (menpo.shape.PointCloud, optional) – The ground truth shape associated to the image.

• 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.

• kwargs (dict, optional) – Additional keyword arguments that can be passed to specific implementations.

Returns

fitting_result (MultiScaleNonParametricIterativeResult or subclass) – The multi-scale fitting result containing the result of the fitting procedure.

property holistic_features

The features that are extracted from the input image at each scale in ascending order, i.e. from lowest to highest scale.

Type

list of closure

property n_scales

Returns the number of scales.

Type

int

property reference_shape

The reference shape that is used to normalise the size of an input image so that the scale of its initial fitting shape matches the scale of this reference shape.

Type

menpo.shape.PointCloud

property scales

The scale value of each scale in ascending order, i.e. from lowest to highest scale.

Type

list of int or float