def make_2d_kernels(): # for the peripheral elements pkb = np.zeros((3,3)) pkb[1,1] = 1 pkb[0,1] = -1 # for the diagonal elements dkb = np.zeros((3,3)) dkb[1,1] = 1 dkb[0,0] = -1/2 kernels = np.zeros(shape=(8,3,3)) for rot in range(4): pk = np.rot90(pkb, k=rot) dk = np.rot90(dkb, k=rot) kernels[rot,:,:] = pk kernels[rot+4,:,:] = dk return kernels