def _threeDdot_simple(M,a):
    "Return Ma, where M is a 3x3 transformation matrix, for each pixel"

    result = np.empty(a.shape,dtype=a.dtype)

    for i in range(a.shape[0]):
        for j in range(a.shape[1]):
            A = np.array([a[i,j,0],a[i,j,1],a[i,j,2]]).reshape((3,1))
            L = np.dot(M,A)
            result[i,j,0] = L[0]
            result[i,j,1] = L[1]
            result[i,j,2] = L[2]

    return result
Return Ma, where M is a 3x3 transformation matrix, for each pixel