## Assignment 4

### 4. Panoramas, by Hand and Automatically

#### 4.1 Description and requirements

This assignment explores making image panoramas. Take images and write code to construct panoramas in two ways, first using hand selected correspondeces between images, and then using automatically found correspondes between images. For each panorama, at least 4 photographs are used.

#### 4.2 Correspondences by Hand

In this part, I use hand specified correspondences. I click the graph (`ginput()` in MATLAB) to manually set correspondences between two graphs. Hence, I get two group of points.

I normalize the points by `function [normal_Points T]= Normal(Points)`, and then compute the homography for the two normalized point groups by `function H_normal = Compute_H_normal(Points,Points_prime)`. Leveraging these two functions, I can compute the homography H for the two original images by `function H = Compute_H(Points,Points_prime)`.

Code of the three functions are provided in Compute_H.m.

#### 4.3 Automatic Correspondences

In this part, I detect and match correspondences automatically via MATLAB functions `detectSURFFeatures()`, `extractFeatures()` and `matchFeatures()`. Then, I estimate, with RANSAC, homography H of the correspondences for the two images via MATLAB function `estimateGeometricTransform()`.

Integrating these functions, I get `function tform = auto(I,I_prime)` to automatically compute homography. Code is provided in auto.m.

#### 4.4 Finishing up and Blending

Finally, by the computed homography, by hand or automatically, I can use `imtransform()` to transform each individual image, and then blend it to the main photograph, or Base in my code, by gradient domain blending.

The gradient domain blending `function output = gra_proc(source,target)` is a little variation from previous assignments. The code is provided in gra_proc.m.

Since the HD photographs will make the matrix too large, especially in the gradient domain processing, and hence will cause very long processing time or even may result in "OUT OF MEMORY" MATLAB error. Thus, I always resize the images to 0.25 of the original at very beginning of the whole processing.

The scripts for making the panorama by hand and automatically are homo.m and auto_homo.m, respectively

#### 4.5 Results

I did 4 sets of examples to show my results. Each of them consists of 4 individual photographs. I will give very detailed step-by-step result for one of them, and for others, I will just post the final results for manual correspondences and automatic correspondences.

##### 4.5.1 Detailed Example
 original_photo_1 original_photo_2 original_photo_3 original_photo_4

By hand

Manually chosen 8 correspondent point pairs, noted by blue circles.

 original_photo_2 in place matching original_photo_1
 original_photo_1&2 in place matching original_photo_3
 original_photo_1&2&3 in place matching original_photo_4
 final result for correspondences by hand

Automatic

Chosen correspondences automatically, and use RANSAC to find proper pairs.

Result Summary

 photo_1 photo_2 photo_3 photo_4

##### 4.5.2 Other Examples

The following are the results for the other 3 examples. I omit the intermediate steps for them and just show the final resualts.

 photo_1 photo_2 photo_3 photo_4

 photo_1 photo_2 photo_3 photo_4

 photo_1 photo_2 photo_3 photo_4