Python:圆形对象的分割

Python:圆形对象的分割,python,numpy,scipy,image-segmentation,scikit-image,Python,Numpy,Scipy,Image Segmentation,Scikit Image,嘿,我有以下问题 我想分割图片中的圆形对象,如下所示: 我尝试了基于分水岭区域的算法,如scikit教程中所述: 来自skimage.com 从skimage.filters导入sobel 从scipy导入ndi图像作为ndi 将numpy作为np导入 从撇渣进口io 从scipy.signal导入查找峰值 imageArray=io.imread('pathToImage') 计数=0 对于范围内的i(len(imageArray)): evaluation\u map=sobel(ima

嘿,我有以下问题

我想分割图片中的圆形对象,如下所示:

我尝试了基于分水岭区域的算法,如scikit教程中所述:

来自skimage.com
从skimage.filters导入sobel
从scipy导入ndi图像作为ndi
将numpy作为np导入
从撇渣进口io
从scipy.signal导入查找峰值
imageArray=io.imread('pathToImage')
计数=0
对于范围内的i(len(imageArray)):
evaluation\u map=sobel(imageArray[i])
markers=np.zeros_like(imageArray[i])
直方图(imageArray[i],bins=256)
较低=找到峰值(历史,np.arange(1,20))
标记[imageArray[i]较低[-1]]=2
分段=分水岭(评估图、标记)
分段=ndi.二进制填充孔(分段-1)
imageArray[count],=ndi.label(分段)

这是一个循环,因为我有一堆这些图像。但我总是在分割后得到一张黑色的图片。现在我想知道是否有一种更好/更简单的方法可以用这样的对象分割图片。

看看上面的评论对你有帮助吗?不幸的是没有:(
from skimage.morphology import watershed
from skimage.filters import sobel
from scipy import ndimage as ndi
import numpy as np
from skimage import io
from scipy.signal import find_peaks_cwt

imageArray = io.imread('pathToImage')
count=0

for i in range(len(imageArray)):
    evaluation_map = sobel(imageArray[i])
    markers = np.zeros_like(imageArray[i])
    histo,_= np.histogram(imageArray[i],bins=256)
    lower=find_peaks_cwt(histo,np.arange(1,20))
    markers[imageArray[i]<lower[0]] = 1
    markers[imageArray[i]>lower[-1]] =2  
    segmentation = watershed(evaluation_map,markers)
    segmentation = ndi.binary_fill_holes(segmentation-1)
    imageArray[count],_ = ndi.label(segmentation)