-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateImage.m
71 lines (63 loc) · 2.91 KB
/
createImage.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
65
66
67
68
69
70
71
function [img, alpha] = createImage(filename, img)
%CREATEIMAGE Renders the screen image upon which we should add the heat map
settings;
if strcmp(DISTINGUISH, '') && RENDER == OBJECT
if USE_MAP == COLOR_MAP
[singleImage, ~, alpha] = imread([IMAGE_DIRECTORY, filename(1, :)]);
elseif USE_MAP == CURVE_MAP
ii = regexp(filename(1, :), IMG_REGEX, 'tokens');
ii = ii{1};
io = str2double(ii{2});
if io > 2
io = io - 2;
end
[singleImage, ~, alpha] = imread([IMAGE_DIRECTORY, CURVE_DIRECTORY, ...
CURVE_MAP_FILENAME, ii{1}, '_', ...
num2str(io), '.png']);
elseif USE_MAP == NORMAL_MAP
ii = regexp(filename(1, :), IMG_REGEX, 'tokens');
ii = ii{1};
io = str2double(ii{2});
if io > 2
io = io - 2;
end
[singleImage, ~, alpha] = imread([IMAGE_DIRECTORY, NORMAL_DIRECTORY, ...
NORMAL_MAP_FILENAME, ii{1}, '_' ...
num2str(io), '.png']);
end
if size(singleImage, 3) == 3
img((1:IMAGE_SIZE), (1:IMAGE_SIZE), :) = singleImage;
else
img((1:IMAGE_SIZE), (1:IMAGE_SIZE), 1) = singleImage;
img((1:IMAGE_SIZE), (1:IMAGE_SIZE), 2) = singleImage;
img((1:IMAGE_SIZE), (1:IMAGE_SIZE), 3) = singleImage;
end
clear filename singleImage;
else
leftImage = imread([IMAGE_DIRECTORY, filename(1, :)]);
rightImage = imread([IMAGE_DIRECTORY, filename(2, :)]);
if size(leftImage, 3) == 3 && size(rightImage, 3) == 3
img(LEFT_POS(1) + (1:IMAGE_SIZE), ...
LEFT_POS(2) + (1:IMAGE_SIZE), :) = leftImage;
img(RIGHT_POS(1) + (1:IMAGE_SIZE), ...
RIGHT_POS(2) + (1:IMAGE_SIZE), :) = rightImage;
else
img(LEFT_POS(1) + (1:IMAGE_SIZE), ...
LEFT_POS(2) + (1:IMAGE_SIZE), 1) = leftImage;
img(LEFT_POS(1) + (1:IMAGE_SIZE), ...
LEFT_POS(2) + (1:IMAGE_SIZE), 2) = leftImage;
img(LEFT_POS(1) + (1:IMAGE_SIZE), ...
LEFT_POS(2) + (1:IMAGE_SIZE), 3) = leftImage;
img(RIGHT_POS(1) + (1:IMAGE_SIZE), ...
RIGHT_POS(2) + (1:IMAGE_SIZE), 1) = rightImage;
img(RIGHT_POS(1) + (1:IMAGE_SIZE), ...
RIGHT_POS(2) + (1:IMAGE_SIZE), 2) = rightImage;
img(RIGHT_POS(1) + (1:IMAGE_SIZE), ...
RIGHT_POS(2) + (1:IMAGE_SIZE), 3) = rightImage;
end
clear filename leftImage rightImage;
end
img = img./256;
% figure(1);
% image(img);
end