A Zero Math Understanding of Log Gamma

Log gamma recording is available from an increasing number of camcorders and even several DSLRs. When folks buy these cameras it’s a safe bet they are doing so with the intent of using, or at least trying, their new camera’s log option.

Over the last year, as I used cameras that offer log gamma (Canon C300 mkII, JVC GY-LS300, Sony FS5, and Canon XC10), I’ve wondered how many shooters understand log and understand why exposure settings when shooting log are necessarily different. I also wonder if some shoot in log mode, but with normal (BT.709) based exposure.

Perhaps our fuzzy understanding of log gamma is that log stands for logarithm. And, for many of us, our memories of logarithms are stored in the same brain region as “driver training” and “solid geometry.” To remove this mental block, I’ll explain log gamma using graphs—no logarithms and no math.

Dynamic Range

Why has log gamma become so popular? Because we believe it provides an extended dynamic range. When, however, we engage log mode nothing about the sensor’s dynamic range changes. The same amount of signal (plus noise) causes the sensor to output a binary code of “1.” And, the same amount of light causes the sensor to output it’s maximum binary value—typically from “4095” to “65535.”

Linear-light

Figure 1 shows the upper 6-stop output from a hypothetical 12-bit sensor that can provide a dynamic range of up to 12-stops. For each additional stop of light captured, the sensor’s output voltage becomes two times greater. In turn, after conversion from analog to digital data, the binary output values also double. This scheme is called linear-light.

Figure 1: Upper six stops of linear-light data from a 12-bit sensor

At its clipping point, my hypothetical 12-bit sensor outputs a binary value of 4095, which will be recorded at 108%. However, for simplicity, graphs in this article will range from a 0- to 100-percent.

Figure 2 shows the upper five stops—codes from 128 to 4095 from the sensor. Included in the Figure are 46-percent and 90-percent signal levels from 18% (middle-gray) Gray and 90% White cards, respectively. Cameras record “white” at levels from 90- to 96-percent while “middle-gray” is recorded from 42- to 46-percent. (The plotted positions for middle-gray and white are approximate.)

When light input is reduced by 1-stop, the binary output code decreases from 4095 to 2047. Using 2048 codes for one-stop (4095 to 2047) is inefficient because for all remaining stops, only 2048 codes are available. Code shortage forces the difference between, for example, stop -4 (a 255 code) and stop -5 (a 127 code) to be 128-steps while the difference between stop -9 (a 7 code) and stop -10 (a 3 code) is only 4-steps.

Figure 2: Upper five stops of linear-light data from a 12-bit sensor

Figure 3 dramatically shows the inefficiency of linear-light by plotting the number of tonal levels (binary codes) in each of the 12 stops.

Figure 3: Number of tonal levels in each of the 12 stops

The lower six stops from the sensor are shown by Figure 4. The increment between each of the lowest three stops is so small that to see them requires this second graph. The lowest stop is a 1-bit binary light verses no-light signal. This single bit, and the next higher stop (2-bits), does have value when measuring dynamic range using, for example, a DSC Labs chart. These 8-levels, however, are likely to carry noise as well as signal and thus provide little or no useful grayscale information. My hypothetical 12-bit sensor would more properly be considered to provide a 10-stop rather than 12-stop grayscale. This inherent loss of effective dynamic range explains why sensors are typically 14-bit and 16-bit devices.

Figure 4: Lower six stops of linear-light data from a 12-bit sensor

Before recording a video signal, linear-light data are processed by one of several possible gamma functions: BT.709, Hypergamma, or Log. Figure 5 presents these three options—each of which may have several sub-options.

Figure 5: BT.709 gamma correction, a Hypergamma (extended BT.709), and log gamma

BT.709 Gamma Correction

BT.709 is a Gamma Correction function that modifies a linear-light signal so the image is ready to view on a display. The blue line in Figure 6 represents a linear-light signal from the sensor. The result of a BT.709 Gamma Correction function applied to the linear-light signal is shown by the green curve.

Figure 6: Linear-light > 709 gamma correction > CRT gamma > Linear-light

When the recorded (green) signal is sent to a display, it is naturally converted to light in the manner described by its Gamma function. The arithmetic product of the Gamma function (purple) and the Gamma Corrected signal (green) becomes once again a linear-light signal (blue). Gamma correction enables unity transfer of information from sensor to display. To learn more about gamma correction, see my article, Looking Deeper into Log Gamma, which was published in March, 2016.

Log Gamma

Almost every visual representation of log gamma presents a comparison like that shown by Figure 7 which displays the increase in dynamic range provided by different log functions. Let’s look at log gamma in an entirely different way.

Figure 7: Marketing explanation of different log gammas

Figure 8 has two fundamental plots. The red, linear, plot presents a series of 12-bit sensor-output codes from 0 to 4095. The blue, curved, line results from a log function applied to each value in the input series. We can see linear data have been converted to logarithmic data.

Figure 8: Non-linear-light signal after log-function

I’ve added green vertical lines at one-stop intervals along the linear (red) plot. These lines, as expected, are spaced at uneven intervals just as they are in Figure 1. Where these lines intersect the log (blue) plot, I’ve placed horizontal lines that extend to the Y-axis. The result—a Y-axis where one-stop intervals are evenly spaced. Each stop now has the same number of binary codes.

The resulting step size (number of codes) is adequate to convey illumination differences meaningful for the human eye—at all captured light levels—without wasting binary codes. Equal, rather than unequal, steps is the most efficient way to transmit all meaningful information from the sensor though a narrow pipeline to editing/grading software.

The pipeline is the 8-bit, 10-bit, or in rare cases, the 12-bit recording system employed by today’s cameras. While a 12-bit system would be able to directly record linear-light data from my hypothetical 12-bit sensor, the 14- to 16-bit data from real sensors must necessarily be scaled down. Relative to the bit depth of the sensor, 10- and 8-bit recording employs a narrow pipeline.

Setting Exposure for Log Gamma

We know the sensor doesn’t function differently when one enables log mode, so how is dynamic range increased? The answer is revealed by a more complete statement; log gamma increases dynamic range over the dynamic range provided by BT.709. Thus, to understand log gamma we need to see how it differs from BT.709 gamma.

Figure 9 shows optimum recorded signal levels used by three different cameras from exposure to an 18% Gray card and a 90% White card. The chart shows the White signal level shifted from 90-percent downward—depending on the type of log gamma—to an average 62-percent. Likewise, middle-gray (18% Gray card) is decreased from 46-percent to an average 36-percent.

Figure 9: Typical 18% Gray card and 90% White card log gamma exposure values

Figure 9: Typical 18% Gray card and 90% White card log gamma exposure values

The Y-axis of Figure 8 has been rotated to become the X-axis for Figure 10. The red line indicates the approximate position of the 90-percent (BT.709 White) signal while the blue line indicates the position of the 62-percent (Log White) signal. The horizontal green arrow shows the decrease in the signal for white levels.

This downward shift provides an increase in headroom. The increased headroom makes possible a greater dynamic range. Or, more properly stated, the increase in headroom allows the highlights to be less compressed than they are when BT.709 Gamma Correction is employed.

Figure 10: Lower exposure results in greater dynamic range

Shooting log also results in a lower signal level for middle-gray. The signal level decreases from 46-percent (orange line) to 36-percent (violet line).

Visually, the downward exposure shift reduces image brightness. When present in a scene bright highlights will, however, be part of the image. This, of course, is the value of log gamma.

Most video cameras are designed so color saturation increases with image brightness. (This explains one reason why video looks different than film.) When shooting log, image brightness is decreased thereby resulting in lower image saturation. Both lower average brightness and lower saturation yield the flat look characteristic of log gamma video.

Dual Zebras

Figures 11 and 12 present the upper and lower stops of a video signal after it has been log processed. To obtain correct exposure from my hypothetical 12-bit sensor, I would need to expose an 18% Gray card at 36-percent or a 90% White card at 62-percent. To accomplish this, my camera should offer dual zebras. I would set the lower zebra at either 30% or 60% while the upper zebra would set to either 40% or 70%.

Figure 11: Upper eleven stops of log gamma data from a 12-bit sensor

Figure 12: Lowest stop of log gamma data from a 12-bit sensor

Setting ISO

A sensor typically delivers maximum dynamic range at its nominal sensitivity. Therefore, be sure to set ISO appropriately when shooting log. Some cameras, however, provide their best dynamic range when they are set to a very specific ISO setting. These cameras either automatically switch to the appropriate ISO when log mode is selected, or the camera’s documentation should specify the correct ISO.

Figure 13 shows the log signal when about 1.5 stops of gain have been applied. Headroom naturally is decreased while shadow detail is increased. (Shadow noise may be lower after grading because when grading, less gain will need to be added to the shadows in order to increase shadow detail visibility.) As you can see, the result is a balanced -6/+6 stop dynamic range centered on middle-gray.

Figure 13: A balanced -6/+6 stop dynamic range centered on middle-gray

Types of Log Gamma

The log signal from my hypothetical 12-bit sensor resulted from applying a simple log function to the linear sensor signal. The processing realities within cameras are very different. Cameras process sensor data to create a match between their sensor and their manufacturer’s desired image goals. Goals—because most cameras offer multiple types of log gamma curves for different purposes. Sony, for example, supports three log curves: S-Log1, S-Log2, and S-Log3.

To accomplish the desired data transformation, sensor data are processed in a more complex way than simply applying a log function. Figure 14 shows that one example of complex processing enables the critical mid-tone areas to have more tonal increments (grayscale) over a 6-stop range, while still yielding a wide dynamic range. You can see how the distance between stops is greater from 3 stops below middle-gray to 3 stops above middle-gray.

Figure 14: Enhanced grayscale from -3-stops to +3-stops about middle-gray

Selecting log gamma mode, or selecting from one of several log gammas, determines the manner in which the linear-light signal from a camera’s sensor is transferred to your editing/grading software.

Log Mode and Color Gamut

In many cameras, in addition to enabling log mode, you have the option to select the colorspace of the recorded data. Figure 15 shows five gamut options. (sRGB colorspace is equivalent to BT.709.) There are even larger gamuts such as Canon’s Cinema gamut that is far larger than REC.2020 and is designed to provide a gamut far closer to that provided by motion picture film.

Figure 15: Five gamuts—from SD to HDR UHD

A camera that provides 14-stops (or more) dynamic range, an appropriate log gamma, and a BT.2020 gamut—will capture source material that can become HDR content.

Editor’s note:

See other Steve Mullen tutorials listed below:

Let us know what you think…

Log-in or Register for free to post comments…

You might also like...

The Iris-less Lens: Has Its Time Finally Come?

An Iris-free lens? This revolutionary technology will be here soon. But what will it mean to shooters and videographers and the images they capture?

What Does “A Look” - Look Like?

Broadcasters and videographers use various strategies and elements of craft to effectively communicate our stories to viewers. First and foremost, the storytelling imperative requires a clear communication of genre.

Here a LUT…There a LUT

A way too cute title—I agree. But LUTs are indeed everywhere. Before we look at the ways LUTs are used, let’s be sure we understand what a LUT does.

Field Report: Canon XC10 Camera

After twenty-five NAB shows I’ve developed a pattern of booths to visit each day. At NAB 2015 walking though a series of expensive C-series cameras in the Canon booth, I encountered a new species of video camera—the XC10. (Figure 1). …

Articles You May Have Missed

Moving to an IT/IP infrastructure is more than just bits, it is also about image/file size. Facilities will soon need to move from current HD-size files to 4K-size files. For those technical managers charged with this transition, you…