forked from ILoveFree2/selectiveSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawRectangleOnImage.m
44 lines (33 loc) · 1.01 KB
/
drawRectangleOnImage.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
function [ im ] = drawRectangleOnImage( im, boundingbox )
%drawRectangleOnImage : can draw all the bounding boxes with random color
%on im
% im: the input image
% boundingbox: the input bounding boxes, it is an n*4 matrix
% im: the output image with all the bounding boxes on them
for i = 1:size(boundingbox,1)
coor1 = boundingbox(i,1);
coor2 = boundingbox(i,2);
coor3 = boundingbox(i,3);
coor4 = boundingbox(i,4);
%this is the random color for the
R = uint8(randi(255,1,1));
G = uint8(randi(255,1,1));
B = uint8(randi(255,1,1));
%left line
im(coor1:coor3,coor2,1) = R;
im(coor1:coor3,coor2,2) = G;
im(coor1:coor3,coor2,3) = B;
%right line
im(coor1:coor3,coor4,1) = R;
im(coor1:coor3,coor4,2) = G;
im(coor1:coor3,coor4,3) = B;
%above line
im(coor1,coor2:coor4,1) = R;
im(coor1,coor2:coor4,2) = G;
im(coor1,coor2:coor4,3) = B;
%above line
im(coor3,coor2:coor4,1) = R;
im(coor3,coor2:coor4,2) = G;
im(coor3,coor2:coor4,3) = B;
end
end