-
Notifications
You must be signed in to change notification settings - Fork 17
/
imageStitching.m
32 lines (30 loc) · 878 Bytes
/
imageStitching.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function imageStitching(cam,rots,timu,tcam)
% Stitch image
disp('Stitching Image')
newim = zeros(800,1600,3);
for i = 1:15:size(cam,4)
idx = getSynchronizedTime(tcam(i),timu);
if idx>size(rots,3)
pause(5)
return
end
R = rots(:,:,idx);
im = cam(:,:,:,i);
% Generate image/cartesian coordinates
r = size(im,1); c = size(im,2);
cartCoord = generateCoordinates(r,c);
transCoord = R*cartCoord';
normCoord = normc(transCoord);
[azi, ele, ~] = cart2sph(normCoord(1,:),normCoord(2,:),normCoord(3,:));
[scaledAzi,scaledEle] = scaleSphrCoordinates(azi,ele);
aziMat = reshape(scaledAzi,[320 240]); eleMat = reshape(scaledEle,[320 240]);
for j=1:c
for k=1:r
newim(eleMat(j,k),aziMat(j,k),:) = im(k,j,:);
end
end
imshow(uint8(newim))
drawnow
hold on
end
end