分水岭图像分割:过分割和连通区域合并

2024-04-28 11:33:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用分水岭算法分割三维断层图像。在

{I>这里是^我的代码段:

D = ndimage.distance_transform_edt(a)

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

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

问题是该算法对区域进行过分割,见图片(左侧为原始断层图,中间为欧氏距离图带种子点(红点),右侧为分割图像)。如果我使用较少的种子点,我不会得到所有的区域。有没有办法合并相邻区域?在

Images


Tags: 图像算法区域thresholdlabelslocalminmax