z = np.empty_like(rgb_image)
for x in range(rgb_image.shape[0]):
    for y in range(rgb_image.shape[1]):
        z[x, y] = np.dot(transformation_matrix, rgb_image[(x), (y), :])
np.allclose(z, np.einsum('kl,ijl->ijk', transformation_matrix, rgb_image))
Numpy 3d array map operation