|
privatedoublecolorScore(BufferedImageimg,Rectanglerect,doublebrightnessThreshold,doublesaturationThreshold){inttotal=0;Setset=newHashSet();for(inti=(int)rect.getX();i>16)&0xff;intg=(color>>8)&0xff;intb=color&0xff;//计算饱和度doublemax=Math.max(r,Math.max(g,b));doublemin=Math.min(r,Math.min(g,b));doublesaturation=1-min/max;//计算亮度doublebrightness=0.3*r+0.6*g+0.1*b;//统计大于阈值的像素if(brightness>brightnessThreshold&saturation>saturationThreshold){set.add(color);}total++;}}if(total==0){return0;}//统计大于阈值像素在所有像素的占比returnset.size()/(double)total;}
|
|