Ask Your Question
0

How to draw irregular outline of MSER region?

asked 2012-07-15 08:59:48 -0500

this post is marked as community wiki

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

edit retag flag offensive close merge delete

Comments

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

AlexanderShishkov gravatar imageAlexanderShishkov ( 2012-07-15 11:18:04 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2012-07-16 17:08:18 -0500

imran gravatar image

updated 2012-10-02 05:17:37 -0500

V.G. gravatar image

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

Refer to drawContours for more information.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-07-15 08:59:48 -0500

Seen: 1,036 times

Last updated: Oct 02 '12