In a JPEG image, we may have thousands of distinct RGB values.
What is the process called of translating these numerous RGB values to just N distinct colour names/values?
(I'd like to know the name for the process so I could read on it).
I want to create a Python script that will get a JPEG as input and convert each pixel to only N colour names.
E.g., assume my colours are as in the table below.
I'd like to go over each pixel in the input image, find the RGB value in the table that is the closest to the current pixel's RGB value, and output for that pixel the corresponding colour name.
For instance, (220,0,12), (224,5,15), (223,1,10), and (216, 2,11) should all be translated to 'bright red'.
Colour | R | G | B |
---|---|---|---|
medium blue | 70 | 138 | 196 |
bright orange | 229 | 28 | 23 |
transparent brown | 165 | 144 | 129 |
transparent medium reddish-violet | 236 | 155 | 193 |
bright yellowish-green | 147 | 183 | 10 |
bright reddish-violet | 154 | 0 | 96 |
transparent bright bluish-violet | 155 | 148 | 198 |
silver | 139 | 146 | 148 |
sand blue | 93 | 115 | 138 |
sand yellow | 139 | 115 | 81 |
earth blue | 0 | 35 | 63 |
earth green | 0 | 51 | 21 |
transparent flourescent blue | 205 | 226 | 245 |
metallic dark grey | 72 | 62 | 58 |
sand green | 94 | 128 | 100 |
dark red | 126 | 7 | 26 |
flame yellowish orange | 242 | 153 | 0 |
transparent bright orange | 235 | 117 | 13 |
reddish brown | 90 | 27 | 11 |
medium stone grey | 154 | 144 | 143 |
dark stone grey | 75 | 92 | 85 |
light stone grey | 227 | 227 | 217 |
light royal blue | 133 | 190 | 232 |
bright purple | 221 | 55 | 138 |
light purple | 237 | 156 | 194 |
cool yellow | 254 | 254 | 152 |
medium lilac | 43 | 20 | 118 |
light nougat | 243 | 191 | 135 |
phosph. green | 252 | 250 | 211 |
warm gold | 168 | 125 | 44 |
dark brown | 46 | 13 | 4 |
transparent bright green | 151 | 253 | 100 |
medium nougat | 168 | 124 | 84 |
white | 255 | 255 | 255 |
black | 0 | 0 | 0 |
transparent yellow | 248 | 238 | 104 |
transparent flourescent reddish-orange | 229 | 100 | 70 |
transparent red | 22 | 40 | 39 |
transparent light blue | 181 | 223 | 233 |
transparent blue | 78 | 175 | 230 |
transparent green | 97 | 176 | 108 |
transparent flourescent green | 242 | 238 | 92 |
transparent | 240 | 240 | 240 |
bright yellow | 255 | 197 | 2 |
bright red | 220 | 0 | 12 |
bright blue | 2 | 89 | 169 |
dark green | 3 | 126 | 43 |
nougat | 215 | 116 | 66 |
bright green | 1 | 150 | 37 |
brick-yellow | 218 | 188 | 125 |
dark orange | 165 | 60 | 20 |