Source code for dcnum.feat.feat_contour.contour

import numpy as np

from ...common import LazyLoader


cv2 = LazyLoader("cv2")


[docs] def contour_single_opencv(mask): """Return the contour for a boolean mask image containg *one* blob""" cv_im = np.asarray(mask * 255, dtype=np.uint8) # determine the contour information using opencv conts, _ = cv2.findContours(cv_im, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) # raw contour cont_raw = np.squeeze(conts[0]) return cont_raw