java - 如何在图像(位图)中找到形状的重心
问题描述
这是我的工作,我试图使用选定的图像坐标在图像(位图)中找到形状的重心:
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
作为示例,请参见此图像:
解决方案
1.首先将位图设置为图像视图
2.获取该特定图像视图的中心点
centreX=imageView.getX() + imageView.getWidth() / 2;
centreY=imageView.getY() + imageView.getHeight() / 2;
推荐阅读
- python - 如何在 Pandas 中扩展和创建以下数据集
- google-colaboratory - Google Colab - 每次编辑库时是否需要重新启动运行时?
- amazon-web-services - 如何在 Redshift 中批量更新设置值?
- react-native - 为 React Native 设置包 ID 和包名称
- kotlin - 如何使用 KotlinJS 解压缩文件
- php - 将图像从 React Native 发送到 PHP Symfony 服务器
- azure - Spring Batch:Azure SQL 性能不一致
- python - Python双打印功能,我不明白这个例子是如何工作的
- logging - 如何在 abp.io 控制台应用程序中初始化、注入和使用 Logger
- powershell - 单击表单按钮时Powershell卡在连接到pnponline