-
Notifications
You must be signed in to change notification settings - Fork 28
/
example_ncc.m
64 lines (53 loc) · 1.34 KB
/
example_ncc.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
56
57
58
59
60
61
62
63
64
% Shows of the use the code with a NCC data (unary) term
clear all; close all;
if (matlabpool('size') == 0)
matlabpool open
end
%% Settings
% Image pair from
%http://vision.middlebury.edu/stereo/'
images{1} = double(imread('data/teddy/im2.png'));
images{2} = double(imread('data/teddy/im6.png'));
disparities = 0:1:50;
tol = 8*(disparities(2)-disparities(1));
unary_weight = 40;
kernel = 1;
%% Setup object
dm = dispmap_ncc(images,disparities, kernel, unary_weight, tol);
%%
% Generate new proposals by samlping taking the
% best NCC disparity at each voxel ad fitting planes
radius = 5;
id = 0;
proposal_cell ={};
for x = 10:50:dm.sz(2)
for y = 10:50:dm.sz(1)
id = id+1;
proposal_cell{id} =dm.generate_new_plane_RANSAC(x,y, radius);
end
end
% Add a few Fronto parallo
for d = 0:10:max(disparities)
proposal = zeros(size(dm.assignment));
proposal(3,:) = 1;
proposal(4,:) = -d;
proposal_cell{end+1} = proposal;
end
%% Iterative binary fusion
for iter = 1:length(proposal_cell)
dm.binary_fusion(proposal_cell{iter});
dm.display_current_dispmap();
drawnow();
end
% Display
single_energy = dm.energy();
figure(1);
dm.display_current_dispmap;
xlabel('Iterative fusion');
%% Simultaneous fusion
dm.restart();
dm.simultaneous_fusion(proposal_cell);
sim_energy = dm.energy();
figure(2);
dm.display_current_dispmap
xlabel('Simultaneous fusion');