def detect_contour(img, level):
"""Returns list of vertices of contours at different levels
Arguments:
img (array): the image array
level (number): the level at which to create the contour
Returns:
(list of nx2 arrays): list of list of vertices of the different contours
Note:
The contour detection is based on matplotlib's QuadContourGenerator
"""
#parameter
mask = None;
corner_mask = True;
nchunk = 0;
#prepare image data
z = ma.asarray(img, dtype=np.float64);
ny, nx = z.shape;
x, y = np.meshgrid(np.arange(nx), np.arange(ny));
#find contour
contour_generator = _contour.QuadContourGenerator(x, y, z.filled(), mask, corner_mask, nchunk)
vertices = contour_generator.create_contour(level);
return vertices;
评论列表
文章目录