MultilevelFitter

class menpo.fitmultilevel.base.MultilevelFitter[source]

Bases: Fitter

Mixin that all MultilevelFitter objects must implement.

fit(image, initial_shape, max_iters=50, gt_shape=None, error_type='me_norm', verbose=False, view=False, **kwargs)[source]

Fits a single image.

Parameters:

image: :class:`menpo.image.masked.MaskedImage` :

The image to be fitted.

initial_shape: :class:`menpo.shape.PointCloud` :

The initial shape estimate from which the fitting procedure will start.

max_iters: int or list, optional :

The maximum number of iterations. If int, then this will be the overall maximum number of iterations for all the pyramidal levels. If list, then a maximum number of iterations is specified for each pyramidal level.

Default: 50

gt_shape: PointCloud :

The groundtruth shape of the image.

Default: None

error_type: ‘me_norm’, ‘me’ or ‘rmse’, optional. :

Specifies the way in which the error between the fitted and ground truth shapes is to be computed.

Default: ‘me_norm’

verbose: boolean, optional :

If True, it prints information related to the fitting results (such as: final error, convergence, ...).

Default: False

view: boolean, optional :

If True, the final fitting result will be visualized.

Default: False

**kwargs: :

Returns:

fitting_list: :map:`FittingResultList` :

A fitting result object.

get_parameters(shape)

Abstract method that gets the parameters.

obtain_shape_from_bb(bounding_box)[source]

Generates an initial shape given a bounding box detection.

Parameters:

bounding_box: (2, 2) ndarray :

The bounding box specified as:

np.array([[x_min, y_min], [x_max, y_max]])

Returns:

initial_shape: :class:`menpo.shape.PointCloud` :

The initial shape.

perturb_shape(gt_shape, noise_std=0.04, rotation=False)[source]

Generates an initial shape by adding gaussian noise to the perfect similarity alignment between the ground truth and reference_shape.

Parameters:

gt_shape: :class:`menpo.shape.PointCloud` :

The ground truth shape.

noise_std: float, optional :

The standard deviation of the gaussian noise used to produce the initial shape.

Default: 0.04

rotation: boolean, optional :

Specifies whether ground truth in-plane rotation is to be used to produce the initial shape.

Default: False

Returns:

initial_shape: :class:`menpo.shape.PointCloud` :

The initial shape.

algorithm

Returns the name of the fitter object.

downscale[source]

Returns the downscale factor used by the fitter.

feature_type[source]

Defines the feature computation function.

interpolator[source]

Returns the type of interpolator used by the fitter.

n_levels[source]

Returns the number of levels used by the fitter.

pyramid_on_features[source]

Returns True if the pyramid is computed on the feature image and False if it is computed on the original (intensities) image and features are extracted at each level.

reference_shape[source]

Returns the reference shape. Typically, the mean of the shape model.