I have two bound boxes. one for predict, which contains 3 rows the second for ground truth that contains two rows.
Ground truth boxes (x,y,w,h)
[[210, 98, 103, 88],
[62, 75, 150, 120]]
Predicate boxes (x,y,w,h)
[[218, 104, 94, 69],
[154 ,184, 34, 9],
[67, 77, 143, 100]]
If I need to compute the bounding box overlap ratio using MATLAB function bboxOverlapRatio. The function evaluates the first-row box of ground truth with the first row in the predicate. Then second-row of ground truth evaluates with the second-row from predicate boxes. The function evaluates bound boxes using sequentially techniques row by row. The question is: What is a function that rearranges predicate boxes using the nearest position(place) or resorts boxes automatically by their appearance in the image? I want to rearrange to have a high ratio.
How can I do this if there is no MATLAB function?
Here is a sample code:
groundTruth = [210 98 103 88, 62 75 150 120]
predicate = [218 104 94 69, 154 184 34 9, 67 77 143 100];
ratio = bboxOverlapRatio(groundTruth,predicate)
I appreciate any help.
As per the documentation of the function bboxOverlapRatio,
Each (I, J) element in the output matrix corresponds to the overlap ratio between row I in bboxA and row J in bboxB.
For the function, your first argument (bboxA) is groundTruth
and bboxB is predicate
. Hence, in the ratio array, the element [0,1]
represents the overlap ratio between grountTruth[0]
and predicate[1]
. Thus, for groundtruth[1]
, you can iterate through [1,0], [1,1], [1,2]
and find the maximum value among them. Since [1,2]
is the maximum, this indicates that for row 1 in groundTruth, row 2 in predicate has the highest value.
This might be useful - max, especially the section Return Linear Indices.