How to Tell a Real 16-bit Depth Map from a Stretched 8-bit One
A depth map PNG can say "16-bit" in its header and still carry only 8-bit information. For screen effects that rarely matters. For a laser engrave, a lithophane, or a CNC relief, it shows up as visible terraces.
The quick test
Count the distinct gray values.
from PIL import Image
im = Image.open("depth.png")
vals = list(im.getdata())
print(im.mode) # I;16 for a 16-bit grayscale PNG
print(len(set(vals))) # distinct height codes
print(min(vals), max(vals))
A stretched 8-bit file has 256 or fewer distinct values, and every value is a multiple of 257 (because 8-bit codes were multiplied by 257 to fill the 0–65,535 range). A genuine 16-bit field has thousands.
A measured example
The public dataset depthmap/16bit-vs-8bit-depth-maps contains the same lion-medallion height field three ways, measured with Pillow on 15 November 2026:
| File | Header | Distinct values |
|---|---|---|
lion-depth-16bit.png |
16-bit | 19,662 (min 0, max 19,661) |
lion-depth-8bit.png |
8-bit | 77 |
lion-depth-8bit-upscaled-to-16bit.png |
16-bit | 77, all multiples of 257 |
The third file is the failure mode: the header says 16-bit, the count does not. Stretching 77 codes into a bigger container does not invent the missing steps.
Why the max is 19,661, not 65,535
That export was written on a 10 mm full scale (65,535 = 10 mm), and the relief was 3 mm deep. A 3 mm relief uses about a third of the range, so the brightest pixel lands near 19,661. On the same scale an 8-bit file only has 77 height steps for 3 mm, which is where the terracing comes from. A shallow relief like this can also look almost black in a normal image viewer; that is expected, not a broken file.
Where the sample came from
I made the 16-bit PNG and the matching closed STL with a depth map generator from one photograph, then derived the 8-bit and upscaled copies in the dataset so all three share one height field. The dataset includes verify.py so you can re-run the counts yourself, and a static Space, 16-bit vs 8-bit depth map guide, shows shaded side-by-side previews.
Checklist before you engrave or print
- Mode is
I;16(or ImageMagickidentify -verbosereportsDepth: 16-bit). - Distinct values are well above 256.
- Values are not all multiples of 257.
- The max matches the relief depth you asked for on your height scale.
If any of those fail, regenerate or re-export rather than smoothing the terraces after the fact.