# How to draw irregular outline of MSER region? This post is a wiki. Anyone with karma >50 is welcome to improve it.

I have detected MSER regions as follows(Thanks a lot for Alexander Shishkov's help!)

#include <opencv2/opencv.hpp>
int main(int argc, char *argv[])
{
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 outlines of MSER regions which have been detected by the above code. This step I write code as follow:

int main(int argc, char *argv[])
{
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 outlines of MSER regions, not interiors, how I need use the function of drawContours, what should I do?

edit retag close merge delete

Could you explain what is the irregular outline of MSER regions on any simple example?

Sort by » oldest newest most voted

If I understand correctly, you do not want to draw the nested contours. In this case the line where you draw the contours should be changed to,

drawContours(box,regions,i,Scalar(0,255,255),1,8, vector<Vec4i>(), 0, Point());//this was used to draw irregular  outlines of MSER regions


more

Official site

GitHub

Wiki

Documentation