Where in the world is Middle Gray?

[Updated Table – 4 Nov 2023] It appears that in the digital world, nothing confounds people more than the concept of Middle Gray – second only to actually finding Carmen Sandiego. Where exactly is Middle Gray? Why are there so many different quoted values for Middle Gray and which value is actually correct? In this write-up, we will explore Middle Gray in a little more detail.

Firstly, let’s start with a disclaimer and a qualifier – there are numerous discussions around a “calibration constant” being set close to 12% or just below 18% or a Middle Gray at 18.4% based on CIELAB derived values. We won’t be going down that rabbit hole. To keep things simple, the most commonly used reference for Middle Gray is 18%, as presented on a typical Gray Card, and we will be referencing that value from here onwards.

So Middle Gray is 18% of what one may ask? Let’s look at this in the context of a Camera sensor. When a sensor captures raw data from a scene, it is captured in linear light. If we look at these values in terms of a 0 – 1 scale for an SDR signal, where zero results in no light being reflected and one results in all the light being reflected back (diffuse white), a properly configured Middle Gray card will result in a reading of 0.18, or 18% reflectance, with half of the light being reflected back. Where the real confusion begins is when this linear signal is then encoded into a separate Gamma such as Rec.709 or sRGB.

Throughout Internet and social media platforms such as Facebook and YouTube, one can find oh so many ill-informed statements that set arbitrary Middle Gray values at 50%, 42.5%, 38%, 43% or any other random IRE. These random values have no meaning without providing the Gamma context under which they have been defined.

Let’s take a look at sRGB for example. It is defined by the following transfer function which encodes linear light (V) into the sRGB Gamma (VsRGB):

\[ V_{sRGB}=\begin{cases} 12.92 \times V & \phantom{–}\text{for $V\leq$ 0.0031308}\\ 1.055 \times V^\frac{1}{2.4}\space-0.055 & \phantom{–}\text{for $V>$ 0.0031308} \end{cases}\]

If we plug the linear light value of 0.18 for Middle Gray into the equation, we can then obtain the result:

\[ V_{sRGB} = 1.055 \times 0.18^{\frac{1}{2.4}}\space-0.055 = 0.461356\] \[0.461356 \times 100 = 46.1\%\]

To the average person, this may equate to 46.1% for Middle Gray, but that’s not quite the full picture. To get the IRE value, we must then perform a further calculation (assuming 10-bit values):

\[ IRE_{sRGB} = \frac{(V_{sRGB} \times 1023) \space – 64}{940 – 64} \times 100 = 46.6 \% \]

The Middle Gray IRE for sRGB is therefore defined as 46.6% and not 50% or whatever value quoted on some random YouTube video or by someone on the internet.

Following similar methods from above, we can also calculate the Rec.709 Gamma Middle Gray IRE from the ITU-R BT.709 transfer function:

\[ V_{R709} = 1.099 \times 0.18^{0.45} \space-0.099 = 0.409\] \[ IRE_{R709} = \frac{(V_{R709} \times 1023) \space – 64}{940 – 64} \times 100 = 40.5 \% \]

But there is a catch – these are data values, which are defined in the full range (0 – 1023 for a 10-bit signal). In the video world, many encoding curves are often defined in the context of Video Legal ranges (64 – 940 for a 10-bit signal). The ITU-R BT.709 and the ITU-R BT.2100 HLG curves are prime examples of this as they are defined using legal ranges (though Rec.709 can also be encoded using the full data range). Conversely, many Log curves are often defined in the context of full data ranges – many Cineon Log derived curves such as Panasonic’s V-Log are some examples that use the full data range for encoding. It’s important to confirm whether the relevant Log curve uses full data levels or video legal levels before attempting to derive the relevant Middle Gray value.

Getting back to the math, in order to convert a data signal to a video legal range, we must use the quantization equation defined by the ITU:

\[V_{Legal} = (219 \times V_{Full} \space + 16) \times 2^{(n – 8)} \phantom{—} \{n = \text{bit depth}\} \]

If we plug this into the IRE equation and then simplify, we get the following Middle Gray IRE value for Rec.709 Scene in the video legal range:

\[ IRE_{R709} = \frac{(219 \times V_{R709} \space + 16) \times 2^{(10 – 8)} \space – 64}{940 – 64} \times 100 = V_{R709} \times 100 = 40.9 \% \]

In the case of gamma curves that use video ranges, the Middle Gray IRE value can be obtained directly from the transfer function without the need to perform additional quantization and IRE calculations.

One can also verify the Middle Gray values on a NLE such as DaVinci Resolve by downloading the Linear Gray Chart below and performing the relevant Color Space Transform from Linear to the desired Gamma. The chart below shows Absolute Black, Middle Gray and Absolute White on a linear scale. To download the image, click on the download button further below.

Linear Middle Gray Chart

This chart can also be generated using a DCTL (DaVinci Color Transform Language) that I have released alongside others on GitHub. To use the DCTL, simply add the transform through the DCTL ResolveFX plugin on a node in the Color page and select Linear as the Gamma setting. Ensure this is followed by a Color Space Transform node going from Linear to the desired gamma setting.

Whilst math calculations are always the most accurate method of identifying a Middle Gray IRE, it’s understandable that this may not be everyone’s strong point and the transfer equation calculations can sometimes get complicated. As an alternative, the Middle Gray values for other gamma curves can also be found (with some rounded precision) by using a Waveform in DaVinci Resolve (or a similar NLE) and changing the output Gamma setting via a Color Space Transform. The Low or High reference level on the Waveform settings can then be manually adjusted to align with the Middle Gray block from the Chart – just ensure the Tone Mapping and OOTF options are disabled. DaVinci Resolve uses data levels internally, so the default waveform view will always show results based on a full signal range.

In some NLEs such as DaVinci Resolve, the Waveform scale can be adjusted between 8-bit, 10-bit and percentage values. It’s important to note that the Middle Gray result shown on a Waveform Monitor may not always be an IRE value. In some scenarios, the Waveform is simply showing the output of the transfer curve equation on a scale. If using an 8-bit scale, the output is multiplied by 255, if using a 10-bit scale, the output is multiplied by 1023 and if using percentage, the output is multiplied by 100, with all values being rounded to the nearest whole integer. Using the Rec.709 transfer curve as an example, for a Waveform using Data levels (and not IRE values), the Middle Gray values are calculated as per below:

\[ V_{R709} = 1.099 \times 0.18^{0.45} \space-0.099 = 0.409\] \[\text{8-bit Value}\ = 0.409 \times 255 = 104 \] \[\text{10-bit Value}\ = 0.409 \times 1023 = 418 \] \[\text{Percentage Value}\ = 0.409 \times 100 = 41\% \]

Following the Waveform guide above, when the ITU-R BT.709 (Rec.709 Scene) Gamma curve is applied on the Linear Gray Chart, the Middle Gray value shows an output of 41% on the Waveform – exactly as per our calculations, albeit rounded to the nearest whole integer.

Gray Chart Rec.709 Test in Resolve

The vast majority of Waveforms will display a signal using either full data levels or IRE values. If this is the case for your particular Waveform, ignore the equations that follow as they may cause further confusion.

For Waveforms shown with data levels transposed into Video Legal ranges (and not IRE values), we can simply use an equation quoted earlier to obtain the target legal values, ensuring we round to the nearest whole integer:

\[V_{Legal} = (219 \times V_{Full} \space + 16) \times 2^{(n – 8)} \phantom{—} \{n = \text{bit depth}\} \] \[\text{8-Bit Legal} = (219 \times 0.409 \space + 16) \times 2^{(8 – 8)} = 106\] \[\text{10-Bit Legal} = (219 \times 0.409 \space + 16) \times 2^{(10 – 8)} = 422\]

To obtain the Waveform output in percentage values using the Video Legal range, we can use a simplified version of the Quantization equation to calculate the percentages:

\[ V_{Legal} = (0.85546875 \times V_{Full} + .0625) \times 100 \] \[ \text{Percentage Legal} = (0.85546875 \times 0.409 + .0625) \times 100 = 41\%\]

Now that we’ve elaborated on the mathematical functions and a somewhat rudimentary method of identifying Middle Gray using a Waveform in applications such as DaVinci Resolve, I’ve documented some commonly used values for future reference in the table below. Hopefully this write-up has been somewhat useful in clarifying any misconceptions surrounding Middle Gray.

Gamma CurveMiddle Gray IRE
(Full Range)
Middle Gray IRE
(Legal Range)
sRGB46.6%46.1%
ITU-R BT.709
(Rec.709 Scene)
40.5%40.9%
Gamma 2.246.3%45.9%
Gamma 2.449.9%48.9%
Gamma 2.653.1%51.7%
Hybrid Log Gamma (HLG)21.2%
HLG BT.240837.8%
Panasonic V-Log / V-Log L42.1%
Sony S-Log37.7%
Sony S-Log232.3%
Sony S-Log340.6%
Leica L-Log43.5%
Fujifilm F-Log46.3%
Fujifilm F-Log238.4%
Arri LogC38.1%
GoPro Protune68%
GoPro GP-Log (Firmware < 1.20)49.1%
GoPro GP-Log (Firmware ≥ 1.20)76.3%
Nikon N-Log35.2%

4 Replies to “Where in the world is Middle Gray?”

  1. Thank you for the blog content, it was very professional and I spent hours reading and trying to understand it. I still have some questions about when to use it.

    For example, when closing the picture profile with sony A7M4 and recording a video, the color space of the video is rec709 and gamma is ITU-R BT.709-5 (which should be equal to gamma2.4), so should I use 48.9% IRE as the exposure reference for 18% gray when using zebra? However, You also mentioned in the article that the exposure of ITU-R BT.709 should be referenced at 40.9% IRE. This confuses me.

    In addition, most computer monitors have a gamma value of 2.2, and the gamma of mobile phone screens is also about 2.2, so what if I need to ensure that the gamma of the project is also 2.2 when I produce these video content?

    1. Hi,

      The transfer function for ITU-R BT.709 is completely different to the Gamma 2.4 transfer function. These two are often used interchangeably but are completely different.

      The Middle Gray for Gamma 2.4 is 48.9% IRE [Equation: 0.18 ^ (1 / 2.4) = 0.489]
      For ITU-R BT.709, the equation is shown in the write-up and mid-gray is equal to 40.9% IRE

      You can normalize the Rec.709 footage to Gamma 2.2 in programs such as DaVinci Resolve using Color Management, or a simple Color Space Transform going from Rec.709 (Scene) to Gamma 2.2

  2. Many thanks for your post, I understand a lot more about this topic thanks to you!
    I’m tyring to follow your thought process but there’s a point where I’m stuck, how do you come with this :

    IREsRGB= ((VsRGB×1023)–64 / (940–64) ×100) =46.6%

    Is it to convert the sRGB value from 0-1 to 10 bits ? (why -64 and why 940?)
    And if so, why do we need to convert to 10bits to find the IRE ?

    It’s probably me missing something very simple and you made a very good work already to explain, but I would like to fully understand the whole article.

    1. 64 and 940 (or 16 & 235 for 8-bit) are the black and white points respectively for a legal video signal. Anything below or above these points is outside the legal range.

      I have substituted 10-bit values, but you could use 8-bit or any other bit-depth.

      The actual bit-depth is dependent on your camera or tool. Most cameras output 8-bit signals whilst more recent ones output 10-bit signals. Generally speaking, the higher the bit-depth, the better the detail and accuracy.

Leave a Reply to xtremestuffCancel reply