Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-199

ROI Pool Bins

Problem

Compute the integer bin boundaries of ROI pooling.

For an ROI [x1, y1, x2, y2] split into pooled_h x pooled_w bins, each bin's row range is [floor(ph * roi_h / pooled_h), ceil((ph + 1) * roi_h / pooled_h)] and similarly for columns. Return one [hstart, hend, wstart, wend] per bin in row-major order, relative to the ROI.

Test cases

case 1
in: [[0,0,4,4],2,2]
expected: [[0,2,0,2],[0,2,2,4],[2,4,0,2],[2,4,2,4]]
case 2
in: [[0,0,5,3],2,2]
expected: [[0,2,0,3],[0,2,2,5],[1,3,0,3],[1,3,2,5]]
case 3
in: [[1,2,4,6],2,1]
expected: [[0,2,0,3],[2,4,0,3]]
Starter codePython
def roi_pool_bins(roi, pooled_h, pooled_w):
    # Your code here
    pass

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