Shape

class menpo.shape.base.Shape[source]

Bases: Vectorizable, Landmarkable, Transformable, Viewable

Abstract representation of shape. Shapes are Transformable, Vectorizable, Landmarkable and Viewable. This base class handles transforming landmarks when the shape is transformed. Therefore, implementations of Shape have to implement the abstract _transform_self_inplace() method that handles transforming the Shape itself.

as_vector(**kwargs)

Returns a flattened representation of the object as a single vector.

Returns:

vector : (N,) ndarray

The core representation of the object, flattened into a single vector. Note that this is always a view back on to the original object, but is not writable.

from_vector(vector)

Build a new instance of the object from it’s vectorized state.

self is used to fill out the missing state required to rebuild a full object from it’s standardized flattened state. This is the default implementation, which is which is a deepcopy of the object followed by a call to from_vector_inplace(). This method can be overridden for a performance benefit if desired.

Parameters:

vector : (n_parameters,) ndarray

Flattened representation of the object.

Returns:

object : type(self)

An new instance of this class.

from_vector_inplace(vector)

Update the state of this object from a vector form.

Parameters:

vector : (n_parameters,) ndarray

Flattened representation of this object

view(**kwargs)

View the object using the default rendering engine figure handling. For example, the default behaviour for Matplotlib is that all draw commands are applied to the same figure object.

Parameters:

kwargs : dict

Passed through to specific rendering engine.

Returns:

viewer : Renderer

The renderer instantiated.

view_new(**kwargs)

View the object on a new figure.

Parameters:

kwargs : dict

Passed through to specific rendering engine.

Returns:

viewer : Renderer

The renderer instantiated.

view_on(figure_id, **kwargs)

View the object on a a specific figure specified by the given id.

Parameters:

figure_id : object

A unique identifier for a figure.

kwargs : dict

Passed through to specific rendering engine.

Returns:

viewer : Renderer

The renderer instantiated.

n_landmark_groups

The number of landmark groups on this object.

Type:int
n_parameters

The length of the vector that this object produces.

Type:int