Color RGB
ArrayList colors;
BufferedImage bi;
privatedouble colorVariety(){// 0-100
for(int i = 0; i<w; i++){
for(int j = 0; j><h; j++){
int rgb = bi.getRGB(i,j);
if(colors.contains(rgb) ==false){
colors.add(rgb);
}
}
}
return (1.0*colors.size() / (w*h));
}
The above code took a really long time to run with larger images. Since there are only 16581375 different colors, I was thinking of making a boolean[] that long and then mapping each rgb to a boolean and finally counting how many booleans are true.
The problem is, how do I map an rgb to a number from 0-16581374 ?
Tell me if you have any different solutions to the problem also.
Thanks>

