Ask Your Question

moments for all contours

asked 2013-08-10 08:46:37 -0600

updated 2013-08-10 09:06:37 -0600

I want to compute moments for all contours but the moments() function compute moments for single contours.


How to compute moments for all contours like a binary image?


I have merged all contours points then compute moments & compute center by moments but it is not near to the center calculated from the binary image moments.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-08-10 10:59:30 -0600

Guanta gravatar image

You could compute all individual moments for each contour and then average them, but this wouldn't be the true moment-value. I'd have done it the same way you did, i.e. merging all contours and then computing the moments. Of course these moments (achieved from contours of certain areas) differ to the moments of the complete areas (once you just regard the borders and once the whole areas).

So, I guess it all depends on your purpose: For what do you need the complete image moments? Maybe you actually want the individual moments for features?

edit flag offensive delete link more


In the OCR field for train a character in the first have to normalize the of the method for normalization is moments-base normalization that use the first moments to center of gravity & second nu for size of normalization.In the persian language some of the characters have points. I solved my problem with the binary image moments.Thanks for response.

Mostafa Sataki gravatar imageMostafa Sataki ( 2013-08-10 12:11:38 -0600 )edit

Question Tools


Asked: 2013-08-10 08:46:37 -0600

Seen: 498 times

Last updated: Aug 10 '13