Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-209

Flow Warp Image

Problem

Warp an image by a dense flow field.

For output pixel (i, j) sample the source at (i + flow_y[i][j], j + flow_x[i][j]) with round-to-nearest; out-of-bounds samples become 0.

Test cases

case 1
in: [[[1,2],[3,4]],[[1,1],[1,1]],[[0,0],[0,0]]]
expected: [[2,0],[4,0]]
case 2
in: [[[1,2],[3,4]],[[0,0],[0,0]],[[0,0],[0,0]]]
expected: [[1,2],[3,4]]
case 3
in: [[[1,2],[3,4]],[[0,0],[0,0]],[[1,0],[1,0]]]
expected: [[3,2],[0,4]]
case 4
in: [[[1,2],[3,4]],[[-1,0],[1,-1]],[[0,0],[-1,0]]]
expected: [[0,2],[2,3]]
Starter codePython
def warp_image(image, flow_x, flow_y):
    # Your code here
    pass

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