如何找到对象的中心? [英] How can I find center of object?
问题描述
二值化后,我有黑白图像。之后,我得到一个不规则形状的对象。该图片的链接如下。
如何将这个对象写入圆?或如何找到此对象的中心?
I have black and white image after binarization. After that I get one object with irregular shape. Link to this image is below. How can I inscribe this object to circle?? or How can I find "center" of this object??
推荐答案
您可以找到重心,使用简单的公式,其是x坐标除以点的数量和y坐标的和除以点数(I表示白点)的总和。
You can find the center of gravity of the pixels using a simple formula which is the sum of the x coordinates divided by the number of points and the sum of the y coordinates divided by the number of points (I mean white points).
然后,您可以绘制一个以重心为中心的圆,点之间最大距离的一半。
Then you can draw a circle centered in the center of gravity with radious half of the maximum distance between points.
这里您有图形解释。
这篇关于如何找到对象的中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!