Author: Stefan Kohler
Presumably, each of you knows: You retouched forever on an image, retouched the fingers sore and if you want to show the final image quite strange rings in color gradients arises.
These rings are called “banding” and are nothing more than tonal value demolitions.
As you can see in the background, we have — just on the right side a problematic gradient, rather a staircase in the brightness curve. This is banding.
How is banding created?
You can break it down very easily: If there are more pixels than brightness levels, banding can occur.
Let’s take a look at how a colorful image is put together. We have three channels – red, green and blue. Each of these channels has up to 256 levels. So 256 * 256 * 256 different pixel values are possible. Different pixel values mean that they differ in luminance, hue or color saturation.
In our example we have the same value on all 3 channels because it is a black and white picture. So only 256 values available. The first dot (the brighter one in the middle of the picture) has an RGB value of 78, the second dot an RGB value of 28, the distance is 452px. In purely mathematical terms this means: 50 steps to 450px, so every 9px the value should change by one step. That should in theory still be a clean gradient with invisible levels – but it is not.
The measured case is, of course, the optimal case. During the editing, however, a lot was pushed back and forth, made a bit lighter here, a bit darker there. This of course changes the usable area and holes are created in the histogram.
With a tonal correction I enlarged the used area and marked the holes – so it is more visible:
These holes are breaks in the tonal values which show up as problematic gradients.
Problems caused by compression
To understand why banding can happen when uploading to the web, we shortly and superficially deal with the JPEG algorithm. How are pictures compressed?
- Compression by conversion to the YCbCr color model
The image is not saved as RGB channels (red-green-blue) but as Y-Cb-Cr (luminance, blue-yellow, red-green). While the luminance channel is stored in full resolution, the other two are calculated smaller. So that looks very simplified as follows:
The RGB image is decomposed into a 100% version of the luminance (Y), and a scaled version for each of the red-green color information (Cb) and the blue-and-yellow information (Cr). It has been found that this process saves a lot of data and at the same time still looks very good – except for the banding that is true.
* note: The process is much more complex, who would like to deal with this, here is more information that we just sweep under the carpet at this point in order not to bore you with subsamling and pixel rearrangements etc.
Next, these three channels are broken down into blocks – typically first in 8×8 pixels. These blocks are then smoothed a bit and so the tone differences are further reduced within the blocks. Since not the absolute value, but the difference to the previous value is saved, that also saves data again.
The image will be much smaller and if you want to see the efficiency of this method, just compare an uncompressed TIF against a JPG and pay attention to the file size.
Of course, this block formation and smoothing leads to further holes in our color gradient – making the banding stronger. The higher the compression, the more banding.
I could keep writing for hours, but the decomposition and different scaling, block formation, and pixel-to-tone ratio are the strongest factors in tonal value holes.
With this background knowledge, one can draw an interesting conclusion to the camera:
The higher the resolution and the better the noise performance, the greater the tendency for banding.
What can we do against banding?
If you edit an image, you can already see in the raw conversion if it could tend to banding: Whenever large-scale, smooth gradients take place it is better in 16-bit edit. In 16-bit instead of the 256 values per channel are 65,536 possible values available. During the processing, therefore, no holes should arise in the histogram.
Before saving as a JPG, you can prevent the block formation with a slight noise. Noise means: more difference between the pixels. We compare an 8×8-pixel area before and after the noise:
As you can see, the individual pixels are now more different to each other and smoothing will be less successful here – the JPG algorithm has been tricked.
The best way to create such a noise is to create a new layer and fill it with 50% gray using “Edit -> Fill”. Now the noise is created with “Filter -> Noise -> Add Noise”. The new layer is now placed in the “soft light” blend mode and the intensity is varied via the layer transparency. It is important, of course, that this noise is generated at the very end of the workflow – first zoom out, then sharpen, then noise. If you change the order, you either sharpen the noise (and amplify it) or you prevent the noise from being reduced. So, at the very end, just before saving.
How to remove banding?
If you want to remove the banding in an already saved image, that is a relatively simple process:
First, the image is converted into 16-bit to get more latitude in the tonal values. Then the banding can be removed with the Gaussian Blur – thus the holes are closed in the histogram. The further storage is then as described above. Of course it’s better to prepare the image in the right way during the raw conversion (right usage of the color depth) and very careful with large, soft brushes to go.
Further tips and tricks:
Converting to 16-bit and then reducing it to the background layer can also help. Jan Wischermann shows those and some more tips here in the following video:
Do you have any suggestions, additions, is this post out of date or have you found any mistakes? Then we look forward to your comment.
You are welcome to share this post. We are very grateful for every recommendation.