TP4

Image Stitching

by Saeed Sojasi


Goal of Assignment

The goal of this assignment is to implement an application of image mosaicing. Image mosaicing or image stitching is the process of combining multiple images with overlapping fields of view to produce a segmented panorama or high-resolution image. Image mosaicing not only allow you to create a large field of view using normal camera, the result image can also be used for texture mapping of a 3D environment such that users can view the surrounding scene with real images. Most approaches to image stitching require overlaps between images. For doing this assignment we need to learn how to compute homographies, and how to use them to warp images. We should to compute the homography that maps each image into the base image and then stitches all the mapped images together to form a whole panoramic scene. we will define some corresponding points between the images and then we will find a warp homography matrix and register the two images together on a mosaic image, and finally we will blend them together. This homework consists of two parts: 1) At first, we should use the manually selected correspondence points to compute homography 'H'. 2) Afterwards, we will have to implement a way to automatically detect and match interesting features in images.

1. Manual Matching

The image stitching algorithm can be summarized as: 1) Features matching. 2) Compute homography. 3)Projective warping. 4)Blending the images into a mosaic. (see the code 'manual_matching.m')
We need pairs of correspondences for calculation of homography. (see the code 'select_points.m'). The calculation of a homography requires at least 4 pairs of correspondences. For this purpose I select manually these interest points in both images. We should select very carefully these correspondences, because an error of a couple of pixels can produce huge changes in the recovered homography. Homography (H) is a 3x3 matrix with 8 degrees of freedom. I calculated the homgraphy that will project each image onto the base image (see the code 'compute_homography.m'). Aftere calculation homography, in the third step, we need to warp our images using this homography (see the code 'warp_image.m'). The input image is frist mapped into the base image (by 'H') then we use the invese of 'H' to find the color of each mapped pixels. Finally, we blend the warped image (see the code 'blend.m').

1.1 Results

The results of this part are shown below:


Panorama1



Manually Cropped




Panorama2



Manually Cropped




Panorama3



Manually Cropped



Discussion

My implementation has a problem, It dose not have good results for large images. I could not get results for more than 5 images. For more than five images, my computer return error. It returns out of memory.

2. Automatic matching

Automatic features matching
o Detecting corner features in an image
o Extracting a feature descriptor for each feature point
o Matching these feature descriptors between two images
o Use a robust method (RANSAC) to compute a homography
The automatic matching (see the code 'automatic_mosaic.m') is the same as manual matching except that all the correspondences are identified automatically.
Find interest points
First of all we need to detect corners features. A corner feature in an image is a location where the horizontal and vertical gradients are both very strong. I used harris detector for detect corner features. Harris detector (or harris corner detector) is an classic algorithm for corner detection. there is a large number of Harris corners and must be reduced down. For this purpose we use an adaptive non-maximal suppression (see the code 'adaptive_non_maximal_suppression.m').
Adaptive Non-maximal suppression
There are a lot of interest points. It is important that interest points are spatially well distribute over the image and for image stitching applications the area of overlap between a pair of images may be small. We use adaptive non-maximal suppression (ANMS) strategy to select a fixed number of interest points from each image. We select maximum in neighborhood of radius r. r is changeable. First we set r = 0 and then we increase this amount until obtain desired number of interest points. For each Harris point, the minimum suppression radius is the minimum distance from that point to a different point with a higher corner strength For this homework I selected 500 desired interest points with highest radius.

Results

The results of this part are shown below:

We see the base image (left) and input image (right). The red points are found by harris corner detection and the green circle around the red points are found by Adaptive Non-maximal suppression.



Feature descriptor
After the determined interest points place, we need to extract a description of the local image such local feature vectors. (see the code 'descriptor.m'). These vectors have been developed including local intensity patches, Gaussian derivatives, shift invariant feature transforms, and affine-invariant descriptors. We sample a 8 × 8 patch of pixels, which is taken from a 40x40 pixel window centered on the point sampled by every 5 pixels. These sampling are performed at a higher pyramid level for avoid aliasing. We should normalize the descriptor vector after sampling. For this purpose we put mean is 0 and standard deviation is 1.

Feature matching
We will need to find pairs of features that look similar and are thus likely to be good matches (see the code 'find_match.m'). The similarity between two points are compared in terms of sum of squared error based on the feature descriptor. The points with the least error are considered for matching. Also, we need to calculate threshold for compare the ratio between the lowest and second lowest errors. Point pairs that are less than threshold are consider for matching.

Results

The results of this part are shown below:

The match points are found between base image (left) and input image(right). The red (+) points are the match points.



RANSAC
Finally, we need to use a robust method to compute homography and remove the outliers from the candidate correspondence points. For this purpose I used RANSAC algorithm (see the code 'ransacH.m'). RANSAC algorithm uses some feature that we found them for estimate homography. We set of candidate features that have most similar by using nearest neighbor algorithm. After that, we refine matches using an outlier rejection procedure based on the noise statistics of correct and incorrect matches. First, we select 4 corresponding points from candidate points to calculate homography. Then all the candidates are projected onto the base image and the number of outliers are counted. we repeat this process 1000 times to reach the best homography in terms of least number of outliers.

Results

The results of this part are shown below:

RANSAC algorithm choose 8 green circle points among the red (+) points as inlier for computing homography matrix. While, the red (+) points are outlier that not be considered in homography matrix.


Results

The results of this part are shown below:


Panorama1



Manually Cropped




Panorama2



Manually Cropped




Panorama3



Manually Cropped



Discussion

Automatic matching function selects a lot of points. So, for run big data we need a high speed computer. For this part I could not get results for more than five images. To be honest, I do not have good computer, then I could not get results with this algorithm for more than five images. Also, in some images that they have a lot of details, this algorithm select a lot of correspondence points and my computer returns error.

3. My Images

I used my fully automatic algorithm on my images. for this part I used a tripod, because the center of projection must be the same for mosaics to work well.

Results

The results of this part are shown below:


My Images1



Manually Cropped



My Images2



Manually Cropped



Bells & whistles

For this part, I used some ideas to show my understanding on this subject. I used homographies to combine images. I put fake graffiti on road sign.

Results

The results of this part are shown below:

Result




Result





Result




I put my images on building.

The results of this part are shown below:

As you see in the results, the edgs of my image after homography have shearing, because when I selected corresponding points I did not very careful. Corresponding points should to select very carefully.

Result




In this image I look like a guilty person, so I created a funny thing by my image.

Result




Result





Result




I put my caricatures on wall.

The result of this part is shown below:


Result




I created a bizarre mosaic by my image.

The result of this part is shown below:
For this part, I used manual matching algorithm.



Result




I created a mosaic by spatially blending images taken at different times (day vs. night).

The result of this part is shown below:
I took 2 images in the sunny day and then I took 2 images from same view point at night.





Result




Cylindrical Panorama

Cylindrical panorama can capture a scene with 360 degree view and this is an advantage over a rectilinear panorama. Rectilinear panorama con not be exceed more than 120 degree of view. For cylindrical panorama we need to calibrate camera for finding focal length (see the code 'cylinder_projection.m'). The focal length is 1278.5. After that, we map pixels from image coordinates to cylindrical coordinates by computing an approximate cylindrical projection. For find matching features and compute transformations between each pair we use feature detection. Finally, we use RANSAC algorithm to select best transformation and after finding the best transformation we composite the images. I compute approximate cylindrical projection by following formula. x (x is with)and y (y is height) are image coordinates and x’ and y’ are corresponding cylindrical coordinates. f is focal length.


I could not find the distortion coefficients (k1 and k2). So, my results are not very good. I used 6 images of panorama1, 7 images of panorama2, and 3 images of my images.

The results of this part are shown below:














Reference

Brown, Matthew, Richard Szeliski, and Simon Winder. "Multi-image matching using multi-scale oriented patches. " In Computer Vision and Pattern Recognition, 2005. CVPR 2005. IEEE Computer Society Conference on, vol. 1, pp. 510-517. IEEE, 2005.