属性运算符

属性运算符(或连接运算符) 1 是数学形态学中的一类保轮廓滤波运算。它们可以由最大树来实现 2, 图像的紧凑层次表示。

在这里,我们将演示如何使用直径闭合 3 4 ,这与形态闭合相比较。比较这两种结果,我们观察到图像和形态闭合的差异也提取了长线。一条细长的行不能包含结构化元素。一旦达到最大伸长,直径闭合就会停止填充。因此,该行不会被填充,因此也不会被差值提取。

import numpy as np
import matplotlib.pyplot as plt
from skimage.morphology import diameter_closing
from skimage import data
from skimage.morphology import closing
from skimage.morphology import square

datasets = {
    'retina': {'image': data.microaneurysms(),
               'figsize': (15, 9),
               'diameter': 10,
               'vis_factor': 3,
               'title': 'Detection of microaneurysm'},
    'page': {'image': data.page(),
             'figsize': (15, 7),
             'diameter': 23,
             'vis_factor': 1,
             'title': 'Text detection'}
}

for dataset in datasets.values():
    # image with printed letters
    image = dataset['image']
    figsize = dataset['figsize']
    diameter = dataset['diameter']

    fig, ax = plt.subplots(2, 3, figsize=figsize)
    # Original image
    ax[0, 0].imshow(image, cmap='gray', aspect='equal',
                    vmin=0, vmax=255)
    ax[0, 0].set_title('Original', fontsize=16)
    ax[0, 0].axis('off')

    ax[1, 0].imshow(image, cmap='gray', aspect='equal',
                    vmin=0, vmax=255)
    ax[1, 0].set_title('Original', fontsize=16)
    ax[1, 0].axis('off')

    # Diameter closing : we remove all dark structures with a maximal
    # extension of less than <diameter> (12 or 23). I.e. in closed_attr, all
    # local minima have at least a maximal extension of <diameter>.
    closed_attr = diameter_closing(image, diameter, connectivity=2)

    # We then calculate the difference to the original image.
    tophat_attr = closed_attr - image

    ax[0, 1].imshow(closed_attr, cmap='gray', aspect='equal',
                    vmin=0, vmax=255)
    ax[0, 1].set_title('Diameter Closing', fontsize=16)
    ax[0, 1].axis('off')

    ax[0, 2].imshow(dataset['vis_factor'] * tophat_attr, cmap='gray',
                    aspect='equal', vmin=0, vmax=255)
    ax[0, 2].set_title('Tophat (Difference)', fontsize=16)
    ax[0, 2].axis('off')

    # A morphological closing removes all dark structures that cannot
    # contain a structuring element of a certain size.
    closed = closing(image, square(diameter))

    # Again we calculate the difference to the original image.
    tophat = closed - image

    ax[1, 1].imshow(closed, cmap='gray', aspect='equal',
                    vmin=0, vmax=255)
    ax[1, 1].set_title('Morphological Closing', fontsize=16)
    ax[1, 1].axis('off')

    ax[1, 2].imshow(dataset['vis_factor'] * tophat, cmap='gray',
                    aspect='equal', vmin=0, vmax=255)
    ax[1, 2].set_title('Tophat (Difference)', fontsize=16)
    ax[1, 2].axis('off')
    fig.suptitle(dataset['title'], fontsize=18)
    fig.tight_layout(rect=(0, 0, 1, 0.88))

plt.show()
  • Detection of microaneurysm, Original, Diameter Closing, Tophat (Difference), Original, Morphological Closing, Tophat (Difference)
  • Text detection, Original, Diameter Closing, Tophat (Difference), Original, Morphological Closing, Tophat (Difference)

参考文献

1

黄晓明(1998)。北京:北京:北京。用于图像和序列处理的反扩张连通算子。IEEE图像处理学报,7(4),555-570。 DOI:10.1109/83.663500

2

Carlinet,E.和Geraud,T.(2014)。组件树计算算法比较综述。IEEE图像处理学报,23(9),3885-3895。 DOI:10.1109/TIP.2014.2336551

3

文森特·L.,Proc.“灰度区的开启和关闭,它们的有效实施和应用”,“欧洲数学形态学及其在信号处理中的应用”,西班牙巴塞罗那,第22-27页,1993年5月。

4

沃尔特·T和克莱恩,J.-C(2002)。基于包围盒闭合的人眼视网膜彩色眼底图像微动脉瘤自动检测在A.Colosimo,P.Sirabella,A.Giuliani(编辑),医学数据分析。《计算机科学讲义》,第2526卷,第210-220页。施普林格·柏林·海德堡。 DOI:10.1007/3-540-36104-9_23

脚本的总运行时间: (0分1.262秒)

Gallery generated by Sphinx-Gallery