UoMASM Tutorial 2: Building an ASM from scratch
An example of building and using Active Shape Models, assuming we start with a set of unlabelled images.
If you have annotated images, see Tutorial 1.
Files and Directory structure
We will assume the following directory structure:
- images : Contains images
- points : Directory for associated points files
- models : Directory parameter files and models
During the annotation process, for every image, images/imageX.jpg, we will create an associated points file, points/imageX.pts.
Annotating the first image
First define the points of interest and any connecting curves using the qmsm_markup_tool.
This allows you to load in an image, add points and curves, then save the points and associated msm_curves file.
Use your skill and judgement to place a suitable number of points at key landmarks and around the boundaries that you wish to model.
Save the points to the points directory, with a name derived from the image name (e.g. image00.pts) and the curves to the models directory (e.g. to models/my_model.crvs).
If you wish, at this point you can follow the steps in Tutoral 1 to build a basic ASM from this single example. Note that this model will have no shape modes, and
will only allow pose transformations when being fit to a new image. However, this can be good
enough to start further annotation. If so, skip the next section and start building your model.
Since it is a good idea to build the first model from a few examples, in order to learn a bit of shape variation, you can use the first example as a template for annotating some more images, before building a model.
Purely manual annotation of further images
You can use the qmsm_shape_editor tool to modify the
points to match subsequent images.
The simplest approach is to run the tool from the models directory using something like:
qmsm_shape_editor -i ../images/image01.jpg -c my_model.crvs -p ../points/image00.pts
This loads the points from the first image and displays them over the second image. You can then
move them around as necessary. When happy, save them to ../points/image01.pts.
Load in the next image and repeat.
Using image lists
To simplify the process of stepping through the images, and to reduce the risk of mis-naming the points, you can create an image list file, in the following format:
image_dir: ../images/
points_dir: ../points/
images: {
image00.pts : image00.jpg
image01.pts : image01.jpg
image02.pts : image02.jpg
image03.pts : image03.jpg
image04.pts : image04.jpg
}
Copy the first set of points (image00.pts) to files image01.pts, image02.pts etc.
Then run
qmsm_shape_editor -l image_list.txt -c my_model.crvs
This will display the first image and associated points (which should be correct).
You can now use the left and right arrow keys to step through the images and associated points.
Modify those that need moving as necessary. When you step to a new image, the points will automatically be saved to the correct file. This can save a lot of fiddling about.
Using an ASM to help annotation
Once you have sufficient images annotated (and a single image can be enough for a simple model),
you can follow the instructions in Tutoral 1 to build an ASM.
You can then use the qasm_markup_tool to annotate
further images.
Create an image list with the names of the so-far un-labelled images to simplify the process of stepping through them. In this case, you don't need to provide any points files - the program will use the model to create them as necessary.
Periodically add the annotated images to your training set and rebuild the model.
UoMASM Index