added contour filter before calling the distance map