Jelenlegi hely

Affine Registration of Planar Shapes

Funded by: 

PhD Scholarship of the Doctoral School in Mathematics and Computer Science of the University of Szeged

Hungarian Scientific Research Fund (OTKA) - K75637

Lifetime from: 
Lifetime to: 
Short description: 

Sample implementation and benchmark dataset of a correspondence-free binary image registration algorithm.


This is the sample implementation and benchmark dataset of the binary image registration algorithm described in the following paper:

  1. Csaba Domokos and Zoltan Kato. Parametric Estimation of Affine Deformations of Planar Shapes. Pattern Recognition, 43(3):569--578, March 2010.

The main code has been written by Zsolt Katona in Java. The code is released under the GNU General Public License.

The program uses PHCpack: a general-purpose solver for polynomial systems written by Jan Verschelde. A shared library has been made from PHCpack to access the solver from Java through a native method call.

The benchmark dataset has been created by Csaba Domokos. It contains 56 different template images of size approx. 1000 X 1000 and 49282 observations generated synthetically by random affine transformations. Please cite the above publication whenever you use the dataset.


The application runs only under Microsoft Windows.

To run the application:

  1. Change to the AffineRegistrationOfBinaryImages\dist directory.
  2. Double-click AffineRegistrationOfBinaryImages.jar in Windows Explorer.
  3. Hint: specifying the maximum heap size of the Java Virtual Machine is strongly recommended when working with large images. To specify the heap size, start the application from the command line by typing:

    java -jar -Xmx512m AffineRegistrationOfBinaryImages.jar

    The heap size is specified after the -Xmx parameter without whitespaces.

To build the application:

  1. Set JAVA_HOME environment variable properly. Do not use quotes when setting JAVA_HOME.
    e.g. SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_11
    (Apache Ant bin directory must also be added to PATH.)
  2. Change to AffineRegistrationOfBinaryImages folder, and type in the command line:

    ant jar

    Binaries are made into the dist directory.

Note: source can be opened in Netbeans IDE as a project.

Usage Notes

Only binary images can be opened (1 bit-per-pixel). Some test images are provided under the images subdirectory. The program GUI should be intuitive. Main steps:

  1. Open template image.
  2. Open observation image or create one synthetically from the template.
  3. Press Registrate button.
  4. Save registration results.

The red lines in the image windows show the coordinate axes, the origin is in the upper left corner. The y-axis is vertical, with values increasing from top to bottom. The x-axis is horizontal with values increasing from left to right.

When displaying images, 'Location of image' tag tells us where the upper-left corner of the transformed image's bounding box is mapped. When saving results, this information is saved into the info file at the 'Location of images X' and 'Location of images Y' tags.

The choosen interpolation method affects the creation of a synthetic observation from the template as well as the creation of the registered image.

Command-line options

If you start the application from the command-line, some options are available:

java -jar AffineRegistrationOfBinaryImages.jar options

Available options:

  • (no parameter)

    Starts the graphical user interface.
  • templatePath observationPath

    Registration of the template image to the observation image without user interaction. By default, the output files will be:

  • templatePath observationPath infoFilePath matlabFilePath
    observationCCSPath registeredCCSPath xorPath magentaGreenPath

    Registration of the template image to the observation image without user interaction. The last six parameters specify the output filenames. If you do not wish to save one of them use a hyphen (-) instead of that filename.
    This option is for batch processing only.

A short description of output files

  • Informations file

    A text file containing all information about the registration.
  • MATLAB file

    The transformation matrix is saved to a .mat file that can be loaded in MATLAB. The name of the MATLAB variable is R.
  • Observation image

    The observation is displayed in the common coordinate system. First the common bounding box of the aligned images is computed, then the observation image is displayed in this area.
  • Registered image

    The registered template is displayed in the common coordinate system. First the common bounding box of the aligned images is computed, then the template image is transormed into this area by the recovered transformation.
  • XOR image

    The result of a bitwise XOR operator on the observation and the registered template.
  • Magenta/Green image

    The registered template is assigned to both red and blue channels while the observation is assigned to the green channel.

Benchmark dataset

This is a synthetic binary image dataset for testing affine registration methods. All images are in PNG format. There are 56 different template images around size 1000 x 1000. The observations were generated synthetically by applying randomly choosen affine transformations composed by

  • 0, 10, ..., 350 degree of rotations;
  • 0, 0.4, ..., 1.2 shearings;
  • 0.5, 0.7, ..., 1.9 scalings;
  • -20, 0, 20 translations along both axes.

The images are binary and the 0 and 1 represents the background and foreground, respectively!

Templates directory contains the template images in PNG file format. There are 19 linedawing and 37 filled images. Naming convention: image????.png (image0001.png, image0002.png, ..., image0056.png)

Observations directory contains all observations for each template. There are 49282 images. Naming convention: observation????_????.png, where the first four digits are the template number, and last four digits count the number of the observation for the given template. Each observation has an associated data file with the same name and extension .dat.

Fields of a datafile
TemplateFileName filename of the corresponding template image
TemplateWidth width and
TemplateHeight height of the template image
TemplatePixel the number of the foreground pixels on the template
ObservationFileName filename of the observation (Note that: the observation has the same name as the corresponding datafile with extension .png
ObservationWidth width and
ObservationHeight height of the observations image
ObservationPixel the number of the foreground pixels on the observation
the applied transformation matrix (row by row)
TransformationMeasure the determinant of the applied transformation matrix
Jacobian ObservationPixel / TemplatePixel



The code is released under the GNU General Public License.

Publications to cite: