masm: Manchester's Active Shape Model library

The masm library contains classes to implement a 2D Active Shape Model (ASM).
The ASM is an algorithm to match statistical shape models to image - or rather, to find a set of model points on an image with positions constrained by a statistical shape model.
It comes with a set of tools to build ASMs and to run them over sets of images (see the tools directory).

Requirements

The masm library depends on VXL, and in particular contrib/mul/msm - the statistical shape modelling library in Manchester's contributions to VXL.

The Basic Algorithm

Given a shape model instance defining the initial position of a set of model points on an image, the basic ASM algorithm iterates the following steps: The masm_model class contains the data required for an ASM. In particular:
To search an image with an ASM, you must create a masm_searcher object, which contains the current shape and pose parameters, as well as a set of msm_point_finder objects, which will do the search for each point.
There can be multiple masm_searcher objects, all using the same masm_model.

Example usage

To load in a model and use it to search an image:
  // Load in the ASM
  masm_model model;
  if (!vsl_quick_file_load(model,params.asm_path)) return 1;

  // Create a searcher (which will be initialised with the default pose)
  masm_searcher asm_searcher(model);

  // Load in an image
  vimt_image_2d_of image;
  vimt_load(image,image_path);
  if (image.image().size()==0) return 2;

  // Most models assume grey-scale images.  If RGB then convert to grey.
  if (image.image().nplanes()==3)
  {
    vil_image_view grey_image;
    vil_convert_planes_to_grey(image.image(),grey_image);
    image.image()=grey_image;
  }

  // Build an image pyramid from this
  vimt_gaussian_pyramid_builder_2d pyr_builder;

  vimt_image_pyramid image_pyr;
  pyr_builder.build(image_pyr,image);

  // Perform the search
  asm_searcher.search(image_pyr);

  // Get the resulting points
  msm_points final_points = asm_searcher.points();

Sequences of ASMs

It is often useful to use a sequence of ASMs to get faster and more robust results.
For instance, the first ASM may work at a low resolution with only a few shape parameters - this can get to the approximate solution quickly. Subsequent ASMs will then work at increasing resolution with more shape modes. This is a generalisation of the original "Multi-Resolution ASM" idea.
This is expressed in the library using the masm_model_series class, which stores a sequence of masm_model objects, and the associated masm_series_searcher which stores a set of masm_searcher objects, which will be applied in sequence.
The latter is used in almost exactly the same way as the single ASM:
  // Load in the ASM sequence
  masm_model_series model;
  if (!vsl_quick_file_load(model,params.asm_path)) return 1;

  // Create a searcher (which will be initialised with the default pose)
  masm_series_searcher asm_searcher(model);

  // Perform the search
  asm_searcher.search(image_pyr);

  // Get the resulting points
  msm_points final_points = asm_searcher.points();
For working examples of using the classes, see the programs in the tools and tests subdirectories.