NEF Compression
Prepared 2006-03-19 by Bill Claff
Updated 2014-03-01

Introduction

Image data in Nikon NEF files can be stored compressed or uncompressed.
With the exception of the D1 all Nikon DSLRs offer compressed NEF.
Some Nikon DSLR models only offer compressed NEF while others offer both compressed and uncompressed.
When both are available the question arises whether to choose compressed or uncompressed NEF.
As we will see below the image data is typically compressed twice.
In the following table compression means the first compression step; the second compression step is always loss‑less.
Some Nikon DSLR models offer lossless compression that is accomplished by skipping the encoding table..
The following table summarizes the Nikon DSLRs NEF compression options:

Model

NEF compression

Encoding table size

First missing value

D1

Uncompressed

n/a

 

D100

Both

567

107

D1H

Both

567

107

D1X

Both

567

107

D70/D70s

Compressed

683

216

D40/D40x

Compressed

683

216

D50

Compressed

683

216

D60

Compressed

683

216

D80

Compressed

683

216

D3000

Compressed

683

216

D90

Compressed

769

114

D3100/D3200/D3300

Compressed

769

114

D5000

Compressed

769

114

1 J1

Compressed

769

114

1 V1

Compressed

769

114

D2H/D2Hs

Both

683

216

D2X/D2Xs

Both

683

216

D200

Both

683

216

D300/D300S/D3 @12-bit

Both

689

240

D300/D300S/D3 @14-bit

Both

2753

640

D5100/D5200

Compressed

3073

450

D5300 @12-bit

Compressed

?

?

D5300 @14-bit

Compressed

3073

450

D4 @14-bit

Both

3073

450

D4 @12-bit

Both

?

?

D800 @12-bit

Both

?

?

D800 @14-bit

Both

?

?

D3S

Both

?

?

D3X @12-bit

Both

?

?

D3X @14-bit

Both

?

?

D700 @12-bit

Both

?

?

D700 @14-bit

Both

?

?

D610 @12-bit

Both

?

?

D610 @14-bit

Both

?

?

D7000 @12-bit

Both

?

?

D7000 @14-bit

Both

?

?

D7100 @12-bit

Both

?

?

D7100 @14-bit

Both

?

?

Df @12-bit

Both

?

?

Df @14-bit

Both

?

?

The hyperlinks point to text files with the encoding values for those readers who are interested in performing their own research.

(? indicated data that has not been collected yet.)

First missing value is the point at which encoding truly begins.

How it works

Raw image data is compressed by using a lossy encoding followed by non‑adaptive Huffman compression.

During encoding the distinct values from the Analog to Digital Converter (ADC) are reduced to either 567, 683, 689, 769, 2753, or 3073 depending on the camera model and bit depth.

The encoding tables are stored in the NEF file along with the encoded/compressed data.

Why it works

Here is a plot of the Unencoded (in Analog to Digital Units or ADUs) versus Encoded values for the 683 value table (the other tables are very similar):

The black line on this chart indicates the Nikon 683 value table.
The red line indicates the values that correspond to CIE Lightness.

Clearly the Nikon encoding makes the Encoded value very much like perceptual Lightness.

In other words, since the human visual system doesn’t distinguish bright values as well as darker values; there is no need to keep as much precision in the highlight data.

Conclusion

Although the design is imperfect, in this author’s opinion; the result is quite good and deserves the moniker “visually lossless”.
However, if you will be post processing images with a great deal of highlight content then you may want to choose uncompressed NEF rather than compressed NEF to reduce any chance of posterization.