首页 > 解决方案 > 如何在skimage中获取轮廓区域

问题描述

我在文档中定义了 skimage 中的轮廓

contours = measure.find_contours(img, 0.8)

在 OpenCV 区域可以使用:

cv2.contourArea(cnt)

skimage 是否包含类似的东西(轮廓特征的功能)?

标签: python-3.xscikit-image

解决方案


我在 scikit-image 中没有找到任何类似的函数,但是通过对数据进行一些操作,您可以使用 opencv 中的函数。您只需要扩展 numpy 对象并将其转换为 float32 UMat。

# Expand numpy dimensions
c = np.expand_dims(countour.astype(np.float32), 1)
# Convert it to UMat object
c = cv2.UMat(c)
area = cv2.contourArea(c)

推荐阅读