r = range(ker_size)
R = map(lambda i: map(lambda j: (i,j), r), r)
for x, y in map(lambda x: map(lambda y: (x,y), im_size[1]), range(im_size[0])):
#loop over channels
for c in range(chs):
acc = 0
#loop over kernel
a, b = y - ctr, x - ctr
for i,j in R:
n, m = a + j, b + i
if 0 <= m < im_size[0] and 0 <= n < im_size[1]:
acc += data[m][n][c] * kernel[i][j]
out_data[x][y][c] = acc