Python 图像处理
Rebeca Gonzalez
Data Engineer







from skimage import morphologysquare = morphology.square(4)
[[1 1 1 1]
[1 1 1 1]
[1 1 1 1]
[1 1 1 1]]
rectangle = morphology.rectangle(4, 2)
[[1 1]
[1 1]
[1 1]
[1 1]]
from skimage import morphology# 使用矩形结构元素 selem = rectangle(12,6)# 二值腐蚀得到腐蚀后的图像 eroded_image = morphology.binary_erosion(image_horse, selem=selem)
# 显示结果
plot_comparison(image_horse, eroded_image, 'Erosion')

# 使用默认结构元素进行二值腐蚀
eroded_image = morphology.binary_erosion(image_horse)

from skimage import morphology # 进行二值膨胀,得到膨胀图 dilated_image = morphology.binary_dilation(image_horse)# 查看结果 plot_comparison(image_horse, dilated_image, 'Erosion')

Python 图像处理