All the images are downsampled for better viewing on web browser.
My codes actually work for stitching more than two pictures. It just that the memory is quickly
drained from the necessary parameter of the interp2 function.
The most important question in the cylindrical warping is the focal length. Focal length directly affects the FOV and therefore has an impact on the projection. More importantly, we need to know the figure in pixel, not inch or mm. I had two approaches.
Theoretical approach: All my photos are taken while my camera was maximally zoomed out. According to official spec (Olympus C765 Ultra Zoom), the focal length for that scenario was 38 mm (35 mm film equivalent). 35 mm film is defined as the width (the longer side) being 35 mm, although some film producers make it 36. And I know the width of my image is 1144 pixels. So by similar triangle, the focal length in pixel = 1144 / 36 * 38 = 1207.55 or 1144 / 35 * 38 = 1242.06.
Empirical approach: For a range of reasonable focal length, warp the images and align them first with simple average squared difference (so that the low frequency objects match), and then find tune with average squared difference after the edge filter. Repeat until we find a focal length that gives the lowest error. This takes enormous amount of time. It appears that focal length of 1530 is the most appropriate for most images. I include both results for comparison.
Focal length = 1208 pixels (memory ran out and did not finish the last image)
Focal length = 1530 pixels