Spaces:
Running
Running
Add 16-bit depth map verification guide
Browse files- README.md +9 -3
- index.html +59 -19
README.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
| 1 |
---
|
| 2 |
-
title: Verify
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
license: cc-by-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Verify a 16-bit Depth Map
|
| 3 |
+
emoji: 🔍
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
license: cc-by-4.0
|
| 9 |
+
short_description: Tell a real 16-bit depth map from a stretched 8-bit one
|
| 10 |
+
tags:
|
| 11 |
+
- depth-estimation
|
| 12 |
+
- 3d-printing
|
| 13 |
+
- tutorial
|
| 14 |
+
- static
|
| 15 |
---
|
| 16 |
|
| 17 |
+
A short static guide: how to check whether a depth map PNG really carries 16-bit height data. The page lives in `index.html`; measurements come from the dataset depthmap/16bit-vs-8bit-depth-maps.
|
index.html
CHANGED
|
@@ -1,19 +1,59 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
| 3 |
+
<title>How to Tell a Real 16-bit Depth Map from a Stretched 8-bit One</title>
|
| 4 |
+
<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>
|
| 5 |
+
</head><body><main><h1>How to Tell a Real 16-bit Depth Map from a Stretched 8-bit One</h1>
|
| 6 |
+
<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>
|
| 7 |
+
<h2>The quick test</h2>
|
| 8 |
+
<p>Count the distinct gray values.</p>
|
| 9 |
+
<pre><code class="language-python">from PIL import Image
|
| 10 |
+
|
| 11 |
+
im = Image.open("depth.png")
|
| 12 |
+
vals = list(im.getdata())
|
| 13 |
+
print(im.mode) # I;16 for a 16-bit grayscale PNG
|
| 14 |
+
print(len(set(vals))) # distinct height codes
|
| 15 |
+
print(min(vals), max(vals))
|
| 16 |
+
</code></pre>
|
| 17 |
+
<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>
|
| 18 |
+
<h2>A measured example</h2>
|
| 19 |
+
<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>
|
| 20 |
+
<table>
|
| 21 |
+
<thead>
|
| 22 |
+
<tr>
|
| 23 |
+
<th>File</th>
|
| 24 |
+
<th>Header</th>
|
| 25 |
+
<th>Distinct values</th>
|
| 26 |
+
</tr>
|
| 27 |
+
</thead>
|
| 28 |
+
<tbody>
|
| 29 |
+
<tr>
|
| 30 |
+
<td><code>lion-depth-16bit.png</code></td>
|
| 31 |
+
<td>16-bit</td>
|
| 32 |
+
<td>19,662 (min 0, max 19,661)</td>
|
| 33 |
+
</tr>
|
| 34 |
+
<tr>
|
| 35 |
+
<td><code>lion-depth-8bit.png</code></td>
|
| 36 |
+
<td>8-bit</td>
|
| 37 |
+
<td>77</td>
|
| 38 |
+
</tr>
|
| 39 |
+
<tr>
|
| 40 |
+
<td><code>lion-depth-8bit-upscaled-to-16bit.png</code></td>
|
| 41 |
+
<td>16-bit</td>
|
| 42 |
+
<td>77, all multiples of 257</td>
|
| 43 |
+
</tr>
|
| 44 |
+
</tbody>
|
| 45 |
+
</table>
|
| 46 |
+
<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>
|
| 47 |
+
<h2>Why the max is 19,661, not 65,535</h2>
|
| 48 |
+
<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>
|
| 49 |
+
<h2>Where the sample came from</h2>
|
| 50 |
+
<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>
|
| 51 |
+
<h2>Checklist before you engrave or print</h2>
|
| 52 |
+
<ul>
|
| 53 |
+
<li>Mode is <code>I;16</code> (or ImageMagick <code>identify -verbose</code> reports <code>Depth: 16-bit</code>).</li>
|
| 54 |
+
<li>Distinct values are well above 256.</li>
|
| 55 |
+
<li>Values are not all multiples of 257.</li>
|
| 56 |
+
<li>The max matches the relief depth you asked for on your height scale.</li>
|
| 57 |
+
</ul>
|
| 58 |
+
<p>If any of those fail, regenerate or re-export rather than smoothing the terraces after the fact.</p>
|
| 59 |
+
</main></body></html>
|