Answers.Body: <p>Those segmented instances can be seen as <a href="https://en.wikipedia.org/wiki/Component_(graph_theory)" rel="nofollow noreferrer">connected components</a> of the 1s. You can use the <a href="https://en.wikipedia.org/wiki/Flood_fill" rel="nofollow noreferrer">flood fill</a> or <a href="https://en.wikipedia.org/wiki/Breadth-first_search" rel="nofollow noreferrer">BFS</a> algorithm to detect these components or try <a href="https://learnopencv.com/blob-detection-using-opencv-python-c/" rel="nofollow noreferrer">SimpleBlobDetector</a> by OpenCV.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-01T10:54:00.087Z
Answers.Text: "flood fill" finally worked out for me, there is a nice implementation in scikit-image library , although I had to make a loop to go through all objects, because basic implementation can only fill one "blob" of 1s at a time
Answers.UserDisplayName: GKozinski
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-31T11:01:02.960Z
Answers.LastActivityDate: 2021-08-31T11:01:02.960Z
Answers.UserDisplayName: entropy07
Body: <p>Is there a method/algorithm to generate instances of objects from image that was segmented by the use of any image segmentation models?</p>
  <p>For example, I have an image with one class and it was segmented in a given way, where 1s are objects of the same class and empty fields are of no class:<a href="https://i.sstatic.net/2i8w7.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2i8w7.jpg" alt="enter image description here" /></a></p>
  <p>How can I now generate list of the two objects, where list's elements for example would be positions of all the pixels inside the object (list of list).</p>
  
Tags: <convolutional-neural-networks><computer-vision><image-segmentation><instance-segmentation>
Title: How to divide a segmented image into classes instances?
UserDisplayName: GKozinski
ThreadText: # How to divide a segmented image into classes instances?
  
  (Asked by: username_0 on 2021-08-31)
  
  Is there a method/algorithm to generate instances of objects from image that was segmented by the use of any image segmentation models?
  
  For example, I have an image with one class and it was segmented in a given way, where 1s are objects of the same class and empty fields are of no class:[![enter image description here](https://i.sstatic.net/2i8w7.jpg)](https://i.sstatic.net/2i8w7.jpg)
  
  How can I now generate list of the two objects, where list's elements for example would be positions of all the pixels inside the object (list of list).
  
  **Tags:** convolutional-neural-networks, computer-vision, image-segmentation, instance-segmentation
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-08-31. Score: 0 | Accepted answer
  
  Those segmented instances can be seen as [connected components](https://en.wikipedia.org/wiki/Component_(graph_theory)) of the 1s. You can use the [flood fill](https://en.wikipedia.org/wiki/Flood_fill) or [BFS](https://en.wikipedia.org/wiki/Breadth-first_search) algorithm to detect these components or try [SimpleBlobDetector](https://learnopencv.com/blob-detection-using-opencv-python-c/) by OpenCV.
  
  > **Comments:**
  > **username_0**: "flood fill" finally worked out for me, there is a nice implementation in scikit-image library , although I had to make a loop to go through all objects, because basic implementation can only fill one "blob" of 1s at a time  
  
  ---
  
  