Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-067

Image Pyramid Downsample

Problem

Downsample an image by a factor of 2 using decimation.

Keep the pixel at every even row and every even column, so a 3x3 input becomes 2x2 and a 1x1 input stays 1x1.

Test cases

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

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