RAW Conversion Explained In-depth
September 4, 2010 2 Comments
RAW Converters vs. In-camera JPEG Files
Most high-end cameras have the option of saving either JPEG or RAW files. This article will dig into how a JPEG file gets created in a digital camera and how it is limited compared to working with RAW files thus giving you a better background for selecting the right format for you.
A RAW file contains all the information which is measured by an image sensor during the exposure of a picture. Later in the process this will provide total freedom when you want to decide how the scene should be rendered using a RAW converter. The in-camera JPEG is just one interpretation of the scene. When you set your camera to output JPEG files it actually starts with the same data that is contained in the RAW file and the camera computer acts like a built in RAW Converter. All the processing steps needed for converting the RAW data to a JPEG file will be calculated by predefined settings. Once the shot is converted to the JPEG file it cannot be reprocessed from the original RAW data. This is the real disadvantage of using the JPEG conversion in the camera. Naturally, you may tweak the JPEG file in an image-editing program afterwards, but at this point a wide range of decisions have been made on how to process the file. Those decisions cannot be undone without a severe loss of quality. Working with RAW files means that you still have complete freedom to work with the initial captured information and process the image exactly as you like it. And yet still achieve the highest possible image quality. To get a better understanding of this we will take a look at the different processing steps needed to convert at RAW file to a JPEG file:
- Bayer Interpolation
- White Balance and Color Correction
- Tone Curve
- Noise Correction
- JPEG compression
As the first step an image file with color information for each pixel needs to be created. Please note that in camera science, a pixel is denoted as one photosite of one color. This differs from e.g. a computer monitor where a pixel contains all three colors. In the sensor 2 out of 4 pixels are Green, 1 out of 4 is Blue and 1 out of 4 is Red. This means that the RAW file does not see the true color information for each pixel. In this process the task for each pixel in the RAW file is to “guess” the values of the 2 missing colors.
This process is called Bayer Interpolation or “de-mosaicing”. The name Bayer refers to the original pattern of how to arrange the Red, Green and Blue pixels in the sensor. This pattern was patented by Bruce E. Bayer back in 1976 but it is still today by far the most common pattern for color pixels in color image sensor. The Bayer interpolation process calculates the missing color information from the values of the surrounding color pixels in order to create a normal R, G, B color file. This is not an exact science – each camera manufacturer or RAW conversion software vendor have their own custom algorithms for the process. There is a huge difference in the quality of these algorithms, which provide the basis of the ability to see fine details in true colors. Later processing steps can still alter the result but if for instance some details are not established in this step it is not possible to re-establish them later. Some of the finest Bayer interpolation algorithms can be found in RAW Converter software like Capture One and Leaf Capture. Dedicated RAW converter software contains very advanced and complex algorithms. Only very few camera manufacturers have managed to build high quality algorithms into their camera’s “computer” and even some of the largest DSLR camera manufacturers have only managed to implement simple algorithms for this step.
Bayer interpolation. The first figure shows the RAW file with the color pixel arranged in the Bayer Pattern. The second figure shows the RAW file after the Bayer interpolation process. Color information for the 2 missing Colors for each pixel has been calculated.
White Balance and Color Correction
When it comes to colors the most important parameter to get right is the white balance (WB). This process simply determines the “color” of neutral colors. Getting the WB right is the basis of getting accurate color and it is the fundamental starting point for all further color corrections. All cameras have options for setting the WB and all have some sort of auto WB. This might offer a reasonable starting point but often these algorithms are not optimized for the individual camera and will lead to some color cast in the images as well as wrong color interpretation. Occasionally, these auto WB algorithms will produce a completely wrong result and will select a really poor WB. Using in camera JPEG files with wrong or slightly wrong WB might lead to color cast and wrong colors in the final image. This kind of color problem can be extremely difficult to fix afterwards in an image editing software. By using a RAW file and a RAW Converter you will have full control over the WB and it can be adjusted to exactly the right WB for the camera and the scenario.
Like in the days of film there is a tone curve involved when making an image from a digital camera. Back then you were able to choose films with different tone responses (contrast / base characteristics) and in the development process there were still some tweaks that could be done. The tone curve determines how to render all the different levels of light from deep shadow to highlights. The human eye has the ability to see both very bright details and very dark details at the same time. This is also the case for today’s digital cameras. However, when an image needs to be displayed or printed it is only possible to use a quite limited range of tones. Therefore it is necessary to make a decision on how much of the shadows, the mid tones and the highlights that should be seen. This is what the tone curve takes care of.
If the camera has been set to save JPEG files then the tone curve is applied in the camera computer. The different camera manufacturers have different perceptions of what they consider being the ideal tone curve. Some manufacturers prefer a tone curve with high contrast (giving punch to the images but lacking the ability to maintain shadow details) and others like less contrast (which provide better results in portrait scenarios). Some prefer the ability to maintain many highlight details while others hardly keep any.
When an in-camera JPEG file is saved, then it is converted into only 3×8 bit per color pixels – or 256 levels of grey per color channel. This means that if you did not like the tone curve applied by the camera, your ability to tweak it afterwards is quite limited. If deep shadow details are missing, it may not be possible to get them back at all. By using RAW files and a RAW converter you maintain all bits available from the RAW file and you will be able to apply exactly the tone curve you prefer. Some RAW converters like Capture One even gives you the ability to select different default tone curves (Film Curves) or the possibility to work with a totally linear curve. This provides you with complete freedom to create your own look.
Today, we see cameras with previously unreachable ISO levels. This has been a result of improvements on many fronts. In particular the quality and design of sensors and the refining and complexity of the noise reduction algorithms. Without high quality noise reduction methods, images shot at high ISO levels would not be useful at all. How useful some of these extreme high ISO options are, is very much dependent on how the images are intended to be used. However, without doubt you can reach a quality level at high ISO today that has never been achievable before. For in-camera JPEG files large amounts of noise reduction is applied even at quite low ISO levels.
Noise reduction is an “art” in the field of image processing. The challenge is to determine what is useful and valid information in the file and what is just noise and then deal with the noise. There are many different algorithms in this field and the results vary. Some of the cheapest algorithms just blur out information with high loss of details, where other algorithms use very sophisticated methods to clean up the file with a minimum loss of details and color accuracy. Again the benefit of working with RAW is huge compared to using the in-camera noise reduction. If the JPEG files blur all the details which should have been included in the file there is no way to get it back. If you work with a high quality RAW converter like Capture One you have full control over the differentiation between noise and details while still getting a good default compromise – most images don’t need tweaking.
How much sharpness should be applied to my images and what should the camera settings be? This is a big topic and I will explain some of the things that need to be taken into account. Let us start with the camera you are using. Most cameras use an anti-aliasing filter in front of the image sensor. The purpose of this to minimize the potential moiré that can occur because of the way the sensor sees colors via the Bayer Color Pixel Pattern. This anti-aliasing filter blurs the image just a little bit but how much depends on the camera manufacturer and the camera model. The pixel size of the sensor in your camera also has an influence. Likewise, the lens you are using and the aperture will also highly influence how sharp an image will look. This means that even in situations where you are using the same camera you will need to compensate for the different levels of sharpness you get from using different lenses and apertures. Finally, it is necessary to determine how much Photoshop work you plan to add afterwards and what size and purpose you prepare the image for?
It will be difficult to apply the right amount of sharpness for a JPEG file in the camera. If you do need to shoot JPEG make sure that sharpness is not set too high as this cannot be fixed afterwards. The only right solution here is to use RAW files and a RAW converter and then depending on the use and origin of the individual image adjust the sharpness. In the best RAW converters like Capture One you have the possibility to save sharpness presets that may afterwards easily be applied to groups of similar images which will speed up this process considerably.
The whole idea of using JPEG files in a camera is that it makes it possible to compress the image file to a much smaller size. Thus you are able to store large quantities of files onto the memory card and you are able to save the files faster. If you need to shoot long burst of images this might be the only option that gives you a long enough burst period. JPEG is a standard for how to compress an image file but there are many options within the standard that greatly influences the quality and size of the image.
Typically you will have options for different JPEG qualities on your camera. A simple parameter is the size of the image. This is straight forward but you may also have a couple of options for how high compression you can expect to get. If you need to shoot JPEG it is important that you test the JPEG quality settings or simply go for the best quality. It may not be in the details that you see the loss of quality, however, if you e.g. have a sky with a smooth color transition the JPEG compression may break up this transition. The final thing that happens in a camera when shooting JPEG is that the bit depth of the image gets reduced to 8 bit per color channel. After this process, the image then gets compressed by the JPEG compression engine and you end up with a file that is much smaller than the original.
It might be that too high compression settings lead to image files with low quality. However, it is still an amazing technology and it is possible to make JPEG files which are about 8 times smaller than the original which still look almost identically to the original image – this is of course as long as you do not try to tweak it! If you find that you generally like the results of the camera JPEG image files this might lead you to think that it is not necessary for you to use RAW. However, I urge you to see the difference with your own eyes and use RAW files for your own images combined with a quality RAW converter. You will soon realize that your images hold more than you have ever expected!