<p>In the end I decided to use Leon Sorokin's RGBQuant.js for quantization, because it offered better flexibility over the color histogram/clustering method. I'm probably going to convert the quantized palette RGB output to HSV and implement custom clustering that picks out the "highlight" colors, favoring diversity of hue for colors with high value and saturation, and low occurrence frequency.</p>

CC BY-SA 3.0
2015-11-16T10:33:47.740Z
2015-11-16T10:33:47.740Z
Escher
<p>I have a small project that needs to extract the perceptually-salient colors of an image, in javascript. There are a few libraries out there (color-thief.js, vibrant.js). The trouble is, I'm finding that <a href="https://color.adobe.com/create/image/" rel="nofollow">adobe color's</a> image extraction does a noticeably better job of recognizing the little high-contrast highlight colors which make a big visual aesthetic difference, even though they represent a small number of pixels. (This is the "color mood" option). For example, the color of lipstick a person wears, or small decorations on a big cake.</p>

<p>I think (?) Adobe doesn't provide an API for their Color CC any more, but in any case I'd rather not rely on it. Is there a javascript library out there with similar functionality that provides access to some sort of functionality that maximizes dissimilarity between hues?</p>

CC BY-SA 3.0
2015-11-13T12:50:10.797Z
Yes, algorithms are on topic, software programs aren't, and so I guess libraries are in-between? I was hoping for an answer along the lines of "Oh, you need the <maximal euclidian distance in XYZ colorspace> algorithm. There's an implementation in xyz.js; go an study it there."
Escher
CC BY-SA 3.0
2015-11-13T14:18:27.197Z
For your particular question, I suspect your main task will be choosing which [colour space](https://en.wikipedia.org/wiki/Color_space) best suits your purpose, which should simplify the remainder of the task.
trichoplax is on Codidact now
<color><color-separation><javascript>
Javascript color extraction library
Escher
# Javascript color extraction library

(Asked by: username_0 on 2015-11-13)

I have a small project that needs to extract the perceptually-salient colors of an image, in javascript. There are a few libraries out there (color-thief.js, vibrant.js). The trouble is, I'm finding that [adobe color's](https://color.adobe.com/create/image/) image extraction does a noticeably better job of recognizing the little high-contrast highlight colors which make a big visual aesthetic difference, even though they represent a small number of pixels. (This is the "color mood" option). For example, the color of lipstick a person wears, or small decorations on a big cake.

I think (?) Adobe doesn't provide an API for their Color CC any more, but in any case I'd rather not rely on it. Is there a javascript library out there with similar functionality that provides access to some sort of functionality that maximizes dissimilarity between hues?

**Tags:** color, color-separation, javascript

> **Comments:**
> **username_0**: Yes, algorithms are on topic, software programs aren't, and so I guess libraries are in-between? I was hoping for an answer along the lines of "Oh, you need the <maximal euclidian distance in XYZ colorspace> algorithm. There's an implementation in xyz.js; go an study it there."  
> **username_1**: For your particular question, I suspect your main task will be choosing which [colour space](https://en.wikipedia.org/wiki/Color_space) best suits your purpose, which should simplify the remainder of the task.  

---

## 1 answers

### Answer by username_0 on 2015-11-16. Score: 1 | Accepted answer

In the end I decided to use Leon Sorokin's RGBQuant.js for quantization, because it offered better flexibility over the color histogram/clustering method. I'm probably going to convert the quantized palette RGB output to HSV and implement custom clustering that picks out the "highlight" colors, favoring diversity of hue for colors with high value and saturation, and low occurrence frequency.


---

