Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-154

Resize Boxes

Problem

Resize boxes after an image resize.

Given the old and new image sizes, scale x coordinates by new_w / old_w and y coordinates by new_h / old_h, rounding each value to 4 decimal places.

Test cases

case 1
in: [[[1,2,3,4]],10,10,20,30]
expected: [[2,6,6,12]]
case 2
in: [[[0,0,5,5]],5,5,5,5]
expected: [[0,0,5,5]]
case 3
in: [[[1,1,2,2],[3,3,4,4]],4,2,2,4]
expected: [[0.5,2,1,4],[1.5,6,2,8]]
Starter codePython
def resize_boxes(boxes, old_w, old_h, new_w, new_h):
    # Your code here
    pass

3 test cases · run your code against them in the editor