【问题标题】:Python 3D image segmentation find local peaks in distance map for watershedPython 3D 图像分割在分水岭的距离图中找到局部峰值
【发布时间】:2019-01-21 15:27:24
【问题描述】:

我正在尝试在 python 中分割多孔网络的 3d 断层扫描。我可以用ndimage.distance_transform_edt 计算距离图,用feature.peak_local_max 计算峰值。当我应用分水岭算法时,得到一个可接受的结果,但峰值的标记不在距离图的可见峰值上,见图

提前致谢

这里的代码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)

【问题讨论】:

  • 问题是什么?另外,请附上您的代码,请参阅minimal reproducible example
  • 还有其他方法可以计算 3d 数组的局部最小值吗?
  • (a) 如 Cris 所述,请提供完整的代码示例;但是 (b),是的,请参阅 skimage.morphology.local_maxima,如果您不需要 peak_local_max 的花哨的 min_distance 功能,这是推荐的计算方式。

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


【解决方案1】:

我找到了办法:

我必须排除边界并应用阈值

     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)

【讨论】:

    猜你喜欢
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-27
    • 2018-05-12
    • 2014-09-12
    相关资源
    最近更新 更多