CS-194-26 Project 1

Abhinav Ayalur

Overview

For this project, we had to take the Prokudin-Gorskii images, align them, and then superimpose the red green and blue filters on top of each other to construct an RGB image. The reason we had to align the images was because since the images were taken at slightly different positions/angles, they were slightly misaligned by some x and y offset, which I had to account for. To do this, I first selected one image as my baseline image, which was originally blue but ended up being green for reasons I will discuss later. Then, I would np.roll the other filtered images by some x and y offset and measure how well they aligned to the baseline image and assign a number to it. For this, I used SSD, which calculated the sum of the squares of the pixelwise difference between 2 images, and used that as the score. Finding the minimum SSD across all the possible rolls within a certain grid would give me my ideal offsets with which to align. The edges of each of the images were distorted due to the age of the camera and wear and tear, so after rolling, I would only run ssd across the inner quarter of each of the images, which worked quite well.

When the images were far bigger, it was hard to align them because of sheer size, running SSD with a grid search on the image was not computationally feasible. Thus, I instead ran a pyramid search technique were I would downsample the image 2x till it was of a reasonable size, run the normal grid search on that small image, then upsample the image. At each 2x upsample, I would refine my offset over much a smaller area, which was computationally feasible. I also had to multiply my previous offsets by 2x to match the upsampled image size. Doing this, I could process even the larger .tif images.

Earlier, I had alluded to the usage of green filter based alignment instead of blue filter based alignment. Using the blue filter worked for some basic images, like church, but not for more complex images like emir.tif. After experimenting a bit, I found that using the green filter just happened to be better, maybe because it had more in common with the blue and red filters than theey had in common with each other, I'm not quite sure.

RGB images and respective offsets

Blue X Offset: -2

Blue Y Offset: -5

Red X Offset: 1

Red Y Offset: 7

Blue X Offset: -2

Blue Y Offset: 3

Red X Offset: 1

Red Y Offset: 6

Blue X Offset: -3

Blue Y Offset: -3

Red X Offset: 1

Red Y Offset: 4

Blue X Offset: -4

Blue Y Offset: -25

Red X Offset: -8

Red Y Offset: 33

Blue X Offset: -24

Blue Y Offset: -48

Red X Offset: 17

Red Y Offset: 57

Blue X Offset: -17

Blue Y Offset: -59

Red X Offset: -3

Red Y Offset: 64

Blue X Offset: -17

Blue Y Offset: -41

Red X Offset: 5

Red Y Offset: 49

Blue X Offset: -8

Blue Y Offset: -52

Red X Offset: 4

Red Y Offset: 60

Blue X Offset: -10

Blue Y Offset: -82

Red X Offset: 3

Red Y Offset: 95

Blue X Offset: -27

Blue Y Offset: -51

Red X Offset: 10

Red Y Offset: 57

Blue X Offset: -29

Blue Y Offset: -78

Red X Offset: 8

Red Y Offset: 98

Blue X Offset: -14

Blue Y Offset: -51

Red X Offset: -3

Red Y Offset: 59

Blue X Offset: -6

Blue Y Offset: -42

Red X Offset: 26

Red Y Offset: 43

Blue X Offset: 1

Blue Y Offset: -53

Red X Offset: -11

Red Y Offset: 52

Other selected images

Blue X Offset: -19

Blue Y Offset: -26

Red X Offset: 16

Red Y Offset: 95

Blue X Offset: 5

Blue Y Offset: -25

Red X Offset: -5

Red Y Offset: 77