For correlation-stitching registration, MregCalculate() takes a series of images and their rough locations in another image's pixel coordinate system or the global pixel coordinate system, and applies the following three step process to determine the transformations that optimally position each image in the global pixel coordinate system.
Each image is first transformed into its rough location in the pixel coordinate system of its reference image (specified using MregSetLocation()). This initial rough alignment of each image with its reference image creates a region in which both images overlap, which is necessary for the correlation-stitching registration process to be successful.
For each image, the correlation-stitching registration operation then finds the transformation that optimizes the match in the overlapping region between the image and its reference image; this is referred to as the optimization step. You can control the type of transformation that the algorithm can use to reposition the image from its rough location (for example, a translation or a perspective warping), using MregControl() with M_TRANSFORMATION_TYPE. For more information, see the Selecting the transformation type subsection of the Customizing your registration settings section later in this chapter.
Once the optimal transformations that place each image in its reference image's pixel coordinate system are found, each transformation is converted so that it maps the image into the global pixel coordinate system instead.
Note that for the image whose reference coordinate system is the global pixel coordinate system, no correlation-stitching registration is performed and the optimal transformation is the same as the one set with MregSetLocation().
Correlation-stitching registration uses normalized grayscale correlation to optimize the match in the overlapping regions. Subsections within the overlapping regions are chosen and a pixel by pixel normalized grayscale correlation is calculated on each of the subsections. The MregCalculate() function then finds the best possible correlation between the subsections of the overlapping regions and computes the transformations required to obtain this alignment.
By applying the correlation algorithm on subsections within an overlapping region instead of on the whole overlapping region, the algorithm is more resistant to local changes in contrast and intensity within the images. For a better understanding of the normalized grayscale correlation algorithm, see the Pattern matching algorithm (for advanced users) section of Chapter 7: Pattern matching.