forked from jbhuang0604/WSL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowboxes_hos.m
47 lines (38 loc) · 1.11 KB
/
showboxes_hos.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
function showboxes_hos(im, boxes, color, draw, cid, pid)
if nargin <= 3
draw = true;
end
%optionally print cid
if nargin <= 4
cid = nan;
end
if nargin == 5
pid = nan;
end
% doing this initializes the image. set to false in consequent runs.
% if this function is to be called multiple times on the same image.
if draw
image(im);
axis image;
axis off;
end
if ~isempty(boxes)
for j = 1:size(boxes,1)
x1 = boxes(j,1);
y1 = boxes(j,2);
x2 = boxes(j,3);
y2 = boxes(j,4);
line([x1 x1 x2 x2 x1 x1]', [y1 y2 y2 y1 y1 y2]', 'color', color, ...
'linewidth', 1);
if isnan(cid)
text(x1+3, y1+17, num2str(j), 'backgroundcolor', color);
elseif isnan(pid)
text(x1+3, y1+17, ['C', num2str(cid), '_', num2str(j)],...
'backgroundcolor', color, 'fontsize', 5);
else
text(x1+3, y1+17, ['C', num2str(cid), '_', num2str(pid)],...
'backgroundcolor', color, 'fontsize', 5);
end
end
end
drawnow;