-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathselective_search.m
41 lines (32 loc) · 1.36 KB
/
selective_search.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
function all_boxes = selective_search(image_filenames, output_filename)
addpath('Dependencies');
if(~exist('anigauss'))
mex Dependencies/anigaussm/anigauss_mex.c Dependencies/anigaussm/anigauss.c -output anigauss
end
if(~exist('mexCountWordsIndex'))
mex Dependencies/mexCountWordsIndex.cpp
end
if(~exist('mexFelzenSegmentIndex'))
mex Dependencies/FelzenSegment/mexFelzenSegmentIndex.cpp -output mexFelzenSegmentIndex;
end
colorTypes = {'Hsv', 'Lab', 'RGI', 'H', 'Intensity'};
colorType = colorTypes{1}; % Single color space for demo
% Here you specify which similarity functions to use in merging
simFunctionHandles = {@SSSimColourTextureSizeFillOrig, @SSSimTextureSizeFill, @SSSimBoxFillOrig, @SSSimSize};
simFunctionHandles = simFunctionHandles(1:2); % Two different merging strategies
% Thresholds for the Felzenszwalb and Huttenlocher segmentation algorithm.
% Note that by default, we set minSize = k, and sigma = 0.8.
k = 200; % controls size of segments of initial segmentation.
minSize = k;
sigma = 0.8;
% Process all images.
all_boxes = {};
for i=1:length(image_filenames)
im = imread(image_filenames{i});
[boxes blobIndIm blobBoxes hierarchy] = Image2HierarchicalGrouping(im, sigma, k, minSize, colorType, simFunctionHandles);
all_boxes{i} = BoxRemoveDuplicates(boxes);
end
if nargin > 1
all_boxes
save(output_filename, 'all_boxes', '-v7');
end