<p>According to Wikipedia (insert standard disclaimer RE accuracy):</p>

<blockquote>
  <p>JPEG does not define which color encoding is to be used for images. JFIF
  defines the color model to be used: either Y for greyscale, or YCbCr as
  defined by CCIR 601.</p>
</blockquote>

<p>YCbCr is a non-linear format. As I mentioned earlier, "Video Demystified" states:</p>

<blockquote>
  <p>"YCbCr is the color space originally defined by BT.601, and now used for
  all digital component video formats. .... The technically correct notation
  is Y'Cb'Cr' since all three components are derived from R'G'B'."</p>
</blockquote>

<p>and Charles' Poynton's <a href="http://poynton.com/notes/colour_and_gamma/ColorFAQ.html" rel="nofollow">Colour FAQ</a> states</p>

<blockquote>
  <p>Video systems approximate the lightness response of vision using R'G'B'
  signals that are each subject to a 0.45 power function.</p>
</blockquote>

<p>With compression we are after the best visual representation per bit and, as the eye is non-linear in approximately this way, it makes sense to use non-linear representations.</p>

CC BY-SA 3.0
2015-09-14T23:06:07.037Z
From these details, as I understand it, JPEG expects the input RGB values to be encoded in a way that the display will apply a power function upon display. In order to recreate those specific RGB values, they should *not* be corrected prior to encoding.
Mokosha
CC BY-SA 3.0
2015-09-15T08:24:24.187Z
The trouble with stating it like that is that it's a bit ambiguous. We should probably state that, if your "RGB" data is, in fact, R'G'B' (and let's assume sRGB falls into that category) then you shouldn't modify the values before applying the R'G'B'=>YCbCr matrix.  If, however, the data has, say, been computed with a renderer (so possibly linear), been processed using downscaling (which should be done in linear space) or, say, captured (and cleaned up) with a CCD (which I think is linear), then it has to be remapped prior to JPEG compression.
Simon F
CC BY-SA 3.0
2015-09-11T08:22:01.553Z
2015-09-11T08:22:01.553Z
Simon F
<p>The short answer is "no", for reasons covered in <a href="http://www.alvyray.com/memos/CG/Microsoft/9_gamma.pdf">Alvy Ray Smith's memo, <em>Gamma Correction</em></a>. Gamma is not about nonlinearity in human perception, it's about nonlinearity in display devices (and, I suppose, acquisition devices too).</p>

CC BY-SA 3.0
2015-08-23T04:25:08.513Z
2015-08-23T04:25:08.513Z
Pseudonym
<p>When an image is encoded using JPEG, the RGB pixels are first encoded into YUV, and then the UV channels are downsampled. Before actually doing the DCT and encoding the coefficients, JPEG <a href="http://www.w3.org/Graphics/JPEG/jfif3.pdf">doesn't gamma correct</a> the Y channel. Is this correct? Shouldn't we determine the DCT coefficients that will most affect our viewed result?</p>

CC BY-SA 3.0
2015-08-22T12:27:02.963Z
I dont know but it certainly does make sense not to gamma correct.
joojaa
CC BY-SA 3.0
2015-08-22T19:55:49.240Z
I'm not posting this as an answer since I'm not confident in it, but human vision's perception of brightness is *not* linear. In fact, sRGB does a quite good job of compensating for that and giving the most precision in the areas that matter. So you might find that gamma correcting before compressing luma may actually yield worse results.
yuriks
CC BY-SA 3.0
2015-08-24T07:54:04.493Z
AFAIK, video standards assume R'G'B', ie. a non-linear colour space, when applying the 3x3 colour transforms to/from YCbCr.  In an application such as video where one wants to maximise quality per bit, it doesn't make sense to use linear.
 I think sections 27 and 29 of Charles Poyton's Color FAQ express it more clearly: http://poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC27
Simon F
CC BY-SA 3.0
2015-08-24T08:07:05.627Z
"Video demystified" also says: _"YCbCr is the color space originally defined by BT.601, and now used for all digital component video formats. .... The technically correct notation is
Y'Cb'Cr' since all three components are derived from R'G'B'."_
Simon F
CC BY-SA 3.0
2015-09-15T02:23:33.447Z
The gamma exponent is stored in JPEG exif data. most software totally ignore it. but you can assume than after decoding a jpeg its already in gamma space so there is no conversion to do before sending the rgb value on the display buffer.
v.oddou
<compression><gamma>
Should JPEG encoding take into account gamma?
Mokosha
# Should JPEG encoding take into account gamma?

(Asked by: username_0 on 2015-08-22)

When an image is encoded using JPEG, the RGB pixels are first encoded into YUV, and then the UV channels are downsampled. Before actually doing the DCT and encoding the coefficients, JPEG [doesn't gamma correct](http://www.w3.org/Graphics/JPEG/jfif3.pdf) the Y channel. Is this correct? Shouldn't we determine the DCT coefficients that will most affect our viewed result?

**Tags:** compression, gamma

> **Comments:**
> **username_1**: I dont know but it certainly does make sense not to gamma correct.  
> **username_2**: I'm not posting this as an answer since I'm not confident in it, but human vision's perception of brightness is *not* linear. In fact, sRGB does a quite good job of compensating for that and giving the most precision in the areas that matter. So you might find that gamma correcting before compressing luma may actually yield worse results.  
> **username_3**: AFAIK, video standards assume R'G'B', ie. a non-linear colour space, when applying the 3x3 colour transforms to/from YCbCr.  In an application such as video where one wants to maximise quality per bit, it doesn't make sense to use linear.  I think sections 27 and 29 of Charles Poyton's Color FAQ express it more clearly: http://poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC27  
> **username_3**: "Video demystified" also says: _"YCbCr is the color space originally defined by BT.601, and now used for all digital component video formats. .... The technically correct notation is Y'Cb'Cr' since all three components are derived from R'G'B'."_  
> **username_4**: The gamma exponent is stored in JPEG exif data. most software totally ignore it. but you can assume than after decoding a jpeg its already in gamma space so there is no conversion to do before sending the rgb value on the display buffer.  

---

## 2 answers

### Answer by username_3 on 2015-09-11. Score: 2 | Accepted answer

According to Wikipedia (insert standard disclaimer RE accuracy):

> JPEG does not define which color encoding is to be used for images. JFIF
> defines the color model to be used: either Y for greyscale, or YCbCr as
> defined by CCIR 601.

YCbCr is a non-linear format. As I mentioned earlier, "Video Demystified" states:

> "YCbCr is the color space originally defined by BT.601, and now used for
> all digital component video formats. .... The technically correct notation
> is Y'Cb'Cr' since all three components are derived from R'G'B'."

and Charles' Poynton's [Colour FAQ](http://poynton.com/notes/colour_and_gamma/ColorFAQ.html) states

> Video systems approximate the lightness response of vision using R'G'B'
> signals that are each subject to a 0.45 power function.

With compression we are after the best visual representation per bit and, as the eye is non-linear in approximately this way, it makes sense to use non-linear representations.

> **Comments:**
> **username_0**: From these details, as I understand it, JPEG expects the input RGB values to be encoded in a way that the display will apply a power function upon display. In order to recreate those specific RGB values, they should *not* be corrected prior to encoding.  
> **username_3**: The trouble with stating it like that is that it's a bit ambiguous. We should probably state that, if your "RGB" data is, in fact, R'G'B' (and let's assume sRGB falls into that category) then you shouldn't modify the values before applying the R'G'B'=>YCbCr matrix.  If, however, the data has, say, been computed with a renderer (so possibly linear), been processed using downscaling (which should be done in linear space) or, say, captured (and cleaned up) with a CCD (which I think is linear), then it has to be remapped prior to JPEG compression.  

---

### Answer by username_5 on 2015-08-23. Score: 7

The short answer is "no", for reasons covered in [Alvy Ray Smith's memo, *Gamma Correction*](http://www.alvyray.com/memos/CG/Microsoft/9_gamma.pdf). Gamma is not about nonlinearity in human perception, it's about nonlinearity in display devices (and, I suppose, acquisition devices too).


---

