-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_watershed_segmentation.m
41 lines (32 loc) · 1.07 KB
/
run_watershed_segmentation.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
% Performs an initial watershed segmentation on each RGBD image.
addpath(genpath('iccv07Final'));
addpath('segmentation/');
Consts;
Params;
OVERWRITE = params.overwrite_watershed;
%
if ~exist(consts.watershedDir, 'dir')
mkdir(consts.watershedDir);
end
global ii_;
for ii_ = 1 : consts.numImages
if ~consts.useImages(ii_)
continue;
end
fprintf('running watershed %d/%d... ', ii_, consts.numImages);
outFilename = sprintf(consts.watershedFilename, ii_);
if exist(outFilename, 'file') && ~OVERWRITE
fprintf('skipping (exists), overwrite=false.\n');
continue;
end
fprintf('\n');
load(sprintf(consts.imageRgbFilename, ii_), 'imgRgb');
load(sprintf(consts.planeDataFilename, ii_), 'planeData');
[boundaryInfo, pbAll] = im2superpixels(imgRgb, double(planeData.planeMap));
save(outFilename, 'boundaryInfo', 'pbAll');
fprintf('done.\n');
end
clearvars -global ii_;
fprintf(' ================================================= \n');
fprintf('Finished initial watershed segmentation.\n');
fprintf(' ================================================= \n\n');