# Where in the world is Middle Gray?

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 (peak white), a properly configured Middle Gray card will result in a reading of 0.18, or 18% 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% IRE for Middle Gray, but that’s not quite right. 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 for sRGB is therefore defined as 46.6% IRE and not 50% or whatever value quoted by some random YouTuber or forum user on the internet.

Following similar methods from above, we can also calculate the Rec.709 Gamma Middle Gray value 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. Conversely, many Log curves are often defined in the context of full data ranges – Panasonic’s V-Log is one example that uses 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 value for Rec.709 Scene:

$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 these 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, right click on it and select the “Save Image” option on your browser.