A depth map is a grid of numbers. A 3D printer needs a closed surface made of triangles. This tool turns one into the other in a way that is simple enough to describe completely, which is what this page does. Everything below is the method the tool actually uses.
1. Reading the depth map
A 16-bit greyscale PNG, like the ones Image to Depth Map exports, is read at full precision, 65,536 levels. Any other image is read by brightness: the Rec. 709 luma of each pixel multiplied by its alpha, so a transparent background becomes the lowest level. Either way the result is a map of values from 0 to 1, where 1 is nearest and becomes the highest point of the relief. Invert flips that, which is what you want when dark should be high, as in a lithophane. Smoothing applies a three-pass box blur to the map before it is resampled onto the grid.
2. Laying a grid in millimetres
You choose the width; the depth follows the image's aspect ratio. The detail setting is the target spacing between grid points, 0.2 mm by default. A 100 mm wide image with a 4:3 aspect ratio at 0.2 mm spacing gives a grid of 501 × 376 points. The spacing is adjusted separately along each axis so that the grid ends exactly at the edges of the part. The depth map is then resampled bilinearly onto that grid, so its resolution and the mesh resolution are independent: a small image can make a large relief, it will simply be smooth.
Each grid point gets a height: base + maximum relief height × depth, with the depth rescaled so that its highest value is exactly 1. With a 2 mm base and a 5 mm maximum, the lowest point sits at 2 mm and the tallest at exactly 7 mm. The summary shows both numbers for the model as built.
Shaping the relief: why a face comes out flat, and depth compression
In a photo of several people, most of the depth range is the distance between them: one person stands in front of another, an arm reaches towards the camera. Scaled linearly into 5 mm, those jumps take nearly all the height and a nose is left a tenth of a millimetre proud of the cheeks. On our test photos the steps between subjects carried 41 to 47 % of all the depth change while covering under 6 % of the subject.
Sculptors solve this the way a coin does: the gaps are squeezed and the shapes kept. Depth compression does the same with the method Weyrich and colleagues described for digital bas-relief, built on the gradient-domain compression of Fattal, Lischinski and Werman. The tool measures the slope of the depth at several scales, shrinks the steep slopes (the jumps) by a factor that grows with their size, leaves gentle slopes as they are, and rebuilds the surface that best fits the new slopes by solving a Poisson equation inside the subject. Slopes are only ever reduced, never increased or reversed, and no brightness, edge or texture from the photo is used: the relief follows the estimated depth and nothing is added to it. The height the jumps give up is what the faces gain when the result is stretched to your maximum height.
Linear depth turns this off and is the right choice for a height map you drew yourself. Balanced (30 %) is the default for a depth map estimated by AI, and Faces / portrait (85 %) flattens the gaps further. Because the surface is rebuilt as a whole, the order of two distant points can change slightly at high settings; the direction of the slopes does not.
Printing the subject without its background
What is background should not have to be printed. When the map knows where the subject is (a cut-out from the Background Remover, a PNG with transparency, or the Treat black as background option for a plain map), choose Don't print the background. The model is then the subject alone: its outline, the base thickness underneath and the relief on top, with vertical walls. The heights are worked out in a fixed order. The empty background does not count. Inside the subject the levels are stretched, so its darkest tone becomes base level, plus the step at the edge, and white stays the top; each separate figure starts from its own darkest tone, so one that stands farther back does not sit on a block. Only then are the levels turned into millimetres, with white at the relief height you set.
The outline is traced between grid points with marching squares, so it is a smooth curve rather than a staircase of pixels. Before tracing, anything narrower than Smallest outline feature (0.8 mm by default, two nozzle widths) is removed, because a stray wisp of hair would otherwise become a spike no printer can make, and specks under 2 mm² are dropped and reported. If the subject is several separate shapes, the tool says how many pieces the model has: they print loose. Use the flat plate to keep them together, or a rim, a band at base height around the subject that also joins pieces lying close to each other.
3. The top surface and the diagonal choice
Every square of the grid becomes two triangles. There are two ways to cut a square in half, along one diagonal or the other, and on a curved surface they give different shapes. The tool compares the height difference along each diagonal and cuts along the one where the difference is smaller. That keeps ridges running along ridges and valleys along valleys, instead of producing a saw-tooth pattern where a sharp edge crosses the grid at an angle. All triangles are wound counter-clockwise seen from above, so their normals point out of the part.
4. Closing the solid: flat back and walls
A surface alone is not printable; it has to enclose a volume. The back is a flat plane at zero height built as a fan: triangles from a single centre point to each segment of the outer edge. Because the fan uses exactly the same edge points as the surface, the two meet without gaps. The walls are one vertical quad (two triangles) per edge segment, from zero height up to the surface. The result is watertight and manifold: every edge belongs to exactly two faces and all normals point outward, which is what the STL printability checker looks for and what slicers require.
The optional frame pads the grid with extra points around the image, set at base + frame height, so the border is part of the same continuous surface.
5. The triangle budget
The number of triangles is two per grid square plus three per edge segment for the back and walls. The 501 × 376 grid above gives 380,250 triangles, a binary STL of about 19 MB. Halving the spacing multiplies that by four. To keep files usable in a slicer and in the browser, the tool caps the model at one million triangles: if your settings would exceed it, the spacing is increased by 10 % at a time until the model fits, and a note shows the detail actually used. At 0.1 mm on that same 100 × 75 mm part, the tool settles on about 0.13 mm.
Finer spacing than your nozzle can reproduce buys nothing. A 0.4 mm nozzle draws lines 0.4 mm wide, so for most reliefs 0.2 mm is already finer than the print; 0.1 mm is worth it for small, highly detailed pieces or resin printers.
6. STL, OBJ or 3MF
- STL (binary) is the format every slicer reads. It stores each triangle as twelve 32-bit numbers plus two spare bytes, 50 bytes per triangle, and has no units: slicers assume millimetres, which is what this tool writes.
- OBJ is a text format widely read by modelling software such as Blender. It stores each shared corner once and refers to it by number; like STL it has no units, and this tool writes millimetres.
- 3MF is the 3D Manufacturing Format, a zipped XML package. Its core specification lets a file declare its unit; this tool writes millimetres explicitly, so the size is never misread. Modern slicers prefer it.
Bas-relief or lithophane?
The same mesh serves two very different objects. A bas-relief is a low, sculpted surface you look at from the front, lit from the side: coins and plaques are the classic examples. Use a depth map where near is high, a base of 2 mm or so, and a relief of a few millimetres to a centimetre; a side light brings the shape out.
For a plaque or a medal with a clean field around the subject, start one step earlier: the Background Remover cuts the subject out of the photo and passes it to Image to Depth Map, where the removed background stays flat instead of becoming bumps behind the figure.
A lithophane is a thin plate of translucent material whose thickness varies so that, lit from behind, thicker parts look darker and thinner parts brighter, and the picture appears. Here you should not use a depth map at all but the photo itself, read by brightness, with Invert ticked so dark areas become thick. Keep the base thin and the relief modest so light still passes through the thickest parts, and print in white or natural filament. The flat back sits on the print bed, which suits a flat lithophane panel.
When not to use it
This tool makes height fields: every point of the image gets one height, so it cannot make undercuts, overhangs or a full 3D figure. For a real 3D model of an object you need a CAD program, a sculpting tool or photogrammetry. It also does not add supports or hollow the part; slice it with the online STL slicer or your desktop slicer as usual.
For a crisp flat shape instead of a sculpted surface, such as a logo cut-out, a keychain or a sign with raised lettering, use Image to STL, which traces the outline of a two-tone image rather than reading every grey level as a height.