-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab_08.asv
69 lines (57 loc) · 1.16 KB
/
lab_08.asv
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
65
66
67
68
69
im0 = imread('images/NewKuba_stereo_im0.png');
im1 = imread('images/NewKuba_stereo_im1.png');
L = rgb2gray(im0);
R = rgb2gray(im1);
subplot(2,2,1), imshow(im0);
subplot(2,2,2), imshow(im1);
subplot(2,2,3), imshow(L);
subplot(2,2,4), imshow(R);
[sx, sy, sz ] = size(L);
cxr = 141;
cyr = 351;
dx = 34;
dy = 34;
Rpatch = R(cxr:cxr+dx, cyr:cyr+dy);
cx = 141;
cy = 351;
inc = 1;
[max_nc, index_nc] = max(ncc(:));
Disp = zeros(sx, sy);
cxr = 1;
cyr = 1;
i = 1;
j = 1;
dx = 34;
dy = 34;
step = 35;
inc = 1;
cxr = 1;
i = 1;
while((cxr+dx) < (sx+1))
cyr = 1;
j = 1;
while((cyr + dy) < (sy+1))
Rpatch = R(cxr:cxr+dx, cyr:cyr+dx);
cx = cxr;
cy = cyr;
k = 1;
while((cyr+dy) < (sy+1))
Lpatch = L(cx:cx+dx, cy:cy+dy)
k = k + 1;
cy = cy+inc;
end
[max_nc, index_nc] = max(ncc(:));
Corr_max(i, j) = max_nc;
Disp(i:i+dx, j+j+dy) = index_nc-1;
ncc(:) = 0;
j = j+step;
cyr = cyr+step;
end
i = i + step;
cxr = cxr + step;
end
baseline = 203.047;
f = 998.834;
doffs = 16;
Depth = f*baseline*ones(sx, sy) ./ (Disp+doffs);
figure, imshow(Depth, []);