Distance transform implemented.