Panoramic Picture Creation

This example illustrates simple method of panoramic picture creation using sum of absolute differences. It assumes no zooming, rotational variation in 2 images.

1. Reading Images for processing
S1 = imread('p1.jpg');
S2 = imread('p2.jpg');

2. Showing Images
1st Image

imshow(S1);



2nd Image

imshow(S2);



3. Extract red layer of the image for processing using Sum of Absolute Differences (SAD)
S1r = S1(:,:,1);
S2r = S2(:,:,1);

4. Sum of Absolute Differences (SAD) of a selected block is from each image are computed.
sz = 50;
roi2 = S2r(1:sz,1:sz);
[x,y]=size(S2r);
for cnt = y:-1:x/2
roi1 = S1r(1:sz,cnt-sz+1:cnt);
data(y-cnt+1)=sum(sum(abs(double(roi2)-double(roi1))));
end

5. Finding minimum error among all comparison
plot(data)
[minval,ind] = min(data);
hold on;
plot(ind,minval,'r*');





6. Combine the images at the minimum error region.
Sc = S1(1:end,1:y-sz-ind+1,:);
Sfinal = [Sc S2];

7. Final Result
figure;
imshow(Sfinal);