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()
scikit-image库--绘制二值图外接凸面形(七)
最新推荐文章于 2024-10-09 09:09:12 发布