Java - find a color representing all colors in an image

狂风中的少年 提交于 2019-12-08 09:37:05

问题


I am wanting to sample an image to return a single color that "looks" that a good representation of the colors sampled. I have tried two methods:

  • Taking an average of all the red, greens, and blues and creating an image from that. This rarely produces a color that looks like it came from the image.
  • Finding the "dominant" color from the image. This entails finding the most common color from the image. This is better, but for example, the Mona Lisa produces a dark purple color. This seems to capture the darker areas of the image, but it is ignoring all of the lighter areas in the top corners and on her skin. I would like a color that represents the dark areas and the light areas.

Photoshop has a "average blur" that produces a single color for an image. For the Mona Lisa, this looks like:

In this case, each quarter represents the respective quarter of the Mona Lisa. This is eventually what I am looking for, but let's start with the image as a whole.

I would love to know how photoshop gets these colors.

Thanks!

来源:https://stackoverflow.com/questions/26478533/java-find-a-color-representing-all-colors-in-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!