Reputation: 4755
Say I have an image with a transparent background such as the following:
How can I get the bounding rect for each object and not just one big one?
I'm currently using this category to trim the whitespace out. But I'm not sure how to make it separate objects from each other so they each have their own bounding box, or set a minimum threshold so it doesn't pick up anything smaller than say 16x16 if it's by itself.
Upvotes: 1
Views: 593
Reputation: 7596
This is a classic problem in computer vision called connected component labeling. The algorithm is not difficult to implement yourself. There are also third-party implementations out there like this (Swift), and this (Objective-C), and OpenCV definitely has this feature available.
Upvotes: 1