OpenCV Contours Moments?

烂漫一生 提交于 2019-12-03 11:20:20

I saw a great explanation somewhere but do not have the link.

Anyway, moment of 0th degree for a black/white image with black=0 and white=1: this is simply the sum of the pixels, i.e. the number of white pixels.

Moment of 1st degree for x-axis and some particular point X on the x-axis: this is the sum of the white pixel distances from X. I.e. it is the sum of their positions wrt. X. If you divide this by the number of white pixels (0th moment) you get the average white pixel position wrt. X.

And similarly for y-axis.

This idea generalizes to sumOf( pixelValue(position)*position^degree ). For degree 0 the last part is just 1 so that you simply sum the pixel values. For degree 1 it becomes a sum of positions, which can give you an average position, and for degree 2 it can reportedly give you a kind of direction.

For more and more accurate details, google it. :-)

Cheers & hth.,

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!