Reputation: 551
I want to detect the largest BLOB in a binary image for my project. can you please guide me on how can I do this?
Thanks
Upvotes: 1
Views: 1790
Reputation: 3118
I don't know what is the best practice here, but I'd do it somehow like this:
Then store all blobs in vector. Sort your vector by blobs' area. And then get the last blob.
bool sortBlobsASC(CBlob first, CBlob second) { return first.Area() < second.Area(); }
std::sort(myvec.begin(), myvec.end(), sortBlobsASC);
Upvotes: 0
Reputation: 12827
A good point of start would be the CVBloblib . I used it in the past and it works fine.
Then it is just a question of calculating the blobs area or perimeter, depending on what you want :)
Upvotes: 2
Reputation: 8725
Use findContours
to find all blobs in image and using contourArea
you can calculate blob's area. So just find contour (blob) with biggest area.
Upvotes: 5