5

I am trying to stitch 2 aerial images together with very little overlap, probably <500 px of overlap. These images have 3600x2100 resolution. I am using the OpenCV library to complete this task.

Here is my approach:

1. Find feature points and match points between the two images.
2. Find homography between two images
3. Warp one of the images using the homgraphy
4. Stitch the two images

Right now I am trying to get this to work with two images. I am having trouble with step 3 and possibly step 2. I used findHomography() from the OpenCV library to grab my homography between the two images. Then I called warpPerspective() on one of my images using the homgraphy.

The problem with the approach is that the transformed image is all distorted. Also it seems to only transform a certain part of the image. I have no idea why it is not transforming the whole image.

Can someone give me some advice on how I should approach this problem?
Thanks

Angie Quijano
  • 4,167
  • 3
  • 25
  • 30
Hien
  • 1,769
  • 3
  • 18
  • 17
  • Is it possible to post a scaled down version of the result? – bjoernz May 16 '11 at 09:31
  • http://imageshack.us/f/689/test2yz.png/ http://imageshack.us/f/16/test1uf.png/ Here are my results. Thanks – Hien May 16 '11 at 09:44
  • Those images were pretty bad to begin with. Here are test images with slightly more overlap. The colorful dots are the match points. [RESULTS](http://img96.imageshack.us/g/test3v.png/) – Hien May 16 '11 at 09:54

3 Answers3

3

In the results that you have posted, I can see that you have at least one keypoint mismatch. If you use findHomography(src, dst, 0), it will mess up your homography. You should use findHomography(src, dst, CV_RANSAC) instead.

You can also try to use warpAffine instead of warpPerspective.

Edit: In the results that you posted in the comments to your question, I had the impression that the matching worked quite stable. That means that you should be able to get good results with the example as well. Since you mostly seem to have to deal with translation you could try to filter out the outliers with the following sketched algorithm:

  1. calculate the average (or median) motion vector x_avg
  2. calculate the normalized dot product <x_avg, x_match>
  3. discard x_match if the dot product is smaller than a threshold
bjoernz
  • 3,852
  • 18
  • 30
  • After you mentioned about that, I tried it on a few pair of images with a larger overlap area and the results were really good. I guess this will have to do until I can figure out a way to make this work with images with a small area of overlap. Thanks – Hien May 17 '11 at 00:35
  • I haven't worked with vectors in awhile so I am slightly confuse on that certain threshold that you're talking about. Since we're going to compare the normalized dot product to a threshold, what threshold should be good in this situation? I know that a normalized dot product is less than or equal to 1 so what does it mean when the threshold is like .5? Thanks – Hien May 17 '11 at 09:38
  • By multiplying the two normalized vectors you get the cosine of the angle between those vectors. Maybe the wikipedia page will help to visualize it: http://en.wikipedia.org/wiki/Dot_product . So you can probably say that everything smaller than 0.7 (for example) is an outlier. – bjoernz May 17 '11 at 17:06
1

To make it work for images with smaller overlap, you would have to look at the detector, descriptors and matches. You do not specify which descriptors you work with, but I would suggest using SIFT or SURF descriptors and the corresponding detectors. You should also set the detector parameters to make a dense sampling (i.e., try to detect more features).

You can refer to this answer which is slightly related: OpenCV - Image Stitching

Community
  • 1
  • 1
KMS
  • 766
  • 1
  • 7
  • 10
  • I am using SURF descriptor and detector right now. I stayed away from SIFT since it was significantly slower than SURF even though it gave better results. My project initially was to stitch hundreds of images to create a map so I used SURF which gave decent result and is a lot faster than SIFT. – Hien May 19 '11 at 04:53
  • In that case, try adjusting the detector to obtain dense sampling of points. – KMS May 21 '11 at 20:44
0

To stitch images using Homography, the most important thing that should be taken care of is finding of correspondence points in both the images. Lesser the outliers in the correspondence points, the better is the generated homography. Using robust techniques such as RANSAC along with FindHomography() function of OpenCV(Use CV_RANSAC as option) will still generate reasonable homography provided percentage of inliers is more than percentage of outliers. Also make sure that there are at-least 4 inliers in the correspondence points that passed to the FindHomography function.

NoOne
  • 313
  • 1
  • 4
  • 11