Distance transforms for ndarrays