国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

Python庫skimage繪制二值圖像代碼實例

瀏覽:41日期:2022-07-30 13:50:38

二值圖像的凸殼指的是包圍輸入二值圖像白色區域的最小的凸多邊形的像素集合。

skimage中的函數

from skimage.morphology import convex_hull_imagechull = convex_hull_image(image)

完整代碼:

'''===========Convex Hull===========The convex hull of a binary image is the set of pixels included in thesmallest convex polygon that surround all white pixels in the input.A good overview of the algorithm is given on `Steve Eddin’s blog<http://blogs.mathworks.com/steve/2011/10/04/binary-image-convex-hull-algorithm-notes/>`__.'''import matplotlib.pyplot as pltfrom skimage.morphology import convex_hull_imagefrom skimage import data, img_as_floatfrom 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, axes = plt.subplots(1, 2, figsize=(8, 4))ax = axes.ravel()ax[0].set_title(’Original picture’)ax[0].imshow(image, cmap=plt.cm.gray)ax[0].set_axis_off()ax[1].set_title(’Transformed picture’)ax[1].imshow(chull, cmap=plt.cm.gray)ax[1].set_axis_off()plt.tight_layout()plt.show()####################################################################### We prepare a second plot to show the difference.#chull_diff = img_as_float(chull.copy())chull_diff[image] = 2fig, ax = plt.subplots()ax.imshow(chull_diff, cmap=plt.cm.gray)ax.set_title(’Difference’)plt.show()

實驗輸出

Python庫skimage繪制二值圖像代碼實例

Python庫skimage繪制二值圖像代碼實例

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 镇沅| 蓬莱市| 赫章县| 临湘市| 巧家县| 翁牛特旗| 康马县| 大同县| 镇安县| 玉门市| 乳山市| 萝北县| 贵定县| 阿合奇县| 昔阳县| 苏州市| 虎林市| 镇原县| 凌海市| 宁德市| 黄陵县| 阳泉市| 太仆寺旗| 林西县| 车险| 错那县| 丰原市| 南木林县| 宁陕县| 临朐县| 罗甸县| 汽车| 罗平县| 长沙市| 温州市| 中山市| 筠连县| 左云县| 浮山县| 娱乐| 侯马市|