2013-07-09 99 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

...认为有一个特殊的方法来做到这一点。非常感谢! –