In this example, we will use three photographs taken from the same point in space, just by rotating the camera in the horizontal axis. Let's see the steps needed:
>> L = imread('Left.jpg'), >> M = imread('Middle.jpg'), >> R = imread('Right.jpg'), >> subplot(1,3,1);imshow(L);title('Left image') >> subplot(1,3,2);imshow(M);title('Middle image') >> subplot(1,3,3);imshow(R);title('Right image')
Then, it is time to pick a pair of points for the middle and right image:
Having pinpointed the two points that will be matched to connect the two images, we now have to move on to stitching.
circshift
. This function shifts the elements of a matrix in the dimension stated by the user in a circular fashion; that is, the pixels that fall out of the picture due to the shifting process, re-appear at the other end:>> Lr = circshift(L,-19);
Now, we must connect the two images at the vertical line passing through the common point:
>> First = cat(2,Lr(:,1:2018,:),M(:,767:end,:));
>> Rr = circshift(R,-31);
Now, we must connect the two images at the vertical line passing through the common point:
>> All = cat(2,First(:,1:3019,:),Rr(:,466:end,:));
>> imshow(All)
>> Rr = circshift(R,-21); >> All = cat(2,First(:,1:3019,:),Rr(:,450:end,:)); >> for i = 1:size(All,3) panorama(:,:,i)=medfilt2(All(:,:,i),[5 5]); end >> figure,imshow(panorama)
In this example, we demonstrated the simplest possible approach to panorama stitching. For acceptable results with minimal effort, this approach is not bad, but the demanding user should look for more complicated methods; combining feature detection with geometrical image transformations. The approach presented here, started with the manual selection of the common points between the images and the usage of their coordinates for aligning and stitching the images. Some refinement of the exact coordinates is commonly needed, as well as some postprocessing filtering step, such as median filtering. The final result still has artefacts, but it is certainly acceptable for such an easy and straightforward process. The blue sky areas that have appeared at the bottom of the image after the shifting commands, can either be blacked out, or cropped to achieve a better result.
Q1. Which of the following is true?
imfuse
, results in an image that is very bright.