I'm working on a image processing system to segment three different types of pixels that are more or less Yellow/Red/Black.

Now my question - which I though it's best to be asked here - is that which Color system can best best differentiate these three colors in numeric values?

For example if we use RGB, Yellow and Red pixels, will have very similar values in their Red channel (close to 255) which makes it not a good choice for this purpose.

Hope my question is clear.


  • Is this question related to photography, or graphic design? If the latter, we have another site where you might get more answers. – jrista Jul 22 '11 at 20:41
  • this question is about digital photos, as soon as there is a label for "image-processing" and "color" I think the question remains relevant – Mo Valipour Jul 22 '11 at 20:55
  • 2
    @velipour: I'm not really questioning its validity, just whether this is the best site for the question. If you are working with photos, I am assuming you are interested in the most perceptually accurate difference computations. I've provided an answer that describes the CIE Delta-E algorithms, which were specifically designed for that purpose. – jrista Jul 22 '11 at 21:00
  • 1
    Be aware that anyone with a small amount of site reputation can create tags. Their presence should not automatically mean that anything you could consider fitting into them is automatically on topic. This question appears to be about machine vision or some other industrial processing application, and not actually photography at all. If you can couch it in terms that make it relevant to photography, though, it'd be fine. – Please Read My Profile Jan 31 '13 at 19:51

Probably HSV or similar. The color will be denoted by the H component and the intensity (to differentiate saturated red and yellow from black) by the V component.

However, black is not a color, but rather the absence of lighting/intensity/etc., so I don't think there is a system that will absolutely separate the black from the other two. What you are looking for is a 3-space spanned by a vector base formed by R, Y and K vectors. However, I think that K is always related to the other two (they are colors, K is not).

EDIT: Further thinking - K is equivalent to the 0 vector in almost all systems, which is why it cannot be a member of the base. However - checking the HSL system, this may be the required solution to your problem. I'll leave you to check how to convert RGB to HSL, and if I'm right here.

BTW: I think this question is at best marginally related to photography.

| improve this answer | |

If you are looking to do color difference computations, the best color space is probably Lab*. The Lab color space was designed for that kind of thing, and there are several algorithms called CIE Delta-E that provide color distance results. The original dE algorithm, CIE76 (1976) is a pretty strait forward euclidean distance algorithm. Improvements on that original algorithm have been made with CIE94 (1994) and CIEDE2000. Both of the updated algorithms take human perception into account, and aim to produce better perceptual distance results than the original CIE76 algorithm does.

Conversion from RGB to Lab can also be complex. This usually involves normalization of RGB color values into a white-point normal space (i.e. standard daylight at D65, or tungsten A), conversion from neutral RGB to XYZ, and finally conversion from XYZ to Lab. Overall, computing color distance with perceptual accuracy is a rather complex endeavor. If you wish to compute the difference in the native RGB color model, that is also possible. You can again do a simple euclidean distance computation:

delta = sqrt((r1 - r2)^2 + (g1 - g2)^2 + (b1 - b2)^2)

This will provide a color distance based on the RGB color model, which wile not particularly ideal for perceptually accurate distance computations, would be sufficient for most general needs.


| improve this answer | |

You can slice a layercake out of HSV space, but since you'd like red, which in H space is not continuous, and HSV is not a small computation, and defining a layer cake slice shape in a data space is not easy either, you might be better off by thresholding (r+g+b) < Tblack for black, and excessive red (2*r-g-b) > Tred and excessive yellow (r+g-2*b) >Tyellow

Here you see:

colourchecker | excessive red | excessive yellow

r+g+b < Tblack | ex. red > Tred | ex. yell > Tyellow

segment colours

| improve this answer | |

I think "best" depends on what operating system and software you are using. Pro-Photo RGB is probably your most likely candidate, but other options exist that have even wider ranges. Also, what is your desired output?

| improve this answer | |
  • I believe the intention of the OP is a method for distinguishing the three colors, by maximizing the "distance" between them, and not really a question of gamut. – ysap Jul 22 '11 at 19:40
  • @ysap - You are probably right, because what you said confuses me, so I'm guessing I didn't get what the OP meant! I will vote you up! – dpollitt Jul 22 '11 at 19:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.