-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcvtShow10Images.m
More file actions
153 lines (137 loc) · 3.15 KB
/
cvtShow10Images.m
File metadata and controls
153 lines (137 loc) · 3.15 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
function cvtShow10Images ( images, option, cond, button, N)
%% cvtShowImages: Show images
% Input
% images: Image matrix [height x width x numPic]
% cond: Condition about color map
% button: Condition about being able to click image to go to next or previous image
%
% If you quit to show , input "q"
figure;
set(gcf,'CurrentCharacter','@');
if ~exist('frameRate', 'var')
frameRate = 30;
end
if ~exist('options', 'var')
option = 'gray';
end
if ~exist('cond', 'var')
cond = 0;
end
if ~exist('button', 'var')
button = 0;
end
if strcmp(option, 'gray')
[height, width, numPic] = size(images);
if ndims(images) ~= 3
images = reshape(images, height, width, numPic);
end
index = numPic:-1:1;
index = circshift(index, N);
tmpIndex = flip(index(1:N));
i = 1;
finish=false;
if cond == true
colormap('gray')
end
while ~finish
fprintf('Frame : %d\r', i);
for j = 1:N
subplot(1, N, j);
imagesc(real(images(:, :, tmpIndex(j))));
end
drawnow;
if button == true
time = waitforbuttonpress;
if i <= numPic
if time == 1
index = circshift(index, 1);
tmpIndex = flip(index(1:N));
i = i + 1;
else
index = circshift(index, -1);
tmpIndex = flip(index(1:N));
i = i - 1;
end
if i == 0
i = numPic;
end
if i == numPic+1
i = 1;
end
end
else
i = i + 1;
if i == numPic+1
i = 1;
end
index = circshift(index, 1);
tmpIndex = flip(index(1:N));
end
k=get(gcf,'CurrentCharacter');
if k~='@' % has it changed from the dummy character?
set(gcf,'CurrentCharacter','@'); % reset the character
% now process the key as required
if k=='q'
finish=true;
end
end
end
elseif strcmp(option, 'color')
[height, width, ~, numPic] = size(images);
if ndims(images) ~= 4
images = reshape(images, height, width, 3, []);
end
numPic = size(images, 4);
index = numPic:-1:1;
index = circshift(index, N);
tmpIndex = flip(index(1:N));
i = 1;
finish=false;
if cond == true
colormap('gray')
end
while ~finish
fprintf('Frame : %d\r', i);
for j = 1:N
subplot(1, N, j);
imagesc(real(images(:, :, tmpIndex(j))));
end
drawnow;
if button == true
time = waitforbuttonpress;
if i <= numPic
if time == 1
index = circshift(index, 1);
tmpIndex = flip(index(1:N));
i = i + 1;
else
index = circshift(index, -1);
tmpIndex = flip(index(1:N));
i = i - 1;
end
if i == 0
i = numPic;
end
if i == numPic+1
i = 1;
end
end
else
i = i + 1;
if i == numPic+1
i = 1;
end
index = circshift(index, 1);
tmpIndex = flip(index(1:N));
end
k=get(gcf,'CurrentCharacter');
if k~='@' % has it changed from the dummy character?
set(gcf,'CurrentCharacter','@'); % reset the character
% now process the key as required
if k=='q'
finish=true;
end
end
end
end
end