-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrameMontage.m
55 lines (42 loc) · 1.4 KB
/
FrameMontage.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function montageList = FrameMontage(folderLeft, folderRight, output)
if nargout > 0
remember = true;
else
remember = false;
end
%% List files
matchString = '*.jpg';
dirLeft = dir(fullfile(folderLeft , matchString));
dirRight = dir(fullfile(folderRight, matchString));
assert(numel(dirLeft)==numel(dirRight), ...
'Number of images in both the folders must be the same');
fileCount = numel(dirLeft);
if remember
montageList = cell(fileCount, 1);
end
readfile = @(dir, f) imread(fullfile(dir, f));
savefile = @(img, name) imwrite(img, fullfile(output, name));
eta = ETA(tic, fileCount);
for f=1:fileCount
imgL = readfile(folderLeft , dirLeft(f).name);
imgR = readfile(folderRight, dirRight(f).name);
if f==1
imsize = size(imgL);
imgWidth = imsize(2);
sepWidth = floor(imgWidth/1000);
leftEnd = imgWidth/2 - sepWidth;
rightStart = imgWidth/2 + sepWidth;
end
montage = doMontage(imgL, imgR, imsize, leftEnd, rightStart);
if remember
montageList{f} = montage;
end
savefile(montage, dirLeft(f).name);
eta.update(); eta.print();
end
end
function themontage = doMontage(imgl, imgr, imsize, leftEnd, rightStart)
themontage = repmat(uint8(0),imsize);
themontage(:,1:leftEnd,:) = imgl(:,1:leftEnd,:);
themontage(:,rightStart:end,:) = imgr(:,rightStart:end,:);
end