implementation of a contour detection