Atitit 颜色平均值cloor grb hsv模式的区别对比

 

 

 

 

Atitit 颜色平均值cloor grb hsv模式的区别对比

 

使用hsv模式平均后会变得更加的靓丽一些。。2

 

 

public class imgT {

 

public static void main(String[] args) {

Color c = new Color(100, 250, 55);

Color c2 = new Color(69, 176, 216);

List<Color> li_c = Lists.newArrayList();

li_c.add(c);

li_c.add(c2);

Color c_avg = ColorUtil.avgClr_byLiClr(li_c);

 

HSV h = ColorUtil.rgb2hsv(c.getRGB());

HSV h2 = ColorUtil.rgb2hsv(c2.getRGB());

List<HSV> li_h = Lists.newArrayList();

li_h.add(h);

li_h.add(h2);

HSV h_avg = ColorUtil.avgHsv(li_h);

 

 Color h2c=ColorUtil.HSVtoRGBColorV2(h_avg);

System.out.println(c_avg);

System.out.println(h_avg);

System.out.println(h2c);

 

}java.awt.Color[r=84,g=213,b=135]

{

"h":151,

"s":0.7302778,

"v":0.9137255,

"x":0,

"y":0

}

java.awt.Color[r=63,g=233,b=151]

 

 

 

 

使用hsv模式平均后会变得更加的靓丽一些。。

/AtiPlatf_cms/src/com/attilax/img/other/ColorUtil.java

public static Color avgClr_byLiClr(List<Color> li_c) {

int r_sum = 0;int g = 0;int b = 0;

//Color cl = null;

for (Color c1 : li_c) {

 

r_sum=c1.getRed()+r_sum;

g=c1.getGreen()+g;

b=c1.getBlue()+b;

}

int len=li_c.size();

int avg_r=r_sum/len;

int avr_g=g/len;

int avr_b=b/len;

//int rgb = .getRGB();

return  new Color(avg_r, avr_g, avr_b);

//return avgClr(ca);

}

 

作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 

汉字名:艾提拉(艾龙)   EMAIL:1466519819@qq.com

转载请注明来源: http://www.cnblogs.com/attilax/

Atiend

 

 

 

posted @ 2016-11-12 18:49  attilaxAti  阅读(690)  评论(0编辑  收藏  举报