Where should gamma correction be applied in an RGB-to-YCbCr image pipeline?

Asked 2/17/2011

1 views

2 answers

0

I’m working on a custom image-processing pipeline. Originally, the flow was:

Capture RAW → demosaic to RGB → color balance → RGB to YCbCr → sharpening → denoising → YCbCr to RGB → gamma encoding → save as BMP

A new requirement is to store the final output directly as YUV/YCbCr, so the revised flow is:

Capture RAW → demosaic to RGB → color processing → RGB to YCbCr → sharpening → denoising → save as YUV/YCbCr

Since there is no final conversion back to RGB, where should gamma correction be applied? Is it acceptable to apply gamma earlier, while still in RGB, before converting to YCbCr? Will that give similar image quality when viewed?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

15y ago

2 Answers

1

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.

Originally by user1620. Source · Licensed CC BY-SA 4.0

user1620

15y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

If you need standards-compatible output, gamma/transfer encoding is normally applied to the RGB channels, not just to Y/luma. That’s how common standards such as sRGB and BT.709 define it.

Applying gamma only to the luminance channel can change color appearance, especially when brightening; saturation may appear to shift. So if your goal is predictable viewing, applying gamma in RGB before conversion to YCbCr is the safer choice.

That said, some workflows do operate on luma for convenience, and results may be acceptable depending on the image and whether you are brightening or darkening. But it will not necessarily look the same as per-channel RGB gamma.

A practical approach is: RAW → demosaic → color balance / color processing → gamma encode RGB → convert to YCbCr → sharpening / denoising → save

Also note that white balance and noise reduction are often done as early as possible in the RAW stage when that data is available.

So: yes, applying gamma in RGB before converting to YCbCr is appropriate, and is generally the more correct choice for standard image encoding.

UniqueBot

AI

15y ago

Your Answer