Raw vs JPEG experiment

Introduction

It is widely believed that digital cameras' raw image modes offer a significant advantage in overall image quality compared to JPEG modes, at least for photos requiring significant amounts of postprocessing. Brad Templeton posted as a challenge a request for a single image where such advantages are visible; if no advantage could be found even on heavily manipulated images, use of raw mode would consititute an unnecessary waste of camera memory and postprocessing time. This experiment is intended to answer his challenge.

Methodology

The experiment consisted of the following steps:

Note that the goal of the comparison is not to find settings that make the jpeg-processed image look good subjectively, or to criticize the original raw conversion results---instead we wish only to determine whether a jpeg version of the original photo could be made as similar as possible to the raw-processed image. The expectation going in to the experiment was that differences between the raw and jpeg versions would be difficult to spot in the web sized images, but in the 100% scale images it should be possible to see both jpeg artifacts (8x8 blocking, primarily in regions of high detail subject to high manipulation) and quantization errors (banding, primarily in regions of low detail subject to high manipulations).

The Original Photo

The photo selected for this experiment was a close-up portrait of a girl (my daughter), lit naturally by late-afternoon sun through a window. The photo was taken on a Canon D60 with 70-200/2.8IS lens and 500D closeup adapter. The intended result of the photo was a high-key image, however the shot was heavily backlit, so shooting at high key (by overexposing) or even exposing the photo normally resulted in severely blown out highlights. Instead, the photo was deliberately underexposed, and its brightness was significantly increased during postprocessing.

The photo as originally taken (originally 2048x3072, reduced to 448x672):

Original photo reduced for web display

Postprocessing consisted of compositing two copies of the image, one of which had been digitally exposure compensated two stops, and both of which had their levels adjusted during linear conversion. The composite image then underwent light amounts of color rebalancing, noise removal, and sharpening. Here is the final result:

Raw-postprocessed photo reduced for web display

Curve Identification

For the darker of the two composited images, the raw workflow involved only a linear conversion followed by a Levels command in the RGB channels. I felt that the best way to simulate these steps without incurring multiple levels of quantization error was to use a single Curves command. To fit the curves, I compared pixel values from a JPEG conversion of the original image to values at the same positions from the processed raw image, and selected pairs of original and raw pixel values as control points. I then smoothed these curves by removing unnecessary control points while keeping near to the unsmoothed curve. The resulting control points were: Red (15,0), (24,18), (35,50), (50,75), (88,105), (134,141), (217,209), (240,236), (255,255); Green (15,0), (23,12), (32,44), (41,59), (55,77), (74,94), (134,143), (208,206), (234,231), (255,255); Blue (15,0), (36,61), (50,77), (74,99), (129,143), (156,168), (232,228), (255,255). These linear conversion steps did not involve any color balance changes, so all three curves are similar, but not sufficiently identical to allow using a single curve for the RGB channels. Also, some pixel values were significantly out of line with these curves; for instance, a point on the orange hair wrap dangling in the left area of the image was measured at RGB (130,67,32) in the original image and (152,97,71) in the transformed image. Such outliers were avoided in choosing control points for the curves. Although the curved JPEG image was very similar in overall tone to the raw image, some differences were immediately noticable: the overall contrast was higher (e.g. the freckles and dark shadows around the left eye were more apparent), the lips were darker, white of the right eye seemed lighter, and the orange hair wrap band was much duller. Together these effects combined to produce a harsher and less flattering view. However they were most noticeable in parts of this version of the image that were least used in the compositing process.

The raw workflow of the brighter of the two composited images involved digital exposure compensation and linear conversion followed a step of Levels on the L channel in Lab color mode which seemed difficult to replicate by an RGB curve. Instead, we attempted to use curves to match the exposure compensation of the image prior to leveling, and then applied the same L Levels command. The resulting control points were: Red (0,0), (21,79), (50,131), (62,146), (109,196), (160,255); Green (0,0), (16,65), (24,86), (40,111), (55,133), (94,179), (118,208), (156,255); Blue (0,0), (18,74), (47,128), (68,150), (119,216), (168,255). As with the darker image, there were again immediately noticeable differences between the raw-workflow version and the curved JPEG version of this image: lighter and redder whites of the eyes, shifted shadows on the face, and again a duller orange hair wrap band. However the changes were not as uniformly detrimental as they were in the darker image.

Comparison of Resulting Images

Here is the reduced 448x672 image resulting from the manipulation of the JPEG image.

JPEG-postprocessed photo reduced for web display

It is hard to discern a difference from the reduced raw-workflow image side-by-side, but differences can be seen by overlaying the two images and flipping from one to the other: the JPEG version has a darker orange band in the hair wrap, lighter eyes, more prominent freckles around the eye.

Some differences are more noticeable when viewed at 100%. The right eye (one of the few points of relatively sharp focus on an otherwise very soft photo) shows slightly washed out colors and detail and a pink cast in the JPEG version (right), compared to the raw version (left):

Right eye, 100%, raw  Right eye, 100%, jpeg

The lips are possibly a little darker in the jpeg version (right) compared to the raw version (left), and have significantly more grain despite the use of the same noise reduction action on both versions.

Right eye, 100%, raw  Right eye, 100%, jpeg

Finally, here is a close-up view of the problematic orange band. Again, the raw version is on the left, and the jpeg version is on the right. The later postprocessing steps seem to have made up for most of the problems in matching the color of the raw images with JPEG curves.

Right eye, 100%, raw  Right eye, 100%, jpeg

Second Experiment

The first experiment failed to uncover any visible JPEG artifacts such as 8x8 blocking. However, the image consisted largely of unfocused smooth regions where JPEG compression performs well. I wondered whether a more sharply detailed image would behave similarly, so I decided to try a different image, of a redwood forest (Navarro River Redwoods State Park in Northern California), shot with a 28/2.8 lens at F3.5 (smaller aperture would have been better for sharp focus but would have led to too long exposure times for a handheld photo). The photo was normally exposed but again involved heavy backlighting leading to very dark tree trunks against a bright sky:

Second photo, unprocessed, reduced for web display

Postprocessing again consisted of forming two images, one of which was digitally exposure-compensated 1.5 stops, applying a Levels command to rebalance the color in both images, and an L-channel curve to increase shadow detail, and compositing the images; finally, some perspective correction and moderate sharpening were applied. The sharpening was limited to non-shadow areas of the composite image, because the shadows contained too much noise to behave well under sharpening; however, no noise reduction action was used. Here is the image after postprocessing:

Second raw-processed photo reduced for web display

To match the darker of the two raw conversions I used curves with control points Red (0,0), (11,16), (35,43), (108,101), (191,169), (240,227), (255,255); Green (0,0), (7,11), (49,61), (94,94), (172,158), (234,226), (255,255); Blue (0,0), (8,13), (25,37), (59,67), (167,157), (220,209). In addition the raw linear conversion action included increased saturation, which I matched visually to a post-curve saturation increase of 15. To match the lighter conversion I used control points Red (0,0), (4,26), (9,39), (24,67), (41,91), (81,133), (129,195), (153,225), (191,255); Green (0,0), (4,23), (11,46), (22,66), (64,118), (191,255); Blue (0,0), (8,38), (25,72), (101,170), (126,195), (168,233), (197,255). A saturation increase of 20 provided a good visual match to the raw version. Below is the result of the JPEG-based workflow.

Second JPEG-processed photo reduced for web display

This was a less successful duplicate than the first photo, with differences apparent even in a side-by-side display. The color of the redwood trunks is duller than the raw-based version, while the added saturation needed to get the trees to this level of color has turned some of the foliage on the ground into an unnatural pure green. It was not possible to exactly match the perspective correction; although an exact match here is unimportant to the overall image quality, it makes it more difficult to compare the two images pixel-by-pixel, but even in the reduced web size it appears that the raw version has been able to preserve more detail, especially in the highlights. At full-zoom in the crops below of the lower parts of the tree trunks and some ground foliage (as before, raw on the left), the JPEG version looks flat and unconvincing.

Forest floor, 100%, raw  Forest floor, 100%, jpeg

Closer inspection of a crop at the forest canopy reveals that the apparent lack of detail in the reduced version is due to a mismatch between the luminosities of the raw and jpeg versions of the photo: the jpeg version is lighter and has therefore lost detail in some of the brightest highlights.

Forest canopy, 100%, raw  Forest canopy, 100%, jpeg

Still, no banding or other JPEG artifacts were visible, and I did not see clear differences in the amount of noise between the two pictures: both are sufficiently noisy in the darker areas that the original raw workflow (determined prior to this experiment) involved sharpening only non-shadow regions of the photo.

Conclusions


David Eppstein, Dept. Inf. & Comp. Sci., UC Irvine

August 18, 2002