Ask Your Question

CassioPereira's profile - activity

2020-06-26 05:11:34 -0600 received badge  Popular Question (source)
2016-02-25 03:00:56 -0600 received badge  Student (source)
2016-02-12 12:03:39 -0600 commented answer Compute moments after connected component labeling

I see your point, but isn't contMat(r).copyTo(grayObj, objROI(r)); just using the bounding rectangle, which can include points from other labels? How are you creating objROI(r) from the lblImg matrix in this scenario?

2016-02-12 10:13:48 -0600 received badge  Scholar (source)
2016-02-12 10:11:08 -0600 commented answer Compute moments after connected component labeling

I need to compute skewness (3rd order moment) for the region in the contMat matrix. Your solution helped me. I want to use pixel intensities, so I need false in the moments call. But I think cv::Rect r = cv::boundingRect(lblImg == 1); cv::Moments moments = cv::moments(contMat(r), false); achieves what I wanted.

2016-02-12 00:21:58 -0600 asked a question Compute moments after connected component labeling

Hi,

I'm trying to compute the moments of the pixels found in a connected component of a gray scale image.

I have in a matrix cv::Mat contMat a gray scale image. After thresholding it to another matrix binImg, I found its connected components with cv::connectedComponents(binImg, lblImg, 8); I went ahead and created a vector<cv::Point> points with the points from a specific connected component, let's say the ones labeled 1, by traversing lblImg and adding the points from contMat that have label 1 in lblImg.

Now I want to compute the image moments from those points in the contMat matrix using cv::moments(points, false), but that's not really working, because it seems moments expects a contour.

I'm wondering what's the best way to do this using OpenCV 3.1 in C++.

Thanks.