Taking a byte out of bit depth – Jpeg vs. RAW

Mon, Apr 5, 2010

Best Practices, Lightroom, Photoshop

Should I shoot RAW or should I shoot JPEG? That is the eternal question digital photographers struggle with day after day. Take a look at any photography message board or Flickr group and you will likely find a heated discussion weighing both sides of the issue.

Proponents of each file type have strong arguments in their favor, but there are some major technical differences between RAW and JPEG that can help you make a decision for yourself.

To me, the biggest technical difference between JPEG and RAW is bit depth. JPEG is standardized as an 8-bit image file. This means that each color channel of a pixel has 8-bits of data allocated to reproduce color.

Sometimes you will find 8-bit color referred to as 24-bit color, which simply combines the bit-depth of the Red, Green and Blue channels (8 bits + 8 bits +8 bits = 24 bits). Photoshop and Lightroom use the single channel nomenclature, meaning an 8-bit file can address 8 bits of data per color channel per pixel.

An 8-bit file can address up to 256 levels of luminosity per color channel. This is represented in Photoshop as a numeric value between 0 and 255. 0 is the lowest luminance level, while 255 is the highest. A color with all 3 color channels registering 0 is black whilst one with all 3 channels registering as 255 is white.

By multiplying the three channels together we can get the total color depth available in an 8-bit file (256 x 256 x 256 = 2563 = 16,777,216). An 8-bit file is capable of representing up to 16.7 million colors at any given pixel.

That number seems massive, but it simply is not as big as you might wish it to be if you plan on manipulating your image much.

On the other hand, a RAW file is output at the native bit-depth of a DSLR’s image processing chip. Common bit-depths are 12, 14 and 16 bits output from the sensor into the RAW file. Let’s consider a 12-bit RAW file, which is common on many existing entry level DSLR’s. A 12-bit file can address up to 4,096 levels of luminance per color channel as opposed to 256 levels possible in an 8-bit file.

Multiplied across the RGB spectrum that allows for 40963 colors, which is 68,719,476,736 possible colors for any given pixel. 68.7 billion colors possible versus 16.7 million, that is over four thousand times the amount of possible colors.

At this point the exercise is simply mathematical and theoretical. Since the human eye can only distinguish between 7 and 10 million colors, an 8-bit file is all we really need, right? Well for output that is more or less an accurate statement, but for editing and processing purposes we are cutting awful close to the limit. In Photoshop, limiting the bit depth to 8-bits can cause color banding in gradients, also known as posterization.

The more processes and filters applied to the image magnifies the chances of color integrity degradation.

By working with an image as a 16-bit file you can eliminate the color degradation in the image, as Photoshop can address more than 16.7 million colors, allowing for better control of the color data. A real world example of this is an image that has been processed through multiple filter passes by AlienSkin Exposure 2 and Nik Color Efex Pro 3.

I started out with this image right from Lightroom.

I edited this photo in Photosop CS4 from Lightroom twice. This first iteration remained a 16-bit file, created from my 12-bit RAW file. The second iteration was downsampled to 8-bit upon arrival in Photoshop. Both files were subject to 4 conversions in Exposure 2 and 4 conversions in Color Efex Pro 3.

Each filter was applied to both samples with the same filter settings. After the 8 filter passes, the color degradation could be seen.

The above image was the file that remained 16-bit through the filtering process. The added grain from the film filters is noticeable, but colors transition well. Also note the color dots on the shirt in the bright region on the left side of the image.

The above image was the file initially converted to 8-bit in Photoshop before processing. Compared to the prior sample the grain is even more noticeable, even though the same filters were used. This is due to the last of smooth graduations from the color of the grain to the color of the photo. When looking at the colored dots in the bright region on the left side of the frame, notice how the yellow and orange dot visible in the top image are drastically faded out and that the other dots in the area are less “smooth” than they were in the prior image.

Now, since some crazy filters were applied, many of which adding in grain both images are drastically altered from the original and appear similar. However you can notice a definitive color shift between the two images and the 8-bit image became quite noisy with some loss of detail. The 16-bit file held up to the stresses of the test much better than the 8-bit file, even with a final conversion to 8-bit to save the image to JPEG for the web.

Starting out with more bits of color data helps the process immensely, and remaining in an expanded bit-depth during processing allows Photoshop much more room to manipulate colors. Even though the human eye has a limited color response and 8-bit files allow for 16.7 million colors, the effects of multiple editing passes are evident in the file that was rendered and processed in 8-bits more than the image that was rendered in 16-bits and processed before a final downsample to 8-bits.

Even when you downsample at the end to 8-bit, you are then limiting the image to 16.7 million colors. But you are putting off Photoshop having to make hard color decisions to the very end. Photoshop can make its best guesses for downsampling from a wide range of colors, allowing for a smooth downsampling.

However, if you work the file in 8-bits the whole time, Photoshop has to make its color guesses on every pass, leading to more color errors and artifacts.

So far we have only really considered working in 8 or 16-bits in Photoshop, but when working in Lightroom it is even more important. First, Lightroom is developed to manipulate RAW data, so it can do wonderful things with a 12-bit RAW file that you cannot do to a 16-bit file in Photoshop. But even when editing a 16-bit TIFF in Lightroom, such as a film scan, a 16-bit file allows Lightroom to operate on the image much more smoothly than on an 8-bit file.

Have you ever tried to edit a JPEG in Lightroom? It is not a fun endeavor, as you will quickly discover the sliders are not as responsive as they are on a RAW file, or even as responsive as working on a 16-bit TIFF. This is due to the limited color range of the 8-bit image. Anything more than a few quick fixes to a JPEG in Lightroom results in a mangled image.

To put it in the simplest terms imaginable, Lightroom is designed to be used with RAW files, so if you use Lightroom shoot RAW. You will get so much more out of the software. Even if you are working with raster images, such as scans, give Lightroom the most data possible to further manipulate your image, give it 16-bit files.

A 16-bit file will contain all the color information most any scanner on the market can produce, and if you have to convert a RAW file to a raster image for editing for some reason, a 16-bit TIFF will retain all the color data possible from a 12 or 14-bit RAW file as can be managed.

Another point to consider, outside of bit-depth but still pertaining to it, is in-camera processing. When you shoot JPEG, you are entrusting your camera to make the best decisions as to the color and tone of your images. Usually it does a pretty decent job, and many people compare the JPEG experience to shooting Slide Film.

The problem is, the camera is throwing away massive amounts of image information while processing the JPEG. As we discussed there is a big difference in the data carried in a 12-bit image and an 8-bit image. That data cannot be recovered, but it is data Lightroom and Photoshop can use to help you create the image you desire.

In the simplest terms imaginable, Lightroom is designed to be used with RAW files, so if you use Lightroom shoot RAW.

JPEG is not like shooting film at all. In the film world you can make prints or scan the film to get what you need from it. There is a lot more color data in that negative or slide than there can be rendered by a scanner or even a DSLR sensor. Simply put, you can manipulate a negative or slide more before final output than you can a JPEG. A JPEG is really much more like a Polaroid. You can do a bit to it, but not much before quality starts to suffer.

Hopefully, this lays out another convincing argument for shooting RAW as opposed to JPEG. Sure, JPEG is quicker and saves space, and you may feel that your skills can get the most out of JPEG and you don’t need RAW. But simple math doesn’t lie. 68 billion colors is more than 16 million.

When you consider that a camera sensor or a scanner sensor is simply measuring levels of luminance of Red, Green and Blue in an image and uses that data to recreate a full color image, color bit-depth has a massive impact on your images, from color to clarity, sharpness to contrast. Color data is all that is recorded since a camera captures light.

When you really think about how a camera works, be it digital or film, you can see more color data is important to image quality all around.

In the end we are all here to make the best images we can that fulfill our personal vision. Don’t try to save a few megabytes and a few minutes by shooting JPEG. You may find that the JPEG you shot needs further editing, and if you shot it in RAW you would have a much easier time of persuading the image to your will.

Don’t be lazy; take control of your images.

If it was the old days once again, would Polaroids be enough to satisfy your clients? JPEG is the digital equivalent of a Polaroid, not slide film; what you shoot is what you get. The real money back in the day was shooting slide and negative film, something that you could work with in the darkroom. RAW is the same thing, just for the Lightroom.

Michael W. Gray – LifeInDigitalFilm

, , ,

6 Comments For This Post

  1. Perry M Says:

    Well said!

  2. Kevin Says:

    Outstanding. I was already a firm believer in RAW, but this is the best explanation I’ve yet heard.

  3. Brandon Oelling Says:

    ROCK ON Kevin!

    |B

  4. Jasper Teal Says:

    All valid points. The big disadvantage of RAW, though, is that the files are uncompressed, and are therefore about 5x the size of a high-quality JPG, while giving you only about 50% more data (in dynamic range). And the sad thing is, there are 16-bit JPG formats, such as JPEG-2000 and JPEG-HR, which give you the best of both worlds: full dynamic range, and efficient compression, not much larger than 8-bit JPG.

    If only camera makers would support the format :(

  5. Corey Says:

    I want to say “Thank You” for a GREAT explanation of the real differences between shooting RAW vs. Jpeg files.
    Without any doubt as to fact, compression is an information killer. Putting myself in the place of the client, I want information that is “deep/rich” (get this from shooting RAW files only) in/on my prints. I can’t get anything like that from a “shallow” (Jpeg) file that is already shot full of holes before I even get a chance to manipulate it via software I spent hundreds of hard earned dollars for. I can think of no good reason to build something with cheap materials and that is simply what Jpeg was designed to be. I do not care that the RAW file is 50 or so Mb. I have large capacity cards on purpose. I care about what gets hung on the wall. Thanks for all the energy you expend on site!

  6. René Damkot Says:

    I’ll try to be brief, and post a few links instead of re-stating all what’s in those links ;)

    IMO, the example given here is a good example of why 16bpc (which is actually 15bpc +1 in Photoshop) can have advantages over 8bpc, but has less to do with raw vs jpg shooting: If shot in jpg, converting to 16bpc in PS after opening the image would have given (almost) identical results as opening the raw as a 16bpc image, since most damage is caused by rounding errors and posterization.

    AFAIK, no “35mm” DSLR captures a 16bit Raw. It’s all either 12 or 14bit. And that’s sensor data: grayscale, not RGB. So there are no R, G and B channels before de-mosaicing.

    That being said: One advantage of a raw is that it is unprocessed: All “in camera” settings are only “tagged” as metadata and can be altered in the raw converter of choice. So you don’t have to try to “rescue” a jpg with the wrong white balance, but simply can set the WB right in the raw converter.

    http://www.luminous-landscape.com/tutorials/understanding-series/u-raw-files.shtml

    Another advantage is that it’s linear. So you can expose to the right to get a better S/N ratio: http://www.luminous-landscape.com/tutorials/expose-right.shtml

    Also, you’re not confining the image to sRGB or AdobeRGB gamut while capturing it, since you can choose whatever color space you want in the raw processor.

    On a side note: Some raw files are compressed. Lossless for a CR2, lossless or lossy for a NEF. Otherwise a raw file would always have the exact same size, regardless of image detail (and that includes ISO noise)

    http://www.completedigitalphotography.com/?p=489
    http://cpn.canon-europe.com/content/education/infobank/image_compression/lossless_and_lossy_compression.do

4 Trackbacks For This Post

  1. Jpeg or RAW? » The Photo Nomads Says:

    […] here’s a really good article which explains the difference between RAW and Jpeg and it might help you […]

  2. Designer Roundtable – RAW vs JPG | Design by Firgs Says:

    […] Taking a byte out of bit depth – Jpeg vs. RAW –  from Michael W. Gray on X Equals […]

  3. Why designers and photographers should use RAW vs JPEG files — A.J. Wood - Adobe Instructor Says:

    […] you make a +/- adjustment without seeing the color temperature. 2. Bit Depth. As referenced in Brandon’s article JPEG is limited by being an 8-bit format. While the visual difference between 8-bit & 16-bit might be invisible to most people (I […]

  4. Designing Emulation Presets for Lightroom (Download) : Seven by Five Says:

    […] Now, things get a bit tricky. I want to scan in my samples at the highest quality possible, retaining as much color and image detail as possible. The first issue is color depth, which needs to be set at 48-bit (or 16-bit/channel in Photoshop parlance). This setting ensures as much color data as possible will be saved, usually much more than a scanner can produce. For a bit more information on bit depth, check out this article on X-Equals. […]

Leave a Reply