I am writing an application with multiple colored surfaces. I would like to preserve luminance, i.e. a blue surface would appear as bright as a green one, are there tools to help for this?

  • $\begingroup$ Can you give some more details? Are you rendering a 3d scene? What is happening right now to cause your luminance not to be preserved? Are you just trying to render without lighting? It might also be useful info to know what you are using to render: OpenGL, DirectX, other? $\endgroup$ – Alan Wolfe Sep 29 '16 at 21:12
  • $\begingroup$ Rendering a 3D scene with OpenGL, ambient lighting only. I wanted blue to be as perceptually bright (if that's the correct term) as green. $\endgroup$ – Stackmm Oct 1 '16 at 1:26
  • $\begingroup$ I likely need to apply a conversion as the answer below suggests. $\endgroup$ – Stackmm Oct 1 '16 at 1:29

The usual way of doing this is to work in a color space that has luminance as one of the color components. For example the Y'CbCr color space has a luminance channel (you can think of this as similar to brightness which is a poorly defined term) and 2 chrominance or color channels. There are other color spaces that separate colors in this way, too, such as HSV, HLS, Lab, etc.

There are conversions to go between RGB and these various color spaces. The article linked above shows some of the conversions for going between Y'CbCr and sRGB, for example.

You don't say what type of graphics library you'll be using, so it's hard to give any more detail than what I've given you here. But I've done this in OpenGL, Core Graphics, and others. It shouldn't be too difficult.

Edited to add: I should point out that HSV defines value or "brightness" not as luminance but as the average of red, green, and blue, and as such does not track very will with our intuitive sense of brightness. HLS also suffers from some issues (discontinuities, bad but popular reference implementations) and is generally not recommended by the color scientists that I know.

  • $\begingroup$ Thank you, that was helpful. I will be checking out the conversions. I am using OpenGL. $\endgroup$ – Stackmm Sep 28 '16 at 3:24
  • $\begingroup$ For OpenGL, converting to and from YCbCr should just be a matrix multiply of your color value, so just a single instruction in a glsl shader. $\endgroup$ – user1118321 Sep 28 '16 at 3:40

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.