Added an opening after the closure. Compactness condition for contours.