# Photo Mosaics (CS 194-26 Fall 2018 - Project 6-1)

## Overview (What I've Learned)

The goal of this project was to explore image warping beyond the simple translations we've done so far for 2 cool applications: 1.) Image Rectification and 2.) Image Mosaicing. In this project I captured images on my phone, calculated homography matrices mapping 2 images to each other, applied both forward inverse warping for transformation and finally alpha blended to stitch images together.

 my favourite image mosaic result

Through completing this part of the project, I consolidated my understanding of homographies, finally understood the pro's and con's between forward and inverse warping, forward warping is no good because not every pixel in the destination image will be filled! I learned that to accurately predict the size of a result image we can apply a forward warp to the corners of an image first. I think Image Rectification is actually what i personally find coolest about this project, in class we saw how we could see floors of paintings and that inspired me to do similar and look at cool ceilings! Finally I learned that picking points accurately and with a decent spread across the image is crucial to getting a good stitching. Smartly picking points is far more effective than blindly adding more, and I can't wait for part 2 where I'll write code such that I'll never have to pick points again.

## Part 1: Shoot Images

Here are the images that I shot using my Samsung Galaxy S5 Phone, that will be used for image mosaics. Note that before actually using these images (~5000 x 3000 px) I resized them to save computation time and file storage space for upload to this site.

 brunch_1 brunch_2 doe_1 doe_2 house_1 house_2 smog_1 smog_2

## Part 2: Image Rectification

In this part of the project I compute homographies and warp images, by mapping 4 points onto a new flat, projected surface to somewhat replicate a front-parallel viewing of features of interest in the scenes. Although 4 points is unstable, I found that the results they yield are perfectly fine for this portion of the project and it saved me clicking (definitely not for mosaics). If anything extra points made my rectified images worse, as I was very coarsely selecting points in the new image totally by guesswork - more points makes guessing reasonable locations more difficult. Points are selected via ginput manual selection, homographies are solved via least squares, and an inverse warping is done. The images below show 2 cool ceilings and a shifted view into an archway.

 Scrabble Original Scrabble Rectified Miami Beach Original Miami Beach Rectified
 Kitchen Mural Original Kitchen Mural Rectified

## Part 3: Blend Images into Mosaic

In this core part of the project, I build upon the same core techniques used in the previous parts (Homographies and Image Warping), but this time mapping exact, correspondance points between 2 images. Forward warping on the 4 corners of the original image were calculated to get size of result image, stitching was done by calculating a translational offset, and blending was done with basic alpha blending, which provides surprisingly good results - no noticable artifacts (other than a ghostly phone in the brunch_mosaic that dissappeared between images)! I selected between 20-24 points for each of the 4 pairs of images I shot (Part 1), and warped the left image to fit with the right image for the results shown below.

 brunch_1 brunch_2 doe_1 doe_2
 brunch_mosaic doe_mosaic
 house_1 house_2 smog_1 smog_2
 house_mosaic smog_mosaic (larger version @ top of page)

TBD (part 2)