Contours and connected components