scikit-image库--绘制二值图外接凸面形(七)

本文通过使用Python的Skimage库,展示了如何对图像进行凸包处理,以实现图像特征提取和形态学分析。首先,对原始图像进行了黑白反转,确保目标物为白色;然后,应用convex_hull_image函数计算图像的外接凸面形;最后,通过Matplotlib绘制并对比了原始图像、反转图像及凸包处理后的图像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import matplotlib.pyplot as plt

from skimage.morphology import convex_hull_image
from skimage import data, img_as_float
from skimage.util import invert

# The original image is inverted as the object must be white.
image = invert(data.horse()) #黑白变换

chull = convex_hull_image(image)  #求外接凸面形

fig, ax = plt.subplots(1, 3, figsize=(18, 9))

# ax = axes.ravel()
# print(axes.shape,ax.shape)
ax[0].imshow(data.horse(),'gray')
ax[0].set_title('data.horse')
ax[1].set_title('Original picture')
ax[1].imshow(image, cmap=plt.cm.gray, interpolation='nearest')
ax[1].set_axis_off()

ax[2].set_title('Transformed picture')
ax[2].imshow(chull, cmap=plt.cm.gray, interpolation='nearest')
ax[2].set_axis_off()

plt.tight_layout()
plt.show()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值