Python 3D图像分割在分水岭的距离图中找到局部峰

时间:2018-08-14 17:43:00

标签: python-3.x opencv image-processing scipy scikit-image

我正在尝试用python分割多孔网络的3D层析成像。我可以使用ndimage.distance_transform_edt计算距离图,并使用feature.peak_local_max计算峰值。当我应用分水岭算法时,会得到可接受的结果,但是峰的标记不在距离图的可见峰上(见图)

预先感谢

enter image description here

这里的代码a是图片

D = ndimage.distance_transform_edt(a)
localMax = feature.peak_local_max(D, indices=False, min_distance=50,
            labels=a)
localMax2 = feature.peak_local_max(D, indices=True, min_distance=50,
            labels=a)

markers = ndimage.label(localMax, structure=np.ones((3,3,3)))[0]
labels = morphology.watershed(-D,markers,mask=a)

1 个答案:

答案 0 :(得分:0)

我找到了一种方法:

我不得不排除边界并应用阈值

     D = ndimage.distance_transform_edt(a)

    localMax = feature.peak_local_max(D, indices=False, min_distance=30,
        labels=a,threshold_abs=9,exclude_border=1)
    localMax2 = feature.peak_local_max(D, indices=True, min_distance=30,
        labels=a,threshold_abs=9,exclude_border=1)

    #markers = ndimage.label(localMax, structure=np.ones((3,3,3)))[0]
    markers = ndimage.label(localMax, structure=np.ones((3,3,3)))[0]
    labels = morphology.watershed(-D,markers,mask=a)
    regions=measure.regionprops(labels,intensity_image=a)