python-3.x - 如何在skimage中获取轮廓区域
问题描述
我在文档中定义了 skimage 中的轮廓:
contours = measure.find_contours(img, 0.8)
在 OpenCV 区域可以使用:
cv2.contourArea(cnt)
skimage 是否包含类似的东西(轮廓特征的功能)?
解决方案
我在 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)
推荐阅读
- python - Python/SQLite3 - 搜索功能不适用于结果的多种组合
- python - 为什么变量有时会在 Python 中绑定两个方向?
- html - 用 flex 拉伸图像
- ionic-framework - 离子原生推送注册格式变了?
- html - CSS相对百分比在Chrome中不起作用
- c - 使用 SDL 编译 C 文件时出现“对 TTF_Init() 的未定义引用”链接错误
- sql - SQL Server 基于拆分行的减法值
- django - django rest api 不会从我的数据库中检索数据
- sql - 带有 CASE 和 Count 的查询语句出错
- php - 在 Ubuntu 16.04 上切换 php 版本不成功