@DeprecationWarning
def recolor_from_ndarray(lab, perm):
    """perm is an ndarray of length > lab.max()"""
    assert perm.shape[0] > lab.max()
    if perm.ndim == 1:
        lab2 = perm[lab.flat].reshape(lab.shape)
    elif perm.ndim == 2:
        lab2 = perm[lab.flat].reshape(lab.shape + (perm.shape[1],))
    else:
        raise TypeError('perm must be 1D or 2D array')
    return lab2
