I am writing a function to label the connected component in an image (I know there are several libraries outside, I just wanted to play with the algorithm).
To do this I label the connected regions with different labels and create an equivalence table that contain information on the labels belonging to the same connected component.
As an example if my equivalence table (vector of vector) looks something like:
1: 1,3 2: 2,3 3: 1,2,3 4: 4
It means that in the image there are 2 different regions, one made of elements that are labelled 1,2,3 and an other made of elements labelled 4.
What is an easy and efficient way to resolve the equivalences and end up with something that looks like:
1: 1,2,3 2: 4
that I can use to "merge" the different connected regions belonging to the same connected component?
Thanks a lot for the help!