Reputation:
I am working on a project where I am able, after some process, to find a binary image where moving objects are white, the rest being all black :
Then, there's an algorithm that agglomerates the blobs which are supposed to belong together, based on the distance between them (the one in the center for example). To do this, they use the findContour function so that each blob, which is flagged with a number, is represented by its contour pixels (there would be 5 in my image, the one in the center being composed of two close blobs). The output of the algorithm is the flag of the blobs belonging together, so for example with the above image, from top to bottom : (1, [2, 3], 4, 5).
Now I want to compute a concave hull for each of these agglomerated blobs. I have the algorithm to do it, but I can't apply it on the outer pixels, I need the pixels of the whole object !
How can I do that ?
The problem is that if I retrieve the pixels from the original image, I lose the connection between "pixels of the image" and "blobs". The blobs only have information about the contour.
I'd be grateful if you had an idea on how to solve this. :)
Upvotes: 0
Views: 1473
Reputation: 2273
How about using connectedComponents
(or connectedComponentsWithStats
) instead of findContours
?
It will find your blobs while giving you a list of all pixels in these blobs (not only the contour), in its "output" return array.
Upvotes: 1