# Building a Shape Model

Shape models are used both in Active Shape Models and as part of an Appearance Model.

### Parameters defining the Shape Model

A number of parameters in the Shape Model Data file describe the shape model.

#### Aligner

The method used to align the shapes (thus defining what global transformations
the shape is invariant to) can be defined using the `shape_aligner:` field.

Options include

- align_cog_2d : Translation only
- align_zoom_2d : Translation and scaling
- align_similar_2d : Translation,rotation and scaling
- align_affine_2d : Full 2D affine alignment

#### Adding extra flexibility

The `shape_variant_maker` field can be used if you wish to add extra
variability to the shape model, essentially by generating additional artificial
variants on the mean shape.

Typically this will be none (indicated as a "-"):

shape_variant_maker: -

However, smooth variants
on the mean shape can be generated using low frequency sinusoidal functions:

shape_variant_maker: trig_shape_maker_2d { n_freq: 3 max_disp: -0.1 }

If this latter is selected, then the parameters of the shape maker must be
defined in the braces after the name. In the above 3 frequencies are defined,
with an amplitude of 0.1 * [mean shape size]. If the max_disp field
is -ive, it is taken as a proportion of the mean shape size, if positive,
then as an absolute magnitude.

#### Modes and Levels

The number of modes of the shape model is defined by the `shape_modes:` field.

shape_modes: { min: 0 max: 999 prop: 0.95 }

The number will be chosen to explain proportion of the variance, constrained by min and max.
A multi-resolution model will be built, with levels defined by the following fields:

min_level: 0
max_level: 2

## Viewing the Model

You can view the model using the am_view_apm tool.

You can view the shape model alone using the am_view_shape_model tool.