Image Registration

This program implements image registration. It first finds a set of 50 corresponding points between images. Then it runs a registration algorithm that calculates the translation and rotation needed to align the images. And finally it overlays the images on top of each other and calculates the error.

Method and Implementation

Finding Corresponding Points

For this algorithm I found a set of 50 corresponding points

The method I used was OpenCv’s Good features to track method

This is the 50 points found for the first image

This is the 50 points found for the second image

The algorithm then found the controid of the image using the 50 points. This is shown in red in the images above

Finding the angle Theta

To find the angle I used the method given in class where:

Theta = sum(y’(r,i) * x’(l,i) – x’(r,i) * y’(l,i))/sum(y’(r,i) * x’(l,i) + x’(r,i) * y’(l,i))
(where it sums over all points found on both images)

This is the rotated version of image 2 using OpenCv’s cvWarpAffine to rotate the image after the angle was found

Calculating the Error

I used OpenCv’s cvCanny to help me calculate a more accurate measure for the error (I think).

I used cvCanny to calculate edges on both the images, I then compared pixel by pixel and counted the pixels that did not match each other. Finally, I divided this number by the number of pixels in the image and used the result as my measurement for the error

This is both imaged overlayed on top of each other using the centroid as the point of reference. Note that the error is shown at the top

Experiment and Results

Finding Corresponding Points

This part was challenging because it is difficult to find a method for automating finding corresponding points that is accurate

At first I tried Implemented an Active Contours algorithm that spaced 80 points as fairly as possible to start with and have it little by little adjust itself to the inside and outside contour of the shape. This would have been very efficient had I finished writing the algorithm!

Next, I used openCv’s goodFeaturesToTrack algorithm. This proved to be a useful algorithm, however it picks points that are the most unique to an image, which in this case is not the best thing to do

Finally I implemented the same goodFeaturesToTrack algorithm, but this time I ran it on the edges of the image. I found the edges using cvCanny thresholded at about 200, which is the gray color that the biggest edges have. This method porved to be good ebough for the purposes of the assignment, so I used it.

Finding the angle Theta

This was the most straight forward part of the assignment as I followd the algorithm we derived and discussed in class

This algorithm found the angle accurately and helped me rotate the image about the centroid very accurately too

Calculating the Error

I tried a few different methods of calculating the error and eventually used the one I thought was the most fair:

At first I tried calculating the mean distance betweent the found points and using it as the measure for the error. The problem with this approach is that the points don’t necessarily correspond to each other, but that does not mean that the image was not registered correctly. So I figures I would use a measure that did not use the points to calculate error but rather tha actual results.

I tried then going pixel by pixel and incrementing a counter for every pixel that matched. Then dividing this number by the number of pixels and using that as a measure for the error. This is an “ok” measure, however, the images might match very well, but if one is a little darker, this approach will yield a huge error

So I then decided to go the edge way again. I repeated the process described above but on the edges of the image. This proved to be an accurate measure og the error

Discussion and Conclusion

Accuracy Discussion

It was very interesting to see the effect that the number of points found had on the algorithm. I tried different number of points with the error increasing for numbers less than 50 and greater than 50. I did not try to keep increasing the number of points to see if the error would go down again, but I speculate that it does

My final error was of 0.08%

My rotation angle was of 9.16 degrees

My translation was 9px on the x and 16px on the y

Here again is the transformed image overlayed with the original…as asked in the assignment

Source Code

Post a Comment

You must be logged in to post a comment.