-2

I have a HSV value of a color. I need to map it to the colosest color in my list of colors {red,green,blue,grey,orange,purple,yellow,black,white,gold}.

How do I do this mapping. Someone told me to just check the hue ranges. eg : red is 0-10 and 320-260 (eg), but the color also depends on S and V value and the color shade changes upon changing these values.

My question is : how do I map my hsv value to a color in my list.

Please suggest.

Thanks in advance

PS : I am writing the code in java

Edit :

Example : red hsv ranges from (0,100,100) to (12,100,100). But when I change the S and V values, red ranges from (0,50,50) to (3,50,50). Changing the HSV values changes my range.So,the color name depends on S and V. Also, 202,19,58 hsv is grey and so is 154,4,56. But the hsv for grey is 0,50,50. How do I determine gray from HSV then. My HSV function returned 202,19,59. The color becomes green,blue,grey when used different S and V values. Please tell me how can I identify my colors.

At present I am finding the closest distance approach to compare my HSV with the DB color HSV to return the color name.

Sourabh
  • 73
  • 1
  • 18
  • 1
    I have downvoted this question because it is a zero-effort requirements dump. If you can [edit] your question to show us a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) of your attempt, this downvote may be retracted. – Joe C Oct 10 '17 at 06:17
  • Try [converting the color to RGB](https://docs.oracle.com/javase/7/docs/api/java/awt/Color.html#HSBtoRGB(float,%20float,%20float)) then [compare with this](https://stackoverflow.com/a/4126159/4858751) – davidchoo12 Oct 10 '17 at 06:21

1 Answers1

0

It's a little unclear what you mean by this sentence:

but the color also depends on S and V value and the color shade changes upon changing these values.

Your list only contains the 10 colors and not, for example, light blue. So from what I understand, your best bet is to check the hue values as someone suggested, and maybe use the S and V values to determine closeness to blacks or whites. I found the following article very useful for understanding the HSV color scheme: http://learn.leighcotnoir.com/artspeak/elements-color/hue-value-saturation/

If you can explain more, I will be happy to try and help further.

Sami
  • 83
  • 2
  • 10