I
I
Ivan Nesterovich2014-05-29 19:52:28
Working with color
Ivan Nesterovich, 2014-05-29 19:52:28

How to find out the maximum belonging of a color to one of the lists of colors?

There is an array of colors (you can use hex, you can use rgb or cmyk).
The input color is in the same format as the colors in the array (hex, rgb or cmyk).
At the output, you need to understand which color from the array is closest to the input.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
maxaon, 2014-05-29
@maxaon

Have you tried searching? stackoverflow.com/questions/19782975/convert-rgb-c...
If only tint is needed, then try using hsv or hsl

G
gleb_kudr, 2014-05-30
@gleb_kudr

In essence, you need to solve the problem of finding the nearest point in three-dimensional space (a standard problem in three-dimensional space, the solution is googled). Color as such doesn't matter. Take only the space that suits your purposes. For example, if you want to find the closest color in terms of human perception, but you need to use LAB (and compare after converting to it).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question