Contours of height 1 and moment

asked 2015-05-06 03:15:54 -0600

LBerger gravatar image

Hi,

I have got this program

Mat grayscaleImage;

Mat imgOrig = imread("BLOB_MSER.bmp", IMREAD_UNCHANGED)
cvtColor(imgOrig, grayscaleImage, COLOR_BGR2GRAY);

Mat binarizedImage;
threshold(grayscaleImage, binarizedImage, 20, 255, THRESH_BINARY);
std::vector < std::vector<Point> > contours;
Mat tmpBinaryImage = binarizedImage.clone();
findContours(tmpBinaryImage, contours, RETR_LIST, CHAIN_APPROX_NONE);
Moments moms = moments(Mat(contours[20]));

For contours[20] I have got 1076 points but all moments are 0. What's wrong? When I call SimpleBlobDetector with this image I have got an exception for this contour

data are here

Thanks for your help

edit retag flag offensive close merge delete

Comments

Did you try using cv::drawContours to draw this specific contour?

seeminglyHelpful gravatar imageseeminglyHelpful ( 2015-05-06 03:43:58 -0600 )edit

No In debugging I can see that all y-coordinate points are 1(y=1)

LBerger gravatar imageLBerger ( 2015-05-06 03:52:19 -0600 )edit

There seems to be a border on top and left sides of the image, maybe that's causing the problem.

seeminglyHelpful gravatar imageseeminglyHelpful ( 2015-05-06 04:03:39 -0600 )edit

May be you can test program and see if you've got same result as me. It would be helpfull

LBerger gravatar imageLBerger ( 2015-05-06 04:15:15 -0600 )edit