2013-07-09 100 views
-1

夥計們對不起,如果這聽起來有點尷尬。任何人都可以幫助如何計算圖像大小的平均尺寸。java.awt.Dimension的平均值

Dimension d = new Dimension (d); 
//where: 
int width = (int)d.getWidth 
int heigth = (int)d.getHeigth 

===> image size = (width, length); 
//Example 
image1 = (200, 350); 
image2 = (250, 280); 
image3 = (340, 260); 

如何計算3張圖片的平均大小?

+1

你會如何平均其他任何數字? – mattbdean

+0

你是指平均**面積**(平均(寬*長))?或維度(平均(寬度),平均(長度))? – CPerkins

回答

1
Dimension result = new Dimension() 
result.width = image1.getWidth() + image2.getWidth() + image3.getWidth(); 
result.height = image1.getHeight() + image2.getHeight() + image3.getHeight(); 
result.width /= 3; 
result.height /= 3; 

基本上,就像做任何其他平均值一樣。

+0

...認爲有一個特殊的方法來做到這一點。非常感謝! –