How do I draw irregular contours of MSER regions
How I can draw the contour of MSER regions which I have detected ? //detect MSER regions,Ellipse fitting of MSER regions,draw contour of MSER region//
int main(int argc, char *argv[]) {
Mat box = imread("box.png",1);
MSER ms;
vector<vector<Point>> regions;
ms(box, regions, Mat());
for (int i = 0; i < regions.size(); i++)
{
ellipse(box, fitEllipse(regions[i]), Scalar(255));
}
imshow("mser", box);
waitKey(0);
return 0;
}
//Next step I try to draw irregular contour of MSER regions which have been detected by the above code. This step I write code as follow://
int main(int argc, char *argv[]) {
Mat box = imread("box.png",1);
MSER ms;
vector<vector<Point>> regions;
ms(box, regions, Mat());
for (int i = 0; i < regions.size(); i++)
{
ellipse(box, fitEllipse(regions[i]), Scalar(255));
drawContours(box,regions,i,Scalar(0,255,255),1,8);//this was used to draw
//irregular outlines of MSER regions
}
imshow("mser", box);
waitKey(0);
return 0;
}
The result of above code show that the irregular interiors of MSER regions are drawn. But, I just need draw irregular contour(outline) of MSER regions, not interiors, how I need use the function of drawContours, what should I do?
a kind friend, imran, recommmend me use the function drawcontour like this:
drawContours(box,regions,i,Scalar(0,255,255),1,8, vector<vec4i>(), 0, Point());//this was used to draw irregular outlines of MSER regions//
However,it still show that the function draws the contour(s) and all the nested contours, I just want draw contour, not nested contours,so it does not work. I do not know whether I have explain my problem clear?
Please reformat your question in a good way!
1). Question name is still bad, you should remove the noise from the beginning. 2). Not all code is formatted as a code. 3). You should use spaces after commas. 4). You should probably attach some images. Please try again!
One mser region, what you get from opencv, contains all points that are belong to one extracted region. So mser region is not a contour of the region. You can find the outer contour by going through every pixels of one region. Find minX and maxY for every Y value that are present in one region. So the result will be an outer contour.