diff --git a/proj4/.DS_Store b/proj4/.DS_Store new file mode 100644 index 0000000..80454de Binary files /dev/null and b/proj4/.DS_Store differ diff --git a/proj4/images/1-1-1.png b/proj4/images/1-1-1.png new file mode 100644 index 0000000..b63e8b3 Binary files /dev/null and b/proj4/images/1-1-1.png differ diff --git a/proj4/images/1-1-2.png b/proj4/images/1-1-2.png new file mode 100644 index 0000000..d309f2b Binary files /dev/null and b/proj4/images/1-1-2.png differ diff --git a/proj4/images/1-1-3.png b/proj4/images/1-1-3.png new file mode 100644 index 0000000..01ebba5 Binary files /dev/null and b/proj4/images/1-1-3.png differ diff --git a/proj4/images/1-1-4.png b/proj4/images/1-1-4.png new file mode 100644 index 0000000..61120bb Binary files /dev/null and b/proj4/images/1-1-4.png differ diff --git a/proj4/images/1-1-5.png b/proj4/images/1-1-5.png new file mode 100644 index 0000000..12a081b Binary files /dev/null and b/proj4/images/1-1-5.png differ diff --git a/proj4/images/1-1-6.png b/proj4/images/1-1-6.png new file mode 100644 index 0000000..bc64992 Binary files /dev/null and b/proj4/images/1-1-6.png differ diff --git a/proj4/images/1-1-7.png b/proj4/images/1-1-7.png new file mode 100644 index 0000000..38330e2 Binary files /dev/null and b/proj4/images/1-1-7.png differ diff --git a/proj4/images/1-2-1.png b/proj4/images/1-2-1.png new file mode 100644 index 0000000..b7dc4de Binary files /dev/null and b/proj4/images/1-2-1.png differ diff --git a/proj4/images/1-2-2.png b/proj4/images/1-2-2.png new file mode 100644 index 0000000..86e0d0d Binary files /dev/null and b/proj4/images/1-2-2.png differ diff --git a/proj4/images/1-2-3.png b/proj4/images/1-2-3.png new file mode 100644 index 0000000..eb93621 Binary files /dev/null and b/proj4/images/1-2-3.png differ diff --git a/proj4/images/1-2-4.png b/proj4/images/1-2-4.png new file mode 100644 index 0000000..8fe47b7 Binary files /dev/null and b/proj4/images/1-2-4.png differ diff --git a/proj4/images/1-2-5.png b/proj4/images/1-2-5.png new file mode 100644 index 0000000..97e0d6a Binary files /dev/null and b/proj4/images/1-2-5.png differ diff --git a/proj4/images/1-2-6.png b/proj4/images/1-2-6.png new file mode 100644 index 0000000..7484e1d Binary files /dev/null and b/proj4/images/1-2-6.png differ diff --git a/proj4/images/1-2-7.png b/proj4/images/1-2-7.png new file mode 100644 index 0000000..d4780e8 Binary files /dev/null and b/proj4/images/1-2-7.png differ diff --git a/proj4/images/1-3-1.png b/proj4/images/1-3-1.png new file mode 100644 index 0000000..997ddbb Binary files /dev/null and b/proj4/images/1-3-1.png differ diff --git a/proj4/images/1-3-2.png b/proj4/images/1-3-2.png new file mode 100644 index 0000000..601df46 Binary files /dev/null and b/proj4/images/1-3-2.png differ diff --git a/proj4/images/1-3-3.png b/proj4/images/1-3-3.png new file mode 100644 index 0000000..8146db0 Binary files /dev/null and b/proj4/images/1-3-3.png differ diff --git a/proj4/images/1-3-4.png b/proj4/images/1-3-4.png new file mode 100644 index 0000000..64e914c Binary files /dev/null and b/proj4/images/1-3-4.png differ diff --git a/proj4/images/1-3-5.png b/proj4/images/1-3-5.png new file mode 100644 index 0000000..e6ed9f0 Binary files /dev/null and b/proj4/images/1-3-5.png differ diff --git a/proj4/images/1-3-6.png b/proj4/images/1-3-6.png new file mode 100644 index 0000000..a7bee64 Binary files /dev/null and b/proj4/images/1-3-6.png differ diff --git a/proj4/images/1-3-7.png b/proj4/images/1-3-7.png new file mode 100644 index 0000000..e1838e5 Binary files /dev/null and b/proj4/images/1-3-7.png differ diff --git a/proj4/images/3-1-1.png b/proj4/images/3-1-1.png new file mode 100644 index 0000000..42acd82 Binary files /dev/null and b/proj4/images/3-1-1.png differ diff --git a/proj4/images/3-1-2.png b/proj4/images/3-1-2.png new file mode 100644 index 0000000..1a31bc6 Binary files /dev/null and b/proj4/images/3-1-2.png differ diff --git a/proj4/images/3-2-1.png b/proj4/images/3-2-1.png new file mode 100644 index 0000000..cbdcd7f Binary files /dev/null and b/proj4/images/3-2-1.png differ diff --git a/proj4/images/3-2-2.png b/proj4/images/3-2-2.png new file mode 100644 index 0000000..92b57c8 Binary files /dev/null and b/proj4/images/3-2-2.png differ diff --git a/proj4/images/4-1-1.png b/proj4/images/4-1-1.png new file mode 100644 index 0000000..56fde30 Binary files /dev/null and b/proj4/images/4-1-1.png differ diff --git a/proj4/images/4-1-2.png b/proj4/images/4-1-2.png new file mode 100644 index 0000000..25ac51e Binary files /dev/null and b/proj4/images/4-1-2.png differ diff --git a/proj4/images/4-1-3.png b/proj4/images/4-1-3.png new file mode 100644 index 0000000..e7e2cfa Binary files /dev/null and b/proj4/images/4-1-3.png differ diff --git a/proj4/images/4-1-4.png b/proj4/images/4-1-4.png new file mode 100644 index 0000000..f12b671 Binary files /dev/null and b/proj4/images/4-1-4.png differ diff --git a/proj4/images/4-1-5.png b/proj4/images/4-1-5.png new file mode 100644 index 0000000..2bf267e Binary files /dev/null and b/proj4/images/4-1-5.png differ diff --git a/proj4/images/4-2-1.png b/proj4/images/4-2-1.png new file mode 100644 index 0000000..b845836 Binary files /dev/null and b/proj4/images/4-2-1.png differ diff --git a/proj4/images/4-2-2.png b/proj4/images/4-2-2.png new file mode 100644 index 0000000..3605217 Binary files /dev/null and b/proj4/images/4-2-2.png differ diff --git a/proj4/images/4-2-3.png b/proj4/images/4-2-3.png new file mode 100644 index 0000000..fc639e0 Binary files /dev/null and b/proj4/images/4-2-3.png differ diff --git a/proj4/images/4-2-4.png b/proj4/images/4-2-4.png new file mode 100644 index 0000000..d459197 Binary files /dev/null and b/proj4/images/4-2-4.png differ diff --git a/proj4/images/4-2-5.png b/proj4/images/4-2-5.png new file mode 100644 index 0000000..635a8db Binary files /dev/null and b/proj4/images/4-2-5.png differ diff --git a/proj4/images/4-3-1.png b/proj4/images/4-3-1.png new file mode 100644 index 0000000..15a72cf Binary files /dev/null and b/proj4/images/4-3-1.png differ diff --git a/proj4/images/4-3-2.png b/proj4/images/4-3-2.png new file mode 100644 index 0000000..63ae592 Binary files /dev/null and b/proj4/images/4-3-2.png differ diff --git a/proj4/images/4-3-3.png b/proj4/images/4-3-3.png new file mode 100644 index 0000000..a20dd51 Binary files /dev/null and b/proj4/images/4-3-3.png differ diff --git a/proj4/images/4-3-4.png b/proj4/images/4-3-4.png new file mode 100644 index 0000000..939b850 Binary files /dev/null and b/proj4/images/4-3-4.png differ diff --git a/proj4/images/4-3-5.png b/proj4/images/4-3-5.png new file mode 100644 index 0000000..2b7c3ee Binary files /dev/null and b/proj4/images/4-3-5.png differ diff --git a/proj4/index.html b/proj4/index.html new file mode 100644 index 0000000..70e41a5 --- /dev/null +++ b/proj4/index.html @@ -0,0 +1,523 @@ + + + + + + + + + + + CS 180 Project 4: Image Warping and Mosaicing + + + + + + + + +

CS 180 Project 4: Image Warping and Mosaicing

+

Jaxon Zeng

+ +

+ +
+ + + + +

Part A

+

Shoot the Pictures

+

To prepare for this project, I have shot several sets of pictures for later steps. In each set, I setup several + correspondence points for each pair of pictures.

+ The first set is the beautiful San Francisco skyline during a clear night. I took the set with a camera on a long + focal length lens. + +

San Francisco Skyline

+
+ + + + + + +
+ +
SF 1
+
+ +
SF 2
+
+ +
SF 3
+
+
+
+ +
Correspondence 1-2
+ + + + +
+ + + + +
+
+
+ +
Correspondence 2-3
+ + + + + +
+ + + + +
+
+
+
+

Village under Snow Mountain

+

The second set is a village under the beautiful mountain. I took this set with a wide angle lens.

+
+ + + + + + +
+ +
MT 1
+
+ +
MT 2
+
+ +
MT 3
+
+
+
+ +
Correspondence 1-2
+ + + + +
+ + + + +
+
+
+ +
Correspondence 2-3
+ + + + + +
+ + + + +
+
+
+
+

My Living Room

+

I took the third set randomly in my living room with my phone.

+
+ + + + + + +
+ +
RM 1
+
+ +
RM 2
+
+ +
RM 3
+
+
+
+ +
Correspondence 1-2
+ + + + +
+ + + + +
+
+
+ +
Correspondence 2-3
+ + + + + +
+ + + + +
+
+ +

Recover Homographies

+

To recover homographies, I need to find a matrix to perform projective mapping between correspondence points. The + matrix has 8 degrees of freedom and the lower right corner is set to 1 since all my images are taken with the same + focal length within the same set.

+

+ $$ + H = \begin{bmatrix} + h_1 & h_2 & h_3 \\ + h_4 & h_5 & h_6 \\ + h_7 & h_8 & 1 + \end{bmatrix} + $$ + + For each correspondence points $p'$ and $p$, I will have $p' = Hp$. + $$ + \begin{bmatrix} + x' \\ + y' \\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + h_1 & h_2 & h_3 \\ + h_4 & h_5 & h_6 \\ + h_7 & h_8 & 1 + \end{bmatrix} + \begin{bmatrix} + x \\ + y \\ + 1 + \end{bmatrix} + $$ + + Expanding the matrix I have: + $$ + \begin{aligned} + x' &= h_1 x + h_2 y + h_3 \\ + y' &= h_4 x + h_5 y + h_6 \\ + w' &= h_7 x + h_8 y + 1 + \end{aligned} + $$ + + To set the scaling factor to 1, I normalized the result by the third row: + $$ + x' = \frac{h_1 x + h_2 y + h_3}{h_7 x + h_8 y + 1} + $$ + $$ + y' = \frac{h_4 x + h_5 y + h_6}{h_7 x + h_8 y + 1} + $$ + Simplify the result we have: + $$ + h_1 x + h_2 y + h_3 - x' (h_7 x + h_8 y + 1) = 0 + $$ + $$ + h_4 x + h_5 y + h_6 - y' (h_7 x + h_8 y + 1) = 0 + $$ + Write this result back to matrix form: + $$ + \begin{align} + + \begin{bmatrix} + -x & -y & -1 & 0 & 0 & 0 & x' x & x' y & x' \\ + 0 & 0 & 0 & -x & -y & -1 & y' x & y' y & y' + \end{bmatrix}&\begin{bmatrix} + h_1 \\ + h_2 \\ + h_3 \\ + h_4 \\ + h_5 \\ + h_6 \\ + h_7 \\ + h_8 \\ + 1 + \end{bmatrix} &= &0 \\ + + A&h &= &0 + \end{align} + $$ + + To eliminate error, I set more correspondence points than the equation needed. When solving the matrix, I try to + get the minimum error solution. I use Singular Value Decomposition for $H$. +
+ In SVD, we decomposite $A$ into three components. + $$ + A = U \Sigma V^T + $$ + The solution for $H$ is the last column of $V^T$. I reshape the last column to a $3\times3$ matrix. And normalized + the matrix based on the bottom right corner to retrive $H$. + +

+ +

Warp the Images

+ After I get the recovery matrix from correspondence points, I can simply use forward warpping to transform one image + into another by multiplying the coordinates with $H$. To map the original image into the new transformed image, I + use scipy.interpolate.griddata to interpolate the color of the new coordinates. I also calculate the + the size of output image by the four corners of the new image. +
+ To test the result of the warping function, I rectify some images to make parts of the images into a shape of + square. + +
+ +
TV into square
+ + + + +
+ + + + +
+
+
+ +
Road Sign into square
+ + + + +
+ + + +
+
+ +

Blend Images into a Mosaic

+ Here comes the most interesting part of the project. I can finally blend the images into a single panorama. I use + the warping function to warp the images into the result shape. Then I compute their bounding box to decide their + position in the final image. Then I align each image based on their position. + At first I use a hard blending that directly put the three images into the final image. +
+ + + + + + + + + + + + +
+ +
SF 1
+
+ +
SF 2
+
+ +
SF 3
+
+ +
SF 1
+
+ +
SF 2
+
+ +
SF 3
+
+
+
+ + + + +
+ +
SF Pano
+
+
+
+
+ +
+ + + + + + + + + + + +
+ +
MT 1
+
+ +
MT 2
+
+ +
MT 3
+
+ +
MT 1
+
+ +
MT 2
+
+ +
MT 3
+
+
+
+ + + + +
+ +
MT Pano
+
+
+
+
+ + + +
+ + + + + + + + + + + +
+ +
RM 1
+
+ +
RM 2
+
+ +
RM 3
+
+ +
RM 1
+
+ +
RM 2
+
+ +
RM 3
+
+
+
+ + + + +
+ +
RM Pano
+
+
+
+
+ + The direct blending works fine for the first set of images. However, it's obvious that the panorama of the second + and third set did not blend smoothly. To create a smooth blending between images, I use the Laplacian multilayer + blending method from project 2. I use a gaussian filter to create a mask that smoothly merge the edge of two images + together. +
+ + + + +
+ +
SF Pano Smooth
+
+
+
+
+ + + + +
+ +
MT Pano Smooth
+
+
+
+
+ + + + +
+ +
RM Pano Smooth
+
+
+ + + + + \ No newline at end of file