Spaces:
Running
Running
Download index.html from depthmap/verify-16bit-depth-map: direct link, hf CLI and curl.
- Browser
- Download file 3.91 kB
-
https://huggingface.co/spaces/depthmap/verify-16bit-depth-map/resolve/main/index.html
- Command line
-
hf download hf://spaces/depthmap/verify-16bit-depth-map/index.html
-
curl -L -o index.html https://huggingface.co/spaces/depthmap/verify-16bit-depth-map/resolve/main/index.html
3.91 kB
| <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>How to Tell a Real 16-bit Depth Map from a Stretched 8-bit One</title> | |
| <style>body{margin:0;font:18px/1.6 system-ui,-apple-system,Segoe UI,sans-serif;background:#f6f4ef;color:#111}main{max-width:820px;margin:0 auto;padding:32px 20px 64px}a{color:#0b57d0}table{border-collapse:collapse;width:100%;background:#fff}th,td{border-bottom:1px solid #ddd;padding:8px 10px;text-align:left;font-size:.95rem}pre{background:#fff;border:1px solid #ddd;padding:12px;overflow:auto;border-radius:8px}code{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.88em}</style> | |
| </head><body><main><h1>How to Tell a Real 16-bit Depth Map from a Stretched 8-bit One</h1> | |
| <p>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.</p> | |
| <h2>The quick test</h2> | |
| <p>Count the distinct gray values.</p> | |
| <pre><code class="language-python">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)) | |
| </code></pre> | |
| <p>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.</p> | |
| <h2>A measured example</h2> | |
| <p>The public dataset <a href="https://huggingface.co/datasets/depthmap/16bit-vs-8bit-depth-maps">depthmap/16bit-vs-8bit-depth-maps</a> contains the same lion-medallion height field three ways, measured with Pillow on 15 November 2026:</p> | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>File</th> | |
| <th>Header</th> | |
| <th>Distinct values</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td><code>lion-depth-16bit.png</code></td> | |
| <td>16-bit</td> | |
| <td>19,662 (min 0, max 19,661)</td> | |
| </tr> | |
| <tr> | |
| <td><code>lion-depth-8bit.png</code></td> | |
| <td>8-bit</td> | |
| <td>77</td> | |
| </tr> | |
| <tr> | |
| <td><code>lion-depth-8bit-upscaled-to-16bit.png</code></td> | |
| <td>16-bit</td> | |
| <td>77, all multiples of 257</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <p>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.</p> | |
| <h2>Why the max is 19,661, not 65,535</h2> | |
| <p>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.</p> | |
| <h2>Where the sample came from</h2> | |
| <p>I made the 16-bit PNG and the matching closed STL with a <a href="https://depth-map.com/" target="_blank" rel="noopener">depth map generator</a> from one photograph, then derived the 8-bit and upscaled copies in the dataset so all three share one height field. The dataset includes <code>verify.py</code> so you can re-run the counts yourself, and a static Space, <a href="https://huggingface.co/spaces/depthmap/16bit-vs-8bit-depth-map-guide">16-bit vs 8-bit depth map guide</a>, shows shaded side-by-side previews.</p> | |
| <h2>Checklist before you engrave or print</h2> | |
| <ul> | |
| <li>Mode is <code>I;16</code> (or ImageMagick <code>identify -verbose</code> reports <code>Depth: 16-bit</code>).</li> | |
| <li>Distinct values are well above 256.</li> | |
| <li>Values are not all multiples of 257.</li> | |
| <li>The max matches the relief depth you asked for on your height scale.</li> | |
| </ul> | |
| <p>If any of those fail, regenerate or re-export rather than smoothing the terraces after the fact.</p> | |
| </main></body></html> |