繁体   English   中英

如何在图像(位图)中找到形状的重心

[英]How to find Center of Gravity of the shape in the Image (Bitmap)

这是我的工作,我试图使用选定的图像坐标在图像(位图)中找到形状的重心:

float xpos = 0f , ypos = 0f;
PointF currF = new PointF();
for (PointF pointF : pointFArrayList){
     xpos += pointF.x;
     pos += pointF.y;
} 
currF.x = xpos/pointFArrayList.size();
currF.y = ypos/pointFArrayList.size();
addRoundIconToViewRed(currF); //Marking the center of gravity

例如,请参阅此图像:

使用此图像查找 COG

1.首先将位图设置为图像视图

2.获取该特定图像视图的中心点

     centreX=imageView.getX() + imageView.getWidth()  / 2;
     centreY=imageView.getY() + imageView.getHeight() / 2;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM