I'm trying to separate connected objects. It seems that Python and the watershed algorithm (scipy implementation) are well-suited to handle this.
Here is my image and automatically generated watershed seed points (local maxima of the thresholded and distance-transformed image):
seeds = myGenSeeds( image_grey )
So far, so good; there is a seed for every object.
Things break down when I run the watershed though:
segmented = ndimage.measurements.watershed_ift( 255 - image_grey, seeds)`
Both the top-middle cluster and the centre cluster are poorly separated. In the top cluster, one object flooded around the other two. In the centre cluster, though it might be too small to see here, the centre seed flooded to only a few pixels.
I have two questions:
I found this thread because I am having the same problem with watershed_ift
. I recommend just using the watershed
function in skimage.morphology
. It accepts float inputs, so you don't lose resolution on the greyscale image, and it actually floods the entire basin, while the ift
approach only seems to flood the isovalues where the markers lie.
EDIT: Be sure to multiply your distance transform by -1 so the peaks become valleys, or else you won't get any watersheds!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With