簡體   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