/
G53VIS_CW.m
48 lines (39 loc) · 1.74 KB
/
G53VIS_CW.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
close all;
clear;
%leftImage(:, :) = rgb2gray(imread('cones_left.png')); %Load in the left image
%rightImage(:, :) = rgb2gray(imread('cones_right.png')); %Load in the right image
leftImage(:, :) = rgb2gray(imread('teddy_left.png')); %Load in the left image
rightImage(:, :) = rgb2gray(imread('teddy_right.png')); %Load in the right image
%leftImage = imnoise(leftImage, 'gaussian');
%rightImage = imnoise(rightImage, 'gaussian');
maxSearchSpace = 50;
for x = 2 : 5
windowSize = 2 ^ 2;
disp = intensityToDisparity(leftImage, rightImage, windowSize, maxSearchSpace);
figure('Name', sprintf('Disparity from Pixel Intensity Matching [%dx%d window]', windowSize, windowSize));
imshow(disp);
end
for x = 2 : 5
windowSize = 2 ^ x;
disp = gradientFeaturesToDisparity(leftImage, rightImage, windowSize, maxSearchSpace);
figure('Name', sprintf('Disparity from Gradient Feature Matching [%dx%d window]', windowSize, windowSize));
imshow(disp);
end
for x = 2 : 5
windowSize = 2 ^ x;
disp = hogFeaturesToDisparity(leftImage, rightImage, windowSize, maxSearchSpace);
figure('Name', sprintf('Disparity from Histogram of Oriented Gradient (HOG) Feature Matching [%dx%d window]', windowSize, windowSize));
imshow(disp);
end
for x = 2 : 5
windowSize = 2 ^ 2;
disp = lbpToDisparity(leftImage, rightImage, windowSize);
figure('Name', sprintf('Disparity from Loopy Belief Propagation(LBP) [%dx%d window]', windowSize, windowSize));
imshow(disp);
end
for x = 2 : 5
windowSize = 2 ^ x;
disp = dpToDisparity(leftImage, rightImage, windowSize);
figure('Name', sprintf('Disparity from Dynamic Programming (DP) [%dx%d window]', windowSize, windowSize));
imshow(disp);
end