imgalign Detail

The alignment process is rather complicated. The algorithm uses two different functions, a master function: imgalign and a recursive helper function: alignhlpr. First is a look at the base of the recursive case. Second, building up the recursive "pyramid." And last a look at the overall alignment process.

Diagram of the cutterfnx

Alignhlpr Base Case

The very base of the recursive function is hit when the images are below a certain threshold (this sizing will be covered below). At this point the amount of searching can be maximize with a minimal performance loss. The two components that are being aligned are passed in to the function with a baseimg, the image that will not move, and a alimg, the image that will be aligned. A subset of the base image is taken to be the base of comparison (a.). Most of the unique parts of the image occur in the middle of the image, this selection tries to focus on this part, while ignoring the noisy or damaged sides. This subset of the base image never changes throughout the function. A window of the same size is then passed over alimg, pulling out varying subsets of the alimg. These subsets are compared to the baseimg using an algorithm, sum of the differences squared, to determine the best match (c.). In this example it is very hard to notice the differences in the three alimg parts, but they are all different. Once all of the possibilities are looked at, the recursive function passes the offset of the alimg back up the chain.

Diagram of the cutterfnx

Alignhlpr Recursion

In the first instance of the alignhlpr, which is called from imgalign, there would be the largest sized images. If the images are above a certain size, then they are cut in half in size and recursively passed to the same function (a.). The second (or highest) instance of the recursion will eventually pass back a set of offsets, as outlined above (b.). Now these offsets are used to search the existing images, but with a finer focus. Seeing as the general location of alignment is known, only a few different combinations need to be searched (c.). This process, also called an "image pyramid," is a very effective way of speeding up the image processing. For the large .tif images, they are 3700 pixels wide! This process cuts them in half, 4 or 5 times; greatly decreasing the amount of information that needs to be processed.

Diagram of the cutterfnx

imgalign

The main function of the aligning process, imgalign, is passed in three different component images. It then determines the best image to act as the "base," or a constant image that the others will align to. This process is normally determined by the largest of the component images; however, it can be set by the user as well. Once the base image is determined, the images are passed to two different instances of the helper function, alignhlpr. When the offset values are returned, the three images are combined to form a color image (a.). At this point, depending on the amount of offset, there may be a lot of wasted space on the sides. This would present itself by ghost colors on the edges due to a lack of information. Based on the offset values, the edges can be trimmed to limit this effect (b.). At this point we have an image that is ready to be put through the white balance function.



Close this window.