java - How can I do a method that return the Color that is more times repeated? all values of RGB that the image has -


is like:

public color colormoretimesrepeated() {

} , don't know how make variable count different colors , return me 1 repeated more times.

the idea count colors of image , give color repeated more times, have tried using *2 journeys , when anycolor repeated begins count , @ end return 1 more repeated.

    count=0;     color morerepeated = null;     for(int i=0;i< high;i++){     for(int j=0;j<wide;j++){ * 

there excellent answer on stackflow. i've posted code below link discussion.

set<integer> colors = new hashset<integer>();     bufferedimage image = imageio.read(new file("test.png"));         int w = image.getwidth();     int h = image.getheight();     for(int y = 0; y < h; y++) {         for(int x = 0; x < w; x++) {             int pixel = image.getrgb(x, y);                  colors.add(pixel);         }     }     system.out.println("there "+colors.size()+" colors"); 

https://stackoverflow.com/a/5253698/2353014


Comments