Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert RGB code to 8 simple intervals (possible ?)

I'm working on my Final Bachelor Project in Computer Science and for now I'm in a dead end. Here is what I got stuck on:

I'm trying to classify any color (rgb code) in any of 8 (eight) simple colors. In short terms I need to find 8 intervals where any colour can be placed and be considered a basic color (red, blue, green, black, yellow, purple, grey, brown ).

example:
(18,218,23) to be classified as "green"
(81,,214,85) also "green"
but
(15,52,16) needs to be "black"
(110,117,110) needs to be "grey"

So there are 256 x 256 x 256 possible colors and I need to divide them in 8 (intervals) basic colors.

I'm waiting for some suggestions.

Cheers !


To be clear (as I've seen in comments) I'm looking for a particular set of 8 colors (red, black, green, brown, blue, purple, grey, yellow). Sorry for the orange above !

like image 267
VladU Avatar asked Dec 06 '22 14:12

VladU


1 Answers

Don't do this in RGB, convert to a more convenient color space HSV is probably easiest - then the 8 "colors" are simply 8 intervals along the Hue axis.

like image 78
Martin Beckett Avatar answered Jan 09 '23 23:01

Martin Beckett