大家好,又见面了,我是你们的朋友全栈君。
Matlab infl()依次使用函数IM=imreconstruct(marker,mask)
有关算法的详细信息,请参见
Soille,P.,《形态图像分析:原理和应用》,Springer Verlag,1999年,第208-209页。第6.3.7节“填充孔”部分import numpy as np
from skimage.morphology import reconstruction
import matplotlib.pyplot as plt
from skimage.io import imread, imsave
# Use the matlab reference Soille, P., Morphological Image Analysis: Principles and Applications, Springer-Verlag, 1999, pp. 208-209.
# 6.3.7 Fillhole
# The holes of a binary image correspond to the set of its regional minima which
# are not connected to the image border. This definition holds for grey scale
# images. Hence, filling the holes of a grey scale image comes down to remove
# all minima which are not connected to the image border, or, equivalently,
# impose the set of minima which are connected to the image border. The
# marker image 1m used in the morphological reconstruction by erosion is set
# to the maximum image value except along its border where the values of the
# original image are kept:
img = imread(“tyre.jpg”)
seed = np.ones_like(img)*255
img[ : ,0] = 0
img[ : ,-1] = 0
img[ 0 ,:] = 0
img[ -1 ,:] = 0
seed[ : ,0] = 0
seed[ : ,-1] = 0
seed[ 0 ,:] = 0
seed[ -1 ,:] = 0
fill = reconstruction(seed, img, method=’erosion’)
f, (ax0, ax1) = plt.subplots(1, 2,
subplot_kw={‘xticks’: [], ‘yticks’: []},
figsize=(12, 8))
ax0.imshow(img)
ax1.imshow(fill)
plt.show()
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/194225.html原文链接:https://javaforall.cn