I have a binary image which contain few blobs.
I want to remove blobs which are less than a certain area.
Can any one suggest me a way?
I am using Open-C
//src_gray is your image that we threshold
threshold(src_gray, threshold_output, NULL, 255, THRESH_OTSU);
/// Find contours
findContours(threshold_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0));
/// Approximate contours
vector boundRect(contours.size());
for (unsigned int i = 0; i < contours.size(); i++)
{ //identify bounding box
boundRect[i] = boundingRect(contours[i]);
}
for (unsigned int i = 0; i < contours.size(); i++)
{
if ((boundRect[i].area() < //enter your area here))
{
src_gray(boundRect[i])=//set it to whatever value you want;
}
}
Well give this a try...