main_colors operation allows you to extract a given number of prevailing from an image.
The operation is useful when analyzing dominant colors of a product present in a web store, database, building image-based palettes, or doing something fancy with your site or app coloring scheme.
main_colors operation should come last in your image URL.
:number_of_colors — a number of colors you’d like to extract from an image: a smaller palette is derived, consisting of colors that are a fine match when representing your input.
:number_of_colors may be omitted, the default value of
4 is used in the case.
main_colors returns a JSON containing an array of 8-bit RGB values specific to the found dominant colors. For example, for [this][get-colors-example-inout] input image, the operation with no specified parameters will return this JSON,
[138, 142, 143],
[85, 74, 65],
[193, 211, 224],
[49, 42, 36]
main_colors algorithm involves random number generation, which may lead to slightly different results when applied to a single image repeatedly.
Technically, the operation is an optimized variation of the Local K-means color image quantization algorithm. The algorithm is adapted to a wide variety of input image data and provides results, intuitive in terms of human perception.