Working with raw digital camera images

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

Recently, I went along to one of the meetings of my local camera club, which is something I’ve been meaning to do for a while but somehow never got around to. At the meeting, one of the members (Andy Gailer) gave a really interesting presentation on working with raw images. I’ve repeated most of the highlights here, adding a few notes of my own along the way.

Technical details

Raw images are exactly that – the raw pixel data that is captured by a digital sensor. So, in order to understand the use of camera raw, it helps to understand a little bit about the technology that creates the image.

Probably the most important part of a digital camera is the sensor that converts available light into electrical signals. Two types of sensor are commonly used: charge-coupled device (CCD); and complementary metal oxide semiconductor (CMOS). CCD is a more mature technology but CMOS is gaining popularity as it can be implemented using fewer components, requires less power and provides the data more quickly.

Regardless of the technology in use, digital camera sensors consist of an array of photodiodes (or “pixels”) collecting photons (minute amounts of energy which combine to make light) and each pixel is fitted with a microlens to focus light into the sensor site. The number of photons collected in each pixel is converted into an electrical charge and this charge is converted into a voltage, amplified, and converted to a digital value to be processed into a digital image, either in camera or, if a raw image is used, using a computer. It’s important to understand that, in the same way that a bucket can only hold so much water, a pixel can only hold a certain amount of light.

Sensors also come in a variety of sizes. A “full frame” 35mm sensor is the same size as a frame of 35mm film (24x36mm) but a compact digital compact camera will have a much smaller sensor. My Canon Digital Ixus 70 has a 5.75×4.31mm sensor but my Nikon D70 DSLR has a 23.7×15.5 mm (Nikon DX) sensor. The Canon squeezes 7077888 pixels onto that tiny sensor whereas the Nikon only has 6016000 pixels, but each one of the Ixus 70’s pixels is significantly smaller than the D70’s and this will affect the image quality – that’s why not all megapixels are equal.

Bayer sensor patternThe quality of the image will also be affected by it’s contents – each pixel can only capture one of three colours as it has a red, green, or blue filter over the top, usually arranged in a pattern known as the Bayer Mask, with twice as many green filters as red or blue (the pattern is designed to mimic the way that we see colour). On top of the Bayer filter is an infrared filter, then an antialiasing filter (to reduce moiré) and each of these various filters steadily reduces the overall quality of the image.

An alternative filter (the Foveon X3) employs an arrangement that is similar to the one used to make up the coloured emulsion layers in photographic film, where the red, green, and blue pixels are placed on top of one another (different colours of light will penetrate further into the sensor), meaning that all pixels capture all colours, but this sensor type is relatively uncommon and also suffers from low light sensitivity.

Bayer sensor filteringThe resulting data from the sensor consists of three channels of photographic data – red, green and blue but, with the exception of the Foveon sensor, each channel is incomplete because the mask means that only certain pixels will be activated for a given colour. During raw conversion (either in-camera, or on the computer), a process known as demosaicing is used in an attempt to fill in the missing pixel data, based on the comparative brightness of the surrounding pixels, and then sharpening is applied to counteract the effect of so many filters on the sensor.

I mentioned earlier that each sensor site (or pixel) can only capture a finite amount of light, expressed as a number of levels.

The number of bits used in the analogue to digital conversion process will determine the light sensitivity, with 8 bits representing 255 levels, 12 bits for 4095 levels, 14 bits for 16383 levels and 16 bits for 65535 levels. It’s important to understand that a sensor records light in a linear fashion, so reducing the amount of light falling on the sensor by one stop (EV) will halve the number of levels of light that can be recorded. Equally, if the light is doubled, eventually the pixel will be full and the resulting effect is blown highlights.

Similarly, as the light levels drop, an effect known as posterisation (or colour banding) becomes visible, particularly in areas such as shadow detail, or the sky.

Even a few stops can make a huge difference to the number of light levels that the sensor can determine and so it is generally recommended to expose as far to the right of the histogram as possible without clipping (I’ll describe the histogram in a follow-up post). Because human vision is not linear, during raw conversion a tonal curve (including a gamma correction) is applied to the image to make it more pleasing on the eye.

The table below shows the difference between an image recorded as an 8-bit (gamma encoded) JPEG and others recorded as a 12-bit or 14-bit (linear encoded) raw file:

Stop 8-bit JPEG (gamma-encoded) 12-bit raw (linear) 14-bit raw (linear)
1st stop (brightest tones) 69 levels 2048 levels 8192 levels
2nd stop (bright tones) 50 levels 1024 levels 4096 levels
3rd stop (mid-tones) 37 levels 512 levels 2048 levels
4th stop (dark tones) 27 levels 256 levels 1024 levels
5th stop (darkest tones) 20 levels 128 levels 512 levels

Even though the logarithmic scale used for the gamma-encoded image does not fall off as sharply as the linear scale for the raw image, the overall number of discernible light levels is reduced in the JPEG (partly due to the 8-bit nature of the file format), whereas the raw files retain more detail, allowing for some exposure compensation to be applied post-capture. In addition, due to the lossy compression that is inherent with a JPEG, further image quality is sacrificed each time the image is saved.

Colour spacesColour spaces are another consideration, with each space defining the number of visible colours (or gamut) that may be represented in an image. Which colour space is “best” is often a personal consideration but it’s important to note that we can neither see, nor print all of the available colours; however, by storing the maximum possible amount of information, there is more scope for making changes later without degrading image quality. For print work, Adobe RGB may be a good colour space but for on-screen work (where the display device has a smaller gamut), sRGB may be more appropriate. I have now switched the default setting in my Nikon D70 to Adobe RGB 1998 but in reality it makes very little difference as the colour space can be altered later.

JPEG or raw?

For a JPEG image, the following process is applied to every image by the camera:

  1. RGB information from sensor is converted to colour data.
  2. Tone curve applied to convert linear-encoded data to gamma encoding.
  3. White balance set.
  4. Contrast adjusted.
  5. Colour saturation increased.
  6. Sharpening applied.
  7. 12/14-bit native file compressed to lossy 8-bit JPEG.
  8. Image is recorded to memory card.

By shooting raw, no data is lost from the sensor and a better tonal quality is retained. Images can be reprocessed years later for better (or alternative) results; however some raw processing software will be required.

Adobe Camera Raw is a free download and allows all of the adjustments that a camera would normally make to be applied to an image (and more), under the control of the photographer. It integrates with other Adobe applications (e.g. Bridge and Photoshop) for image organisation and editing. At first, the interface can be daunting – but the controls are organised in order of significance (left to right and top to bottom) and many may be ignored. Adobe’s white paper on understanding Adobe Photoshop Camera Raw 4 is also worth a read.

Adobe Camera Raw 4.0

There is one significant drawback with raw image capture though – even though the sensor data is captured in the same way, most camera manufacturers (particularly Canon and Nikon) record the data using a proprietary format. This is why software such as Adobe Camera Raw is constantly updated for new cameras; however it’s also a risk that one day those raw images will become obsolete. There is a potential solution, using Adobe’s Digital Negative (.DNG) format but adoption by manufacturers has been slow and, for many photographers, conversion from a proprietary raw format to DNG is an extra step in the workflow.

Working with raw images

Andy gave some good advice for working with raw images and I’ve added a few tips of my own to Andy’s advice:

  • At the capture stage:
    • Just because you can edit later, don’t rely on it – take your best shots with proper settings – particularly focus and exposure.
    • Get the brightest possible shot without clipping – use the camera’s histogram function and expose to the right.
    • Check the shot in-camera by zooming in on parts of the image on the LCD.
  • Back on the computer, organise the files:
    • Download images to the PC.
    • Sort, organise, tag, rank and caption as desired.
    • Add metadata.
    • Back up the images to a separate storage location.
    • Automate repetitive tasks (e.g. renaming and captioning).
  • Process the raw images:
    • Process for maximum quality.
    • Adjust colour balance.
    • Crop, straighten and sharpen (if required – and only if no more editing is to be performed).
    • Save converted files at 16-bit and back up to offline storage.
  • Edit (if required):
    • Apply any image enhancements, clean up flaws, etc.
    • Perform any creative enhancements.
    • Apply batch actions
    • Prepare for output (printing or web) – if sharpening is required, this should be the last action on the image before saving.
  • Archive:
    • Establish and implement an archival plan.
    • Save files on external devices and media for easy access and retrieval – consider off site storage.

Further reading

Further information may be found in the following articles:

Credits

Based on a presentation by Andy Gailer. The Bayer filter images used in this post are licensed under the GNU free documentation license and the colour space diagram is ©Jeff Schewe, used with permission (images from Wikipedia).

3 thoughts on “Working with raw digital camera images

  1. Hi Mark,
    The information that you have given is very useful, I have not used Adobe Photoshop Camera Raw, I have recently downloaded 30 day trial version of contenta converter from here: http://www.contenta-converter.com/ . The RAW processing panel is quited different from the snapshot you have shown, could you help me analyse the difference between the two softwares?

  2. @Meenu – Adobe Camera Raw is free, rather than a chargeable product, and is also arguably the de facto standard for raw conversion; however the software that you mentioned does seem to include some photo management capabilities too. Unfortunately I don’t have the time to perform a full comparison but I have to say I struggle to see the market that Contenta Converter is after – Mac users have iPhoto and Windows users have Windows Photo Gallery for free, with the raw conversion handled either by free operating system add-ons such as Microsoft Pro Photo Tools (together with manufacturer-supplied codecs) or by Adobe Camera Raw.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.