I am having some hard time using Disjoint Sets in Connected Component Labeling. I have looked on many examples and also on this question where Bo Tian provided a very good implementation of Disjoint Sets as C++ linked list. I have already implemented Connected Component labeling ( labels are simple integers ) in my program but I have a really hard time resolving equivalences amongst labels with disjoint sets.
Can anyone help me on that - maybe using the Bo Tian's implementation ? I think that will also help others when they come to this point.
EDIT
My algorithm goes through the image and when it finds two labels two connected pixels with different labels it has to make a note in the 'equivalence registry' (which would be the Disjoint set forest). After looping the whole image I have to resolve the equivalences by (going second pass over the image) looking at the registry and then marking these pixels' which have equivalent labels to the minimum out of the set.
Check this tutorial on DJS. Only modification is that during union you have to connect bigger to lesser, so root is always mimimum of the set.