Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Compute moments after connected component labeling

$
0
0
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 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.

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>