-1

Let's say I have an image with some shapes on it. Is there any algorithm that knows that there are multiple shapes on it, based on if they are separated or not?

An example of my goal

MomoVR
  • 113
  • 1
  • 8
  • 1
    The thing you need is called “connected components labeling”, Wikipedia lists a few algorithms: https://en.wikipedia.org/wiki/Connected-component_labeling – Soonts Jul 06 '22 at 21:13
  • You need to be clearer about when you are dealing with different holes: imagine the 2D-matrix "[[1,0][0,1]", where the zeroes only touch diagonally. Does this represent one hole or two? – Dominique Jul 14 '22 at 12:55

1 Answers1

1

I used an algorithm called "connected component labeling". I used these intructions for the implementation: https://towardsdatascience.com/implementing-a-connected-component-labeling-algorithm-from-scratch-94e1636554f

MomoVR
  • 113
  • 1
  • 8