0

I have a binary image that I create in scikit-image like so:

img = image_to_process  

from skimage.filters import threshold_li
thresh = threshold_li(img)
thresh_image = grayscale > thresh

On the resulting thresh_image (binary), I want to run a further segmentation step that separates the masked objects.

However I only find segmentation methods that run on grayscale (e.g. skimage.segmentation.watershed) , but not on binary images. Do I understand this correctly, and if so, do you know of a way to separate objects in a binary image?

Thanks!

Phil
  • 29
  • 5
  • please add the `image_to_process` to your question to form the [MWE](https://stackoverflow.com/help/minimal-reproducible-example) – Bilal Jan 11 '22 at 16:01
  • Objects in a binary image have the same value everywhere, so how you want to separate those objects any further? For binary images you can use morphology operators like open, close, dilate, erode... –  Jan 11 '22 at 16:05
  • @Phil **labeling connected components**, see this [answer](https://stackoverflow.com/q/46442154), might be the answer to your question. – Bilal Jan 11 '22 at 16:08
  • Hi! @Bilal, I think this answer would work for me. Thank you! And as for the MWE, unfortunately I am not able to share the image publicly as I work with medical images. Sorry! – Phil Jan 11 '22 at 16:19
  • @Sembei - Maybe segmentation is the wrong term, I just need a way to separate objects from one another in a binary image. I will have a look at the binary morphology operators. Thanks! – Phil Jan 11 '22 at 16:21
  • If the objects are not touching each other, then you need to label connected components. Check this link https://scipy-lectures.org/packages/scikit-image/auto_examples/plot_labels.html If the objects are touching by a small region you can separate them using the `opening` morphology operator https://scikit-image.org/docs/dev/api/skimage.morphology.html –  Jan 11 '22 at 16:43

1 Answers1

0

Use skimage.measure.label on the binary image to separate the different objects.

Juan
  • 5,433
  • 21
  • 23