Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-342

Unpatchify Image

Problem

Rebuild an image from a flat list of non-overlapping patches, the inverse of patchify.

Patches are in row-major order and each patch is a flat list of patch * patch pixels in row-major order. Return the h x w image; h and w are divisible by patch.

Test cases

case 1
in: [[[1,2,3,4]],2,2,2]
expected: [[1,2],[3,4]]
case 2
in: [[[0,1,4,5],[2,3,6,7],[8,9,12,13],[10,11,14,15]],4,4,2]
expected: [[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]
case 3
in: [[[1],[2],[3],[4]],2,2,1]
expected: [[1,2],[3,4]]
Starter codePython
def unpatchify(patches, h, w, patch):
    # Your code here
    pass

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