def do_matrix(img, mtx):
    '\n    img に対して mtx を適用する。\n    '
    base_shape = img.shape
    (r, g, b) = (img[(..., 0)], img[(..., 1)], img[(..., 2)])
    ro = (((r * mtx[0][0]) + (g * mtx[0][1])) + (b * mtx[0][2]))
    go = (((r * mtx[1][0]) + (g * mtx[1][1])) + (b * mtx[1][2]))
    bo = (((r * mtx[2][0]) + (g * mtx[2][1])) + (b * mtx[2][2]))
    out_img = np.dstack((ro, go, bo)).reshape(base_shape)
    return out_img
img に対して mtx を適用する。
def do_matrix(img, mtx):
    '\n    \n    '
    base_shape = img.shape
    (r, g, b) = (img[(..., 0)], img[(..., 1)], img[(..., 2)])
    ro = (((r * mtx[0][0]) + (g * mtx[0][1])) + (b * mtx[0][2]))
    go = (((r * mtx[1][0]) + (g * mtx[1][1])) + (b * mtx[1][2]))
    bo = (((r * mtx[2][0]) + (g * mtx[2][1])) + (b * mtx[2][2]))
    out_img = np.dstack((ro, go, bo)).reshape(base_shape)
    return out_img