We can take the ideas from part 1 and further apply them to create panorama images. In this case, we must capture
images by rotating the camera in such a way that any pair of side by side images has some overlapping features. We
can then select the same features in both images in order to transform one image into the shape of the other. Here is
an example of the feature selection:
Feature Points of Left Panel
Feature Points of Center Panel
Note that I selected more than 4 feature points this time. This is because overconstraining the system of equations
is actually beneficial. The overall algorithm is extremely prone to human error in choosing feature points. A small
error can make the transformation drastically different and for this reason, we overconstrain the system with 8 pairs
of feature points and solve it using the built in least squares solver to mitigate errors of any individual pair of
feature points.
Once we determine the homography matrix H we can inverse warp one image into the shape of the other image as we did
in the previous part. In this case, I chose to keep my center panel static and warped my left panel into the center
panel's shape:
Warped Left Panel
Static Center Panel
Next, we can gauge the relative locations of the images by comparing the transformed corners of the left panel (the
image we are warping) to the coordinates of the original center image. In this way we can offset and align the images
properly and furthermore create an output matrix large enough to hold the entire combination of the two images.
Warped Left Panel
Static Center Panel
There will inevitably be overlap in the two images since there was overlap in the original pair of images. In order to
remedy the overlap, we use a linear alpha-blending technique. We construct an alpha mask for each image such
that it linearly drops from 1 to 0 for the image on the left (as x increases) and linearly increases from 0 to 1 for
the image on the right (as x increases). We create a pair of canvases that are the same size as the ouput images in
addition to a pair of masks that are the same size as the input images. We take each mask and place it in each canvas
at the same location as the images above.
Left Alpha Mask
Center Alpha Mask
We then check to see where the overlap exists. This means we search the images for any location where both images
have non-zero pixels. We then run through each of these overlapping pixels and use weighted alpha blending. We check
each of the alpha masks for the corresponding alpha value and then determine weights w1 and w2 as follows:
w1 = a1 / (a1 + a2)
w2 = a2 / (a1 + a2)
And finally, we determine the color of the pixel:
output[x, y] = w1 * im1[x, y] + w2 * im2[x, y]
For all non-overlapping pixels, we can simply add the two images together since one or both images will be black.
This gets us the following result:
Warped Left and Center Panels after Blending
I attempted to use regular feathering blending on the overlapping borders and laplacian stack blending from our
previous project however this method seemed to provide the best results while minimizing artifacting and faded seams.
If we want to create a 3 panel panorama, we can take our output image, treat it as the static fixed image, and then
warp another image into its shape.
Below are some of my full panorama results:
Results seem to vary depending on subject and the steadiness with which the photographer takes the pictures (since
any non-lateral rotation of the camera can make the output image blurry). Additionally, the feature point selection
greatly impacts the transformation. The pictures of the bay seem to turn out the best probably because of the high
amount of entropy and loss of detail as the details of the scene are mostly small.
Interestingly, in the final 2 results where I used 5 panels rather than 3, it seems that the images on the far left
and right warp a lot more than the rest of the images. This could again be the fault of the photographer as I took
them with the camera at an upwards angle and thus as I rotated the camera, more of the scene changed. This is why the
furthest right and left panels are so stretched out.