I suspect that this isn't quite correct.  The function may move part of the boundary onto the interior of the set.