Michael
Michael

Reputation: 1251

Java Color Histogram all Colors not RGB separate

I would like to extract a color histogram out of a BufferedImage (Java). I don't want to extract a separate histogram for red, green and blue, but I would like to have one histogram including all available colors (including a binning). It would be nice if the neighboring bins look similar to each other.

I don't have an Idea how to define the bins, since colors are not one-dimensional. Another problem is the allocation of a color to its bin.

Does somebody have an idea or a library to realize it?

Best, Michael

Upvotes: 0

Views: 1945

Answers (2)

BlueCoder
BlueCoder

Reputation: 293

Just an idea: open some image editor (e.g. Paint) and look at their color pickers to get an idea on how to arrange colors.

I think I would arrange them by HUE (enter link description here) since it would be a an unidimensional arrangement that easily matches the idea of "color bins" and it also puts similar colors near each other in a rainbow fashion. However, using Hue-only (discarding luminance and saturation) means that you might put colors that look very differently in the picture in the same bin.

Another way would be to automatically "cluster" all the colors in the picture into a fixed number of bins (e.g. 16) by using some kind of statical cluster analysis on the full RGB info (e.g. using all 3 RGB components) and then display the graph with the 16 "mean color" of each cluster below the corresponding histogram bar.

Upvotes: 0

ArtemStorozhuk
ArtemStorozhuk

Reputation: 8725

You can separately calculate histograms for red, green and blue and then find the mean of them and draw result grapic. Take a look at this article.

Or you can create a cube 3d histogram (each edge responces for one color). Here's result of it (java).

Upvotes: 1

Related Questions