All problems
Seeded Random Crop
Problem
Take a random crop from an image using a seeded RNG.
Seed the random module, pick top = randint(0, H - out_h) and left = randint(0, W - out_w), then return the out_h x out_w crop.
Test cases
case 1
in: [[[1,2,3],[4,5,6],[7,8,9]],2,2,5]
expected: [[5,6],[8,9]]
case 2
in: [[[1,2,3],[4,5,6],[7,8,9]],1,1,0]
expected: [[5]]
case 3
in: [[[1,2,3],[4,5,6]],1,2,4]
expected: [[2,3]]
case 4
in: [[[1,2],[3,4]],2,2,9]
expected: [[1,2],[3,4]]
Starter codePython
def random_crop(image, out_h, out_w, seed):
# Your code here
pass4 test cases · run your code against them in the editor