-
Notifications
You must be signed in to change notification settings - Fork 2
/
BestIoU_nonCell.m
35 lines (29 loc) · 919 Bytes
/
BestIoU_nonCell.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
function [num_gtboxes, bestIoU, bestGtIdx] = BestIoU_nonCell( boxes, gtBoxes, M1, M2)
N1 = size( boxes , 1 );
bestIoU = zeros( N1,1 );
bestGtIdx = zeros( N1,1 );
deleted_gtbox = false(M1, 1);
if isempty( gtBoxes )
bestIoU(:) = 0; % already 0 ...
num_gtboxes = 0;
else
%deal with the replicate annotation
for i = 1:N1
box = boxes(i,:);
s = PairedIoU( box, gtBoxes ).';
s([deleted_gtbox;false(M2,1)]) = -1;
[bestiou, bestgtidx] = max(s,[],1);
if bestgtidx <= M1
gt_S = PairedIoU( gtBoxes(bestgtidx,:), gtBoxes(1:M1,:) ).';
rep = (gt_S > 0.9);
deleted_gtbox(rep) = true;
deleted_gtbox(bestgtidx) = false;
end
end
S = PairedIoU( boxes, gtBoxes ).';
S([deleted_gtbox;false(M2,1)],:) = -1;
[bestIoU(:), bestGtIdx(:)] = max( S, [], 1 );
bestGtIdx(bestIoU<=0) = 0;
num_gtboxes = sum(~deleted_gtbox);
end
end