NEF Compression
Prepared 2006-03-19 by Bill Claff
Updated 2017-03-24

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/D700 @12-bit

Both

689

240

D300/D300S/D3/D700 @14-bit

Both

2753

640

D5100/D5200

Compressed

3073

450

D5300 @12-bit

Compressed

769

114

D5300 @14-bit

Compressed

3073

450

D7000/D7100 @12-bit

Both

769

114

D7000/D7100 @14-bit

Both

3073

450

D3S/D3X/D4/D610/D800/D800E @12-bit

Both

769

114

D3S/D3X/D4/D610/D800/D800E @14-bit

Both

3073

450

D7200/D750/D810 @12-bit

Both

1025

400

D7200/D750/D810 @14-bit

Both

4097

1552

D5500 @12-bit

Compressed

1025

400

D5500 @14-bit

Compressed

4097

1552

D5600 @12-bit

Compressed

?

?

D5600 @14-bit

Compressed

?

?

D810A @12-bit

Both

?

?

D801A @14-bit

Both

?

?

D600 @12-bit

Both

?

?

D600 @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, 1025, 2753, 3073 or 4097 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.