Gamma correction the first – distorting linearity

You are here: Nature Science Photography – Contrast – Gamma correction


Now that we have taken a picture with our digital Fujiyamaruckzuck camera, we want to continue working with it. At this point, we come back to the fundamental difference mentioned above between our perception of contrast and that of an electronic image carrier. The sensor transforms the electrons received from the pixels nearly 1:1 into voltage values, which the A/D converter then quantizes. Therefore, if a scene is twice as bright as another, its voltage value, or binary value, will also be twice as high. This is evident from the characteristic curve we established earlier. However, our perception system prevents the doubling of intensity from appearing twice as bright to us. Brighter, but not twice as bright. In order to create the impression of twice as much brightness, we have to increase the intensity almost ninefold. This can be seen from the curve in figures 20 (Estimation of the brightness on a linear scale ) and 21 (Estimation of the brightness on a logarithmic scale ) in the section about „The minimum size of brightness differences“. For this reason, image files in .raw converters that display the preview image exactly according to the data appear much too dark. Their histogram subsequently displays a majority of the values on the left, or dark side.

A gradient chart illustrating a linear distribution of brightness. The gradient moves from dark gray on the left to light gray on the right, marked with data values 64, 128, 256, 512, 1024, and 2048 per exposure step.
Figure 50: Linear distribution of brightness values ​​on 11 bits (211 = 2048 data values)
A vintage truck is parked in front of an old wooden building under a clear blue sky. Two antique gas pumps stand nearby. The scene has an Old West ghost town vibe, with dry grass and mountains in the background.
Figure 51: Image before gamma correction – too dark
A screenshot of a histogram with black bars on a white background. The bars are clustered towards the left and taper off to the right, with a single prominent spike in the middle. The interface includes menus and a gray border.
Figure 52: Histogram before gamma correction


We deal with this by changing the gradient of the linear part of the characteristic curve, i.e. by applying the exponential function known from the “Contrast perception” section. We refer to this change as gamma correction or gamma encoding, as the slope of the curve is also known as the gamma value. This is a simple mathematical operation in which each data value is exponentiated by the reciprocal of the gamma value. The .raw converter does the calculation for us photographers. It does this either automatically with a given gamma value or leaves it to us to set it manually.

Formula 17

The characteristic curve then looks like in figure 56 (C-curve gamma correction), the too dark image shown at the beginning appears in the correct brightness, and its histogram shows a normal distribution of the brightness values. The first thing to notice about this curve is the similarity to the one in figure 20 (Estimation of the brightness on a linear scale) and this is not a coincidence. Moreover, we observe that the exponential transformation of the data results in distinct curve forms, contingent on whether we output them on linear or logarithmic scales. On log-log axes, as in figure 25 in the section „Factors we must take into account to meet requirement 0: Factor 2 – Ambient brightness“, this resulted in a sloped curve but unchanged in shape. Here, on linearly scaled axes, we see a graph bent outward in the middle.

The following two paragraphs will clarify exactly how high the gamma value must be, providing two more equally important reasons for the necessity of gamma correction.

Grayscale gradient image showing gamma-corrected brightness distribution. It transitions from dark on the left to light on the right in six equal sections. Text below explains data values make brightness differences appear equally spaced.
Figure 53: Gamma corrected distribution of brightness values
A vintage truck is parked in front of an old wooden building under a clear blue sky. Two antique gas pumps stand nearby. The scene has an Old West ghost town vibe, with dry grass and mountains in the background.
Figure 54: Image after gamma correction
A histogram displayed in a software window, showing a distribution with peaks towards the right side. The x-axis represents luminance levels, and the graph has significant activity in the highlights region, indicating a bright image.
Figure 55: Histogram after gamma correction
A screenshot of a curves adjustment window in photo editing software, showing a curve line on a histogram graph. The curve is adjusted to lighten the image, with a highlighted peaks graph on the right. Options include OK and Cancel buttons.
Figure 56: Tone curve after gamma correction

Next Gamma Correction the Second – Compensating the Monitor Properties

Main Contrast

Previous Requirement 0 in the digital area

If you found this post useful and want to support the continuation of my writing without intrusive advertising, please consider supporting. Your assistance goes towards helping make the content on this website even better. If you’d like to make a one-time ‘tip’ and buy me a coffee, I have a Ko-Fi page. Your support means a lot. Thank you!

0 - 0

Thank You For Your Vote!

Sorry You have Already Voted!

Join the discussion

Pleased to meet you!

Since I started my first website in the year 2000, I’ve written and published ten books in the German language about photographing the amazing natural wonders of the American West, the details of our visual perception and its photography-related counterparts, and tried to shed some light on the immaterial concepts of quantum and chaos. Now all this material becomes freely accessible on this dedicated English website. I hope many of you find answers and inspiration there. My books are on www.buecherundbilder.de

If you feel that reading JCSCZEPEK.com is worth the price of a few coffees, I’d greatly appreciate your support via my Ko-Fi page. Every donation energizes me to keep the thing going.

Thank you!
Jörg

jcsczepek.com