I am looking for an algorithm to find all connected components in my binary image.
If we think of the image like a matrix, it looks like:
[ 0 0 0 0 ...
0 0 0 0 ...
0 1 1 1 ...
0 1 0 1 ...
0 1 0 0 ...
...
]
I would like to find the all the ones that are touching (diagonally, as well). In this example, there is only one component - but there may be hundreds of unique components in an image.
Image => ALGORITHM => [ [(x,y)], ... ]
# list of lists of coordinates (each shape is a list)
I have looked at the two pass labelling algorithm on Wikipedia, but I don't believe it returns me the actual components - it just labels the distinct components. (Or is this one and the same?)
If possible, this should be able to run in real-time against a video stream.