I have a bespoke Image Capture & processing flow, wherein I do the following operations:-

Capture Raw data-->De-Bayer(Get RGB)-->Color Balance-->RGB-to-YCbCr-->Image sharpening-->Denoise filtering-->YCbCr-to-RGB-->Gamma correction(Gamma encoding)-->Store the file as BMP.

But now as some new requirement, I need to store the final output file in YUV/YCbCr format. So the new flow would be:

Capture Raw data-->De-Bayer(Get RGB)-->Color processing-->RGB-to-YCbCr-->Image sharpening-->Denoise filtering

My questions is now where should I apply the Gamma correction, since there is no conversion back to RGB space after the image sharpening and denoise filtering in YCbCr space?

Will it yield same/similar image quality when viewed, if I apply gamma correction in RGB space after Color balance, before it is converted to YCbCr space and thus before Image sharpening and denoising?

Any pointers appreciated.

thank you.



4 Answers 4


Gamma should be applied on luminance (Y in your case) as it pertains to contrast.

There should be no reason to do it in RGB. I suspect many programs do it independently on each channel rather than on luminance to avoid converting back and forth. Results should actually be at least a little better doing it on luminance.

  • \$\begingroup\$ But then Gamma also means how colors look on the screen. So why not apply on chrominance channels(Cb,Cr)? \$\endgroup\$
    – goldenmean
    Commented Feb 18, 2011 at 14:42
  • \$\begingroup\$ @goldenman - Not really. Think about the standard gamma test where you have a solid block of color near alternating stripes of color and black. The relation between the solid color and the way our eye sees the average of the stripes is about the luminance curve of the display (or medium in case of prints). \$\endgroup\$
    – Itai
    Commented Feb 18, 2011 at 15:57
  • \$\begingroup\$ And I guess Gamma should be related to brightness (perceived intensity), rather than contrast.Correct me if wrong. But got your point about Gamma related more to Luminance component than chrominance component. \$\endgroup\$
    – goldenmean
    Commented Feb 18, 2011 at 16:12
  • \$\begingroup\$ @goldenmean - Yes! Note that brightness and contrast are correlated on most displays. It is hard to change contrast or brightness without affecting the other. That is why the contrast ratio of a display is computed at a specific brightness. \$\endgroup\$
    – Itai
    Commented Feb 18, 2011 at 16:23

The BT.709 standard as does the sRGB standard define that gamma correction should be applied to each RGB channel independently, not only on the Luma channel as the first answer implies.


Brightening gamma in Luminance channel tend to change the perception of colour. Satuaration seems to increase, particularly yellow, since yellow maxes out luminance next to white.

Left column: RGB

Right column: Y in YUV

Top: brightening gamma

Bottom: darkening gamma.

gamma in rgb vs y in yuv

I think RGB gamma is more pleasing/intuitive when brightening and Y gamma when darkening.



Other notes: WB and noise reduction is normally done on the raw before demosaicing when that data is available.

  • \$\begingroup\$ I am intrigued by your last note. Why do you believe this is true? Do you have any references on your claim? \$\endgroup\$ Commented Jan 6, 2017 at 9:44
  • \$\begingroup\$ I see it done in dcraw as well as in firmware of machine vision cameras \$\endgroup\$ Commented Feb 20, 2017 at 22:54
  • \$\begingroup\$ it also makes sense to do it at that point, where you know the balancing will be correct - it is a pretty linear task to rebalance the light, if we ignore the fact that blue is not perfectly only sensitive to blue. You want to wipe out the fact that the sensor is more sensitive to green than blue, and the light has a bit more red than green. After that , that flat white has r,g,b pixels all flattened. If you wait till after demosaicking you'll be balancing on artifacted material. you risk enhancing the errors. \$\endgroup\$ Commented Feb 20, 2017 at 23:03

Consider Capture Raw data--> white balance --> gamma --> De-Bayer(Get RGB)

  • \$\begingroup\$ Why that order? And what about the YCbCr conversion? Not really a helpful answer without at least some explanation. \$\endgroup\$
    – MikeW
    Commented Sep 1, 2014 at 21:46
  • \$\begingroup\$ The order allows to handle white balance while still in linear space, and not be concerned with gamma at later stages. YCbCr conversion goes the standard way, as YCbCr conversion starts with gamma-encoded RGB. In case you want to go with linear encoding, it is YcCbcCrc. \$\endgroup\$
    – Iliah Borg
    Commented Sep 1, 2014 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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