Like most digital SLRs, Nikon’s family of digital SLRs offer the ability to shoot in raw mode. However, Nikon’s raw offerings provide a twist, in the form of compressed raw. The promise of compressed raw files, of course, is that they take up less space and allow you to store more images on your card. Data compression algorithms fall into two categories: lossy techniques, which degrade the quality of your image; and lossless techniques, which reduce file size without affecting image quality. Nikon users often ask whether the compressed raw format is lossless or lossy, so I decided to look into the question

Nikon makes no claims that the format is lossless, but they say that the amount of information that is tossed out is insignificant, and that the format’s algorithm is “not visible lossy” or something to that effect. Obviously, if you’re chosing not to shoot JPEG, the idea of losing image data seems to negate one of the entire reasons to shoot raw. However, there can be extra, unused image data in a raw file, but to try to get a clearer idea of just how lossy the format is, I decided to ask some of the companies that make raw conversion software. Since they have to deconstruct the raw formats, and study them very closely, I figured they’d have a good idea of how compressed Nikon raw files compare to uncompressed.

Unfortunately, while everyone I talked to at Apple and Adobe was very nice and very helpful, they were also hesitant to comment on the issue, lest Nikon trouble them over infringement and intellectual property violations.

Finally, I turned to Dave Coffin, author of the excellent DCRaw. In addition to writing this open source raw converter, Dave has had to perform the same type of raw profile building that Apple and Adobe must hassle with.

Dave’s answer was very straightforward:

It’s definitely lossy, whether or not that loss is perceptible to the average user. The raw sensor has a range of 0-4095, but a non-linear curve reduces this to the range 0-682.

Attached is the curve taken from a Nikon D70s image. The left column is the compressed raw value; the right column is the linear sensor value that it maps to. Note that all values less than 216 map to themselves, so as to preserve shadow detail. Whereas at the end:

676 4011
677 4026
678 4041
679 4055
680 4070
681 4085
682 4095

Thus, for example, any sensor pixel between 4055 and 4070 gets rounded to one of those values.

In other words: when compressing, shadow values are preserved but midtone and highlight values are compressed. As you can see from Dave’s data, highlight values are compressed quite a lot. In a raw capture, most of the data that the camera records is in the brightest few stops, so this is a reasonable place to start throwing out data to achieve better compression. However, if you practice an “expose to the right” exposure strategy when shooting raw, then compressed raw will make such a plan useless. So, when shooting in compressed raw you’ll want to stick with following your meter.

Even if you don’t feel like this is an unacceptable level of data loss, there’s still very little reason to shoot compressed raw, simply because storage cards are so affordable now. However, if you find yourself in a situation where you’ve run out of storage, switching to compressed raw might be a better option than switching to JPEG, as it will still afford you white balance correction that’s not possible with JPEG.