I want to get mass center of circle shape from binary image, but the output give more then one mass center. I'm using code from opencv web tutorial document about image moment and modified little bit. FYI, I'm using c++ API OpenCV.
And the output is:
I expect, the text output would give maybe 3 centroid from 3 contour, but reality is 7 contours (contours[0],...,contours[6]).
Which one the centroid? Or, which one the contour area of the circle shape?
Then I modified the code, remove some contours (because the real picture is very noise, and I just want to get some specific contours, circle shape, so I must remove the other contours, like line and character) using:
contours.erase()
I only want to get centroid from area contour between 100 till 500.
But, the output become strange..
The centroids like fly to anywhere from their contours.
Then, still, there are 5 centroid from 5 contours (contours[0],...,contours[4]).
What must i do? I only want to get the centroid of circle shape (above the number 3). I'm really need your advice. Thank you so much! :D
*Sorry for my bad english..
if ( contourArea(contours[i], false) < 100 || contourArea(contours[i], false) > 500) {contours.erase(contours.begin()+i); }
. – lulu