Photo Corners headlinesarchivemikepasini.com


A   S C R A P B O O K   O F   S O L U T I O N S   F O R   T H E   P H O T O G R A P H E R

Enhancing the enjoyment of taking pictures with news that matters, features that entertain and images that delight. Published frequently.

Lossy DNG: Heresy Or The New JPEG? Share This on LinkedIn   Share This on Google   Tweet This   Forward This

24 June 2014

In Heresy: Should I just wholesale blow away my Raw files?, Google Photo's John Nack confesses that he always wondered if he'd be able to actually see any visual difference between a rendered original Raw file and a lossy DNG proxy of the file. If there is no penalty for converting to lossy DNG, he would save between 40 and 70 percent of the disk space required for Raw files.

Nack famously converted all his wedding photos from Raw to DNG (not just to save space, but to outlast the proprietary format, a romantic notion if there ever was one). So he's just the guy for this.

Besides, he brought Zalman Stern along to Google. Stern worked on Camera Raw for many years and could tell him exactly what kind of trouble he was getting into.

LOSSY DNG

Lossy DNG and DNG are not the same thing, we should explain. There's nothing necessarily lossy about Adobe's DNG format. It can, in fact, include the entire proprietary Raw data within it, if you want. It's an option.

Lossy DNG was introduced in 2012.

If you opt for lossy compression when you convert to DNG, though, the Raw data is remapped from the world of 16-bit channels (typically 10 to 14 bits per channel depending on what your camera captures) to 8-bit channels.

DNG Converter. We've opened Preferences on the right so you can see where the lossy option is. There's also a command line switch if you want to script DNG Converter.

As Nack admits, this sounds like a terrible idea. Don't you lose the ability to recover highlight and shadow detail? Isn't that the whole point of working with Raw data?

PERCEPTUAL V. LINEAR

Well, as Stern explains in the piece, it depends on how you get to 8 bits, which he calls quantization. When the quantization is done in a perceptual space (adjusted for how we see things), you lose less than when it's done in a linear space (which is how the camera captures it).

Perceptual? Linear?

As the late Bruce Fraser put it in his Real World Camera Raw with Adobe Photoshop CS2, we don't see things the way a digital camera does.

He explained, "If we double the acoustic power going to our stereo speakers, the resulting sound isn't twice as loud." More simply, he pointed out, two spoonfuls of sugar in our coffee are not twice as sweet as one. And, more to the point, twice as many photons are not twice as bright to us. They're just brighter.

That's perceptual.

Things are different with a digital exposure. "When a camera captures six stops of dynamic range," he writes, "half of the 4,096 levels are devoted to the brightest stop, half of the remainder (1,024 levels) are devoted to the next stop, half of the remainder (512 levels) are devoted to the next stop and so on." The darkest parts of the image have just 64 levels.

That's linear.

The reason you need more than 8-bit channels in a Raw capture is to accommodate linear data.

So there's some efficiency to be gained by doing the quantization of depth reduction in a perceptual space. You can redistribute (or stretch) the data and, at the same time, preserve dynamic range. Adobe also adds a little artful dithering to avoid banding after color and tonal corrections.

Then that data is compressed using regular old JPEG compression.

As Stern put it, "The place you'd look for errors with lossy Raw technology are things like noise in the shadows and patterning via color casts in highlights after a correction." Those are the real-world implications.

NACK TESTS IT

There is a clever way to see for yourself what the price of using lossy DNG is.

Nack selected a contrasty image and imported the original Raw file into Lightroom where he exported it as a DNG with lossy compression and imported that DNG back into Lightroom. You could also do this with the free DNG Converter and the image editor of your choice.

You want the original Raw file and a lossy DNG copy.

Next, he cranked up the exposure in the shadow and recovered the highlights as much as possible. In Lightroom he pushed the sliders to +100 for Shadows and -100 for Highlights. He even used the Brush tool to open the shadows another full stop, squeezing every bit of data out of them.

He first made those adjustment to the original Raw file and then copied and pasted those same adjustments to the DNG copy. That's easy to do in Lightroom with the Copy Settings command.

A visual inspection didn't reveal anything obvious, he writes, but there's a trick that will let your computer show you what's different about the two images.

Nack doesn't say how he exported the edited images, but we'll assume it was as TIFFs using the same color space.

He opened both images in Photoshop in different layers of the same file. "I set the blending mode of the top layer to Difference in order to highlight any variation between the two versions." That's the trick.

What did it reveal?

Absolutely nothing. A black image. No derivation.

He tried the same thing with a few other images, he reports, including a few with subtle gradients. In only one image was he able to notice a difference, a shot of the moon over a darkened landscape. But only after he had increased exposure over four stops.

WE TRY IT

Seeing is believing, so we gave it shot. But even more, we wanted to compare the editing elbow room of a lossy DNG to DNG and JPEG.

We ingest images with an AppleScript that runs when Image Capture detects a memory card has been mounted. It prompts us for a directory and various options, including converting to DNG, which it does by running the command line version of DNG Converter.

So all we had to do was add a prompt for lossy compression and add the -lossy argument to the command line string.

We took three 12-megapixel landscape Raw files of a wooded area in Yosemite with a waterfall which we had shot Raw+JPEG and converted them into DNG and lossy DNG files. We also took a look at a Samsung EX2F Raw file of the ocean with a lot of sky. Here's the chart (all sizes in megabytes):

IMAGE NEF/SRW DNG LOSSY DNG JPEG
Yosemite Landscape _MRP4560.NEF 16.414.55.67.7
Yosemite Landscape _MRP4561.NEF 17.015.56.18.8
Yosemite Landscape _MRP4562.NEF 17.315.96.28.9
Seascape SAM_0116.SRW 29.711.94.92.9

Here's the funny part. Except for the Samsung (where there was a 16:9 aspect ratio applied to the JPEG), the lossy DNG files are smaller than the JPEGs.

We imported the same image as a NEF, full DNG and lossy DNG, zeroed the Basic adjustments in the Develop module, then slid Highlights to -100 and Shadows to +100 for full recovery, as Nack had done.

We exported each image as a TIFF and opened them in Photoshop on different layers, setting the Mode to Difference to compare the lossy DNG TIFF to the NEF TIFF and the full DNG TIFF. Both comparisons showed a black result, indicating no differences were found.

Then we decided to compare Basic adjustments between a lossy DNG and a JPEG.

That's where things got strange. We imported a JPEG and made the same Highlight and Shadow adjustments, exported it as a TIFF and put it on a layer with the lossy DNG. We thought we'd see some difference but again there was none.

We tried the JPEG against the NEF TIFF and again there was none there either.

At this point, we were blaming the image for being too flatly exposed to show a difference between renderings.

One thing we appreciated was how much faster the file opened for processing compared to a full-size Raw image. That's not just because the file size is smaller but because the initial Raw processing like demosaicizing has already been done.

IF AT FIRST

One experiment does not a lab technician make. We had to try it again.

So we picked a beach scene with the camera pointed southwest into the sun. That gave us strong contrast and a good tonal graduation in the sky.

We had the original Raw file, a camera JPEG and a lossy DNG we created from the Raw file.

Difference Filter. Our optimized lossy DNG edit compared to our optimized JPEG edit. They should be different and are.

We imported the Raw file into Lightroom and exported it as a TIFF. We compared it to the JPEG and the Difference mode showed changes in the top right corner, which was all deep blue sky. So we knew we had the right kind of image file to test.

We made a number of revisions to the three files but we weren't looking for differences any more. We were looking for headroom.

Both the Raw and lossy DNG files gave us more to work with than the JPEG. And it was our impression this particular lossy DNG more closely resembled the Raw's latitude than the JPEG as we moved the Exposure, Highlight and Shadow sliders around.

But it's important to point out that lossy DNG is not a Raw file and won't benefit from any processing engine improvements in the future, at least as far as demosaicizing is concerned. It just has more latitude than a JPEG.

NOT JUST FOR RAW

When we edited our JPEGs of Lotusland, we struggled to squeeze detail out of the shadows and hang onto it in the highlights. There just wasn't much headroom in the JPEG.

Had we saved them as lossy DNGs, though, we would have had a lot more headroom. And we would have enjoyed the same small file size (perhaps even smaller) plus the data integrity checksum all DNGs store. You can, incidentally, wrap your JPEGs up as a DNG with little increase in file size to get the checksum tag.

But that made us think.

We had been shooting Raw+JPEG to have the best of both worlds. But we found that to be more data than we actually needed. We weren't using the JPEGs but we were burning sets of backup DVDs every few weeks (sometimes every few days) according to our backup strategy. Not very efficient.

So this year we started shooting just Raws but converting everything to DNG (in the expectation that we are not far away from an Optics Pro that will read DNG as an input format). Lightroom is efficient enough to make edits to the Raw images painlessly (in fact, it's even fun).

That extended the number of days between long backup sessions.

But some of our shoots are really not Raw-worthy. Product shots, for example. We often slip into JPEG to do those because we control the lighting and can set things up so we don't have to do Raw conversions. It speeds things up a bit.

Why not use lossy DNG for those images? As a JPEG replacement?

We'd have more headroom for editing than a JPEG with a smaller file size than a Raw. And we only use JPEG as an output format, resized, anyway.

We've decided to try that. If we run into a problem, we'll still have the original Raw images on the card.

SOME GOTCHAS

There are a few costs to using lossy DNG.

Not every image editing application can parse a lossy DNG. Although, the complaint in the comments to Nack's article that they don't render as QuickLook previews isn't true in our case.

But don't expect DxO Optics Pro to handle the format. It doesn't.

And while Google apps like Picasa don't parse lossy DNG at the moment, they should be able to read the format soon if Nack has anything to say about it.

So you'll want to test this in your workflow. Make sure lossy DNG is spoken where your images travel.

And, then too, there's no distinction in the filename itself between a DNG and a lossy DNG. Lightroom can tell the difference, but you'll otherwise have to rely on the file size for a hint.

WHEN NOT TO DO IT

There are also some good reasons to not to use lossy DNG.

Adobe's Eric Chan discussed this at length in a support forum thread in which mentions three specific situations in which those gotchas Stern pointed are make it better to stick with the original linear data:

1. Staying in the original camera space primaries (as opposed to storing data that's already transformed to a canonical space, like Adobe RGB or sRGB, like most camera JPEGs).

I see two advantages. One is that since the data is not yet mapped/clipped to a smaller gamut space, the Raw converter can then perform smooth gamut mapping (under user control) to determine how saturated colors are handled. For example, red flowers that are often clipped in camera JPEGs are often not clipped in the original camera primaries (they only become clipped during the Raw-to-output gamut mapping process, unless one takes care to avoid the clipping). A second advantage is that chromatic aberration correction tends to work a lot better. This is because of the spectral separation between the primaries. (Once they are "mixed" into sRGB or Adobe RGB primaries, it is much harder to perform the correction.)

2. Changing the white balance. Yes, one can change the WB for any output-referred image, too, but since the tone curve used to render that data is often unknown, it is much harder to get good WB results without color crosstalk along the tonal range (e.g., light areas may appear neutral, but midtones will then take on a cast or vice versa). Furthermore, most output-referred data is already white-balanced and any channels that become clipped in the process cannot be recovered if one wants to adjust the WB (see previous item on gamut mapping).

3. Noise reduction. Of course, one can always do noise reduction on any image data format or type. However, having (mostly unprocessed) scene-referred data establishes a much better mapping to physical noise models (e.g., how noise varies as a function of exposure), which we use to drive to the noise reduction algorithms.

The white balance issue is worth emphasizing. Your camera's auto white balance is nearly infallible, we've found, for daylight, cloudy, shade and common light sources like tungsten. But more exotic light sources (kitchen lighting comes immediately to mind) can be tricky.

By the time you get to post-processing with the Camera Raw filter in Photoshop CC 2014, the JPEG white balance options are only As Shot, Auto and Custom. Lossy DNG gets As Shot, Auto, Daylight, Cloudy, Shade, Tungsten, Fluorescent, Flash and Custom.

Custom covers it, of course, but, as Chan points out, you risk some crosstalk when you change white balance in those formats in post processing. You can avoid that by setting a custom white balance in the camera for unusual light sources.

As of note in that same thread, Chan confesses to being uncomfortable with lossy DNG for archival purposes. Considering the evolution of the Camera Raw technology, having access to more bits per pixel might one day be even more useful than it is now.

CONCLUSION

The key to lossy DNG's image quality is the perceptual mapping prior to quantization. The issue isn't really about limiting what you can see as it is about preserving what there is to edit.

We wouldn't champion a file format simply for its small size. Storage isn't that expensive. We have, however, begun to use it for what used to be a JPEG capture.

If you've been shooting JPEGs, you'll find more to edit with a lossy DNG. If you shoot Raw, you may, like Nack, not miss your Raw captures much. Either way, if you mind the white balance for unusual light sources (like gymnasiums), the sweet spot for lossy may be where you would have used JPEG.

We also find it intriguing that this particular pot has been stirred two years after the format's introduction.

In that time, two new developments have changed the landscape. One is the increasing popularity of smartphone photography and the other is cloud-based image editing. Lossy DNG provides advantages over both Raw files and JPEG images for both.

Its small footprint makes transmission times equivalent to JPEG transmissions. And its image editing latitude makes it an ideal Raw format for cramped smartphones.

If nothing else, it's worth another look.


BackBack to Photo Corners