Equivalent of watershed for cutting connected components of an image of particles?

62 views
Skip to first unread message

Adam Hughes

unread,
Feb 18, 2015, 7:04:10 PM2/18/15
to scikit...@googlegroups.com
Hi,

In ImageJ, one can select watershedding to break up connected regions of particles.  Are there any examples of using watershed in this capacity in scikit image?   All of the examples I see seem to use watershedding to do segmentation, not to break connected particles in an already-segmented black and white image.  

Also, is there a straightforward way to remove particles on a the edge of an image?  Sorry, googling is failing me, but I know this is possible.

Thanks

Juan Nunez-Iglesias

unread,
Feb 18, 2015, 9:27:15 PM2/18/15
to scikit...@googlegroups.com
Hey Adam,

I'm *guessing* the IJ method is:
1. compute the thresholded background image (ie background labeled "True")
2. compute the Euclidean distance transform (scipy.ndimage.distance_transform_edt)
3. compute the local maxima (find_local_max) and set them as seeds
4. compute watershed, using the foreground as mask.

All of those functions are available in scipy/scikit-image. If you get good results, a gallery example of this would certainly be appreciated! =) However, my experience with such methods is that they only work well for reasonably sparse, perfectly spherical particles.

As to removing particles on the edge, I would use a bool mask with only the edges selected, then np.unique(), then remove them manually in a for loop. I agree that it's a bit laborious... Perhaps a separate function to do this could be added to the API...




--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Georges H

unread,
Feb 19, 2015, 3:31:12 AM2/19/15
to scikit...@googlegroups.com
I second the post of Juan regarding the watershed for non sparse data.

As for clearing image borders you have a function from the segmentation module here :

Juan Nunez-Iglesias

unread,
Feb 19, 2015, 5:12:26 AM2/19/15
to scikit...@googlegroups.com
Ha! I'd never noticed that function! Thanks for pointing it out, Georges! =)




--

Georges H

unread,
Feb 19, 2015, 12:08:47 PM2/19/15
to scikit...@googlegroups.com
Sure thing ! i am actually using it in my own registration workflow ;))
Follow up on the watershed segmentation, maybe you could upload an example image so we could make some suggestions ?

Claiborne Morton

unread,
Mar 10, 2015, 2:12:27 PM3/10/15
to scikit...@googlegroups.com
Hey guys, Im following up on Adam's behalf, but this is an example of an image we are working with in trying to separate cells that are touching each other. 
Also you can see the top middle particle has a crescent shape, but is actually a healthy red blood cell that has been segmented incorrectly because of glare. Is that a way to connect the two tips of the shape so that I could then run "binary_fill_holes()" to correctly segment the cell. Thanks!
RBC_Example.png

Juan Nunez-Iglesias

unread,
Mar 10, 2015, 6:52:03 PM3/10/15
to scikit...@googlegroups.com
You could do a morphology.closing. That's kind of why it's called that. =D

Obviously you don't want to run it on the whole image, but I presume you're doing classification on the regionprops objects, so you could do the closing on each object individually.




--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<RBC_Example.png>

Claiborne Morton

unread,
Mar 11, 2015, 5:15:36 PM3/11/15
to scikit...@googlegroups.com
Hey thanks for the help, here are a few other issues we are running into. When a sickle cell is in contact with a regular cell, we cannot find a way to separate the two. Also bottom-middle circle is of a healthy blood cell that is on its side. The watershed function tends to break these cells into two or more partitions when the should not be separated.
Any idea on how to fix these problems?


--
You received this message because you are subscribed to a topic in the Google Groups "scikit-image" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scikit-image/VL6SZTWvAz8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scikit-image...@googlegroups.com.
WS Errors.png

Thomas Caswell

unread,
Mar 11, 2015, 7:01:54 PM3/11/15
to scikit...@googlegroups.com

Jumping in from the peanut gallery, can you reliable identify when the segmentation has gone sideways? Looking at the second moment, area to bounding box area, or some other compactness measure? 

If you can get away with it, you could just drop the offending cells. If not, then you can try eroding the joined cells until they split into multiple segments.

Tom


You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.

Adam Hughes

unread,
Mar 12, 2015, 1:09:11 PM3/12/15
to scikit...@googlegroups.com
Thomas,

Unfortunately, the cells of interest are the sickle cells, so isolating cells on their side and sickle cells is really important.  If anything, it would be better to toss out the healthy cells.  When you say the "segmentation has gone sideways", what do you mean exactly?

Juan,

What would binary closing do in particular?  I didn't understand what you were saying

Thomas Caswell

unread,
Mar 12, 2015, 1:16:05 PM3/12/15
to scikit...@googlegroups.com
By 'sideways' I mean "didn't work right".

Juan Nunez-Iglesias

unread,
Mar 12, 2015, 10:51:32 PM3/12/15
to scikit...@googlegroups.com
Hey Adam,

"Closing" is a dilation followed by an erosion. If you have "gaps" that are smaller than the footprint (aka structuring element) of the operation, they will be "closed". =) (e.g. a C turning into an O if the distance between the tips of the C is small enough.)

See a small example here:

Though come to think of it we should change the shape to be a C rather than an O with a thin bit.

Juan.
Reply all
Reply to author
Forward
0 new messages