matlab灰度化处理函数_matlab中imfinfo的用法

发布时间:2025-12-09 14:06:06 浏览次数:4

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()

需要做网站?需要网络推广?欢迎咨询客户经理 13272073477