How to start building models
This document summarises how to start building models from scratch, assuming
that all you have is a set of un-annotated images. Thanks to Tom Hangartner for
It is assumed that you have set up your path so that the various tools can
be run from the command line. (eg Under Windows,add the path for the programs
to the system under Control Panel>System> Advanced>Environment Vairables.
In the lower panel edit the path statement by adding the appropriate path
after a semicolon. The computer needs to be rebooted before this change takes
- Create a project directory (directory and file names must not have spaces), e.g. osteo
- Create three subdirectories for models (e.g. models),
point files (e.g. points) and images images.
- Copy templates of the following files to the models directory:
Replace xxx with an appropriate model name, e.g. forearm_distal.
- Edit the .smd file and add the model name (e.g. forearm_distal),the parts file name (e.g. forearm_distal)
and the various required directory names. Also add one pair of point/image
files under training_set. The image file is the first image to be analyzed.
- Edit the .aamprops file and add the model name (e.g. forearm_distal) to am_name
and aam_name and the directory name for the models.
- Create a dummy points file called "points/dummy.pts" as follows:
Annotating the First Image
It is assumed that you are running a shell or command prompt. Change directory
to the models directory you have created.
See also the details on the am_markup start program.
- Run the am_markup start program, invoking it with the name of the
SMD file (eg "am_markup start forearm_distal")
- Choose Add Curve and mark the first point contour.
Position a final point on the first point to close the contour.
- Choose Move One to adjust the location of individual points.
Use other tools as indicated.
- Create additional contours as required. If the desire is to build an
active shape model, the contours around the desired shapes are sufficient.
For an active appearance model, area around the shapes also needs to be
- Save the point contours by choosing "File>Save Points As" select the
above created points subdirectory and use the filename of the image
with the extension .pts.
- Save the contour descriptions by choosing File>Save Parts As;
select the above created models subdirectory and use the filename of
the model with the extension .parts, e.g. forearm_distal.parts.
- Exit am_markup.
Create a First Model
- Run the appearance model builder with the model name (e.g. "am_build_apm forearm_distal")
- Build the active appearance model by running "am_build_aam forearm_distal".
- The appearance model can be viewed with am_view_apm forearm_distal.
Annotating Further Images
- Create an SMD file (called, for instance data_todo.smd) containing
the list of all images you wish to work on. Set the
points files to "dummy.pts". This simply makes it easier to go through the
- Run am_markup again (e.g. am_markup forearm_distal).
The first image previously marked and its model in yellow are displayed in
- Use the "File->Load Image Set" to load in the list of files to annotate
- Enlarge the model-point sizes (green) by going to Props>Graphics Props and
press the + button to the right of Model Point Radius repeatedly.
- Use the "Props->Search Props" menu item to get the search panel.
- Press the "Move All" button on the bar to the left to go to a mode in
which the points can be moved (drag the cursor with left button) or
scaled/rotated (drag with right button). Move the points to roughly the
- Run the search using the "Search" button on the search panel.
- Edit the points (eg by going into "Move One" mode) until satisfied.
- Press the button "Save,Add,Update" or "Save,Add,Update,Next,Labels,Frame".
The latter button will automatically load the next image on the list.
- Go through the remaining images and exit am_markup.
The search will not work very well if trained with only a single image.
It is recommended that one rebuild the model after adding a few images.
To do this, exit am_markup and re-run the am_build_apm/am_build_aam tools.
The model SMD file will have been automatically updated to include the images
you have annotated (but it is worth checking it to make sure there aren't
duplicates or any problems). Delete the annotated files from the data_todo.smd
file. Then re-run am_markup and continue as above.
As more images are added the model becomes more flexible and better able
Please contact Tim with comments on these instructions.