Wednesday, March 6, 2013

Its all in the bits... Why edit in 16bit mode when your image is 8bit.

8 bit v.s. 16 bit

Today I look at whether we should edit our photos in 8 bit or 16 bit mode?

We all know that JPEG images are 8 bit images.  Meaning that the color of each pixel made from 256 levels of Red, Green and Blue (16 million color in all) . Most of us also know that RAW images may have 12 or even 14 bits per color potentially giving each pixel over 16,000 levels of each Red, Green and Blue (nearly 4.4 Trillion colors).  It therefore seems obvious that if you shoot in RAW that you are probably going to edit in 16bit mode to retain that extra information rather than throw away 4+ trillion colors..

But lets say you're not ready to jump into taking photos in RAW mode, or perhaps you have decided for whatever reasons that JPEG is the best method for shooting for your style and workflow.   Does that mean that just because your photos are 8bit images that you should also edit those photos in 8bit mode?
Of course not!  Silly question.  Forget I asked. I wouldn't be wasting time with this post if that was the answer. :-)

So why on Earth should anyone waste their time, computer memory and processing to edit an 8bit image in 16bit mode?  Well, for starters, similar to RAW mode giving may more shades of color to work with, using 16bit mode goes even further.  You will be working with the potential of using more than 65000 shades of Red, Green and Blue. That gives more than 281 Trillion possible colors.

What this means is that every time you modify your image, you are able to work with much finer level of color modification.  Imagine it sort of like moving from a 1MP camera of the 90's to a 250MP camera of the future but you're working with colors of each pixel rather than the pixels themselves.

For some simple editing you may not notice an immediate difference or you may see some minor degradation of colors. Yet for other procedures you may see huge areas where your image starts to break down. You may have already seen the effects and not realized that the problem could have been avoided. Normally this is easily seen as banding in solid color shaded areas.

Before we get started, lets address the common fear that 16bit editing is slow and more difficult to work with. Yes, 16 bit mode is slower, takes more memory and uses more disk space to save an image, but the results are worth the effort. Additionally, we no longer live in the dark ages of 8MB (not GB, but MB) machines with single-core processors running in the sub-1GHz range.  Where there was once a need to be concerned about what your computer could handle, there is rarely a reason now to worry about processing power and computer resources required to edit in 16bit mode. If you do still use one of these machines, you can ignore my rant.

Almost any machine made in the past 10 years is going to handle 16bit editing with little or no discernible effect. Any machine made in the past 3-5 years is almost certainly able to handle such a task several times over.

Lets Get To It

Don't just take my word for it, lets take a look at a very simple example to demonstrate one effect. Although this example is a bit extreme for the purpose of demonstration, you should be aware that nearly any modification done to your image has the potential of causing or being compounded with other edits to create exactly the same issue.

First, be sure that your image editor of choice supports 16bit editing.
These instructions are going to use features in Photoshop, but you can likely find similar examples to follow along with.  We're also going to use grey-scale images simply because it makes the effect more uniformly visible.

Create some clouds

1. Create a new document. Lets use 1000 pixels on a side for this simple example.
2. Be sure you create the document in 8bit color mode.  
3. Now that you have a new document, make some clouds using the following menu,
     Filter -> Render -> Clouds

We now have some nice fluffy clouds.

Add some blur

Next,  Add some Blur using the following menu,
     Filter -> Blur -> Gaussian Blur
     Blur to a rather high amount of about 40-100 pixels, the amount will vary on your image, as clouds are rendered randomly.
                                                    (blur at 88.4 pixels)                             (resulting blur)

It really does not take much, but at this level the effect is exaggerated to an extent that it is easily seen.
Depending on the quality and calibration of your monitor, you may or may not see the bands of colors in the blurred image.  We'll make things a bit more obvious....

Add Levels Adjustment 

Lets do some contrast adjustment, a culprit of severe pixel destruction to further exaggerate the effect.
Make a Levels adjustment and bring the black and white sliders in to meet the curve.
You'll find the Levels adjustment accessible in several locations in Photoshop (and therefore your display may look slightly different, but will work the same). The easiest way to get there is with the following menu,
     Image -> Adjustment -> Levels...

                  (levels panel before adjusting)                      (levels panel after adjusting to the curve)

What we're doing here is essentially throwing away all the pixels with brightness levels to the left of the black slider and making them black.  All pixels with brightness levels to the right of the white slider are thrown away and made white.  Everything in between is stretched adjusted to fit the entire range of black to white.  We'll take a look at what that looks like later.  But for now the result on an 8bit image is quite drastic.

The banding is much more visible after the contrast Levels adjustment.  
Have you ever seen this issue in your own images?  Lets see what happens when using 16bit mode...

Lets Do it Again in 16 bit Mode

We're still going to start with the same bit clouds image.   Either Undo to where the 8bit clouds were initially created or create a new document.

Now that we have our original clouds back, convert to 16bit mode using the following menu,
   Image -> Mode -> 16 Bits/Channel

You won't see any change as the resulting image color is simply expanded to fit a 16bit space.

Here you see the clouds after 16bit conversion on the left, and after the same blur we did above but now for the 16bit version on the right.

      (clouds converted to 16bit)                                                (16bit clouds blurred)

You may see some banding in the blurred version.  This is partially due to the limitation that most monitors can only display images in 8bit mode.  So although Photoshop is working in 16 bit mode (and behind the scenes in an even larger color mode than that), sadly, you may see some effect. This also depends greatly on the quality and calibration of your monitor. 

Don't believe me?  The image looks nearly the same as with the 8bit version, you say?
Lets see what is happens if we try to exaggerate the banding again by using Levels adjustment.  If the banding actually exists in the image, you should see the same results as we did earlier. 

So again, perform the same Levels adjustment.
What will we get?

Compare 16bit v.s. 8 bit after Levels Adjustment

  (16bit image, blurred and level adjusted)
 (8bit image, blurred and levels adjusted)

Here I placed the 16bit image and the 8bit image side by side so you could see the difference.
The color transition of the 16bit image is smooth and will print that way.  i.e. Beautifully.
The banding on the right is just a mess that cannot be fixed and will print just like that! i.e. Ugly.
The banding in the 8 bit image will of course remain when you save your image.

What about saving the 16bit image back to 8 bit?
First we should try to understand what is happening behind the scenes.  Why is the banding visible in the first place?

A little behind the scene look

So what is happening?  It might help to see a simple demonstration of what happens with any edits.
The Levels adjustment has the unique functionality of giving some idea of how many pixels is at each luminosity level.  It isn't perfect but it will give a fantastic visual idea of what is going on with your pixels after a little photo editing.

Remember with the Levels adjustment, we threw away all the pixels to the left and right of curve.
This results in the remaining pixels' color values being expanded to fit the entire range.  The resulting Levels looks like the image to the left. Simply open the Levels panel again and you'll see this new graph. Notice how each spike in the curve above is stretched and expanded to fit the entire graph form left to right?  
We now have a higher contrast image with all pixels again ranging from black to white. 

The above Levels panel is showing the 16bit  result.  Notice the curve is a smooth transition from black to white.  Below is the what happens with the 8bit Levels adjustment.

Whao!  Look at all those spikes!  The stretched curve itself matches that of the 16bit curve above but it has a lot of blank gaps or spaces. These gaps in the 8bit graph are due to the conversion of a small curve containing a limited amount of information being stretched like a Slinky to fit a larger space.
This lack of smooth transition between levels of luminosity is what causes the banding effect that we saw in the examples above.

But with 16bit mode,  there are many more possible values to spread out across the graph.  Thus no gaps, or at least to a very reduced effect, and your end up with a much smoother transition from one point to the next.

Going back to 8 bit

At some point whether it be for printing or for displaying on a website, you will need to convert your image back to 8bit in order to be useful.  Many color levels from the 16bit colorspace do not exist in the 8bit world and due to its limitations must be converted to the next closest possible color.  So some degradation will naturally occur.  Lets see if it was worth the effort.

Below, the left image has been converted from 16bit back to 8bit color mode.  There is some banding and dithering evident, but it is difficult to see and is still quite pleasant.  The image on the right remains as it was, quite un-pleasant.  

(8bit image saved as 8bit)
 (converted from 16bit back to 8bit) 

It becomes quite obvious that the 16bit conversion was worth the effort, but why?
If you look back at the result from the Levels adjustment with the 8bit image, you'll recall the gaps in the graph. The final result was not using the entire set of colors and luminosity values available even to an 8bit image. There is little you can do after the fact to fill in those gaps once it has been destroyed to that extent.  Adding some noise or blurring can help hide the flaws but will rarely eliminate it.
When using a 16bit image, the entire 8bit range is available to receive a close approximation of what the 16bit version had available.  If you could print and display a full 16bit image, you would see a more drastic change but since we're limited to 8bit in most cases the transitions again appear as smooth as these mediums will allow.


When performing any destructive retouching, color modification, levels/curves adjustments, blending, smoothing, etc.. you should seriously consider first converting to 16bit mode. It will result in cleaner, better looking results even if you are starting with 8 bit images.

Additionally, be sure you save your files in a NON-lossy format like TIF or PSD if it is likely that you may perform any future editing on that same image.

Saving your edited files as JPEG will repeatedly throw away more detail and pixels due to the lossy-compression that JPEG uses. It may be for another discussion, but trust me, if you value your work enough to edit in 16bit mode, save in TIF or PSD format.  Re-saving a JPEG over time will result in an unusable image.

JPEG is often very efficient at throwing away "unnecessary" information, so your file sizes can remain very small.  Saving as compressed TIF or as PSD retains all detail without throwing out any information, ever.  This benefit has a cost as it will result in larger file sizes.  Saving as a 16bit image v.s. saving as an 8bit will result in even larger file sizes. But disk space is cheap and I think you will find it is worth the extra bytes to retain the higher quality in your images.

* Note that it should be stated that some filter effects and certain features may work slightly differently in 16bit mode than in 8bit mode or may not work at all.  If you find this to be the case and your favorite feature is suddenly unavailable,  you may need to drop back to 8bit mode.  
But try to leave the use of these features until major image corrections are completed in 16bit mode.
You can always go back form 8bit into 16bit mode, but any information thrown away from the conversion back into 8bit mode will be permanently lost.

No comments:

Post a Comment