0

Hey I have the following problem,

I want to segment the round objects in a picture like this: enter image description here

I tried the watershed region based algorithm like in the scikit tutorial here: http://scikit-image.org/docs/dev/auto_examples/xx_applications/plot_coins_segmentation.html

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)

It is a loop because I have a stack of those images. But I always get a black picture after the segmentation. Now I wonder If there is a better/easy method approach to segment a picture with objects like this.

Liwellyen
  • 433
  • 1
  • 6
  • 19

0 Answers0