I am converting color from RGB to CIELab to train a GMM. When I get back the mean of clusters of the GMM I have sometimes negatives values in RGB space. I was wondering if the mean of only visible color can be non visible color ? Therefore I was also wondering if the visual color of CIELab forms a convex shape.

EDIT: I'm using Expectation-Minimization of OpenCV to train the Gaussian Mixture Model.

  • $\begingroup$ It sounds like your colors are out of gamut. Which RGB color space are you working in? $\endgroup$ – Emre Feb 5 '13 at 6:31
  • $\begingroup$ @Emre I guess it's the ISO RGB, where in normalized, (1,1,1) is white and (0,0,0) is black. I think I'm out of gamut but how can it be possible ? $\endgroup$ – Seltymar Feb 5 '13 at 7:11
  • $\begingroup$ How did you convert to and from Lab* and RGB? $\endgroup$ – Emre Feb 5 '13 at 7:55
  • $\begingroup$ @Emre I took the algorithm from this site easyrgb.com/index.php?X=MATH. I converted RGB to XYZ then XYZ to CIELab*. $\endgroup$ – Seltymar Feb 5 '13 at 8:17

You are implicitly using sRGB, a small color space. You might like to try using scRGB, a similar color space that allows such values.

The average of visible colors should also be visible, however the calculation should be performed in a perceptual color space for the result to be more meaningful; L*a*b* is better than sRGB.

Another question to ponder is whether the centers make sense in L*a*b*. Perhaps you have a bug?

  • $\begingroup$ Ok, I see that in fact, sRGB is very a small part of the visible color. But as all colors are taken in sRGB space, even after converting in Lab*, the mean should stay in the subset define by sRGB, right ? I am not sure as it is a gaussian. It can also come from a bug. $\endgroup$ – Seltymar Feb 5 '13 at 9:11
  • $\begingroup$ I think sRGB gamut in Lab is a non-convex shape, hence the line connecting two points can lay partly outside of the shape including its centroid (the color average). The resulting color can be theoretically out of sRGB gamut. You can make use larger RGB space (e.g. scRGB as Emre mentioned) or make use of some gamut mapping technique. $\endgroup$ – Libor Feb 7 '13 at 16:26
  • $\begingroup$ @Libor thank you. That sounds logic. I will try with the scRGB space. $\endgroup$ – Seltymar Feb 8 '13 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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