A depth map is a greyscale image in which each pixel stores a distance instead of a colour. In the maps this tool produces, white is nearest and black is farthest. That is a convention, not a law: some software, including many 3D renderers, uses the opposite, which is why every export here can be inverted. A depth map is the bridge between a flat picture and anything that has thickness, from a printed relief or a lithophane to a CNC carving or a parallax effect.
There are two very different ways to get one from an ordinary image, and the tool offers both, because each is right for a different kind of picture.
Brightness mode: when the grey already means height
Brightness mode makes no guess about the scene. For every pixel it computes the luma with the Rec. 709 weights (0.2126 × red + 0.7152 × green + 0.0722 × blue), the same formula used for HD video, so green counts most and blue least, the way the eye perceives brightness. Luma then goes through the adjustments in a fixed order: gamma first, then invert, then optional smoothing with a three-pass box blur, a cheap separable filter that approximates a Gaussian blur. Finally the result is multiplied by the pixel's alpha, so a transparent background always ends up flat and far, whatever else you change. The black and white points are applied last, to the finished map, so they stretch whatever range is left. Very large images are scaled down to at most 4 megapixels first, which keeps the page responsive and memory use reasonable.
This is exactly right for logos, line art, embossing masks, terrain height maps and any image that someone already painted as height. It is exactly wrong for most photos: a white shirt is not closer than a dark face, and a bright sky is the farthest thing in the frame. For photos, use AI mode.
AI mode: Depth Anything V2 Small, in your browser
AI mode runs Depth Anything V2 Small, a monocular depth estimation model published in 2024 by Lihe Yang and colleagues. "Monocular" means it works from a single photo, the way you can still judge depth with one eye closed: from perspective, occlusion, texture and the typical sizes of familiar things. The authors trained large teacher models on synthetic images with precise depth and used them to label a large set of real photos, then trained smaller student models on those labels. The family spans 25 million to 1.3 billion parameters; the Small variant is the 25-million one, released under the Apache-2.0 licence, while the larger Base, Large and Giant variants are licensed for non-commercial use only, so this tool never loads them.
What happens to your photo, step by step:
- Resize. The model expects an input of about 518 pixels, with both sides a multiple of 14 (it cuts the image into 14 × 14 patches). The image is scaled by the smallest change that brings one side to 518 while keeping the aspect ratio, and each side is rounded to a multiple of 14. For a typical landscape photo this puts the short side at 518 pixels. Very wide panoramas are capped at 2,072 pixels on the long side. The resampling is a port of the bicubic filter the model's reference pre-processing uses, with proper antialiasing so fine texture does not alias into false edges. Transparent areas are composited over white.
- Normalise. Each colour channel is scaled to 0–1 and normalised with the ImageNet mean and standard deviation, exactly as in the model's published pre-processing configuration.
- Infer. The model runs through ONNX Runtime Web in a background worker, on the GPU with WebGPU when available, otherwise on the CPU with WebAssembly. The weights are the half-precision (fp16) ONNX export, about 50 MB, downloaded once from Hugging Face and kept in your browser's cache storage until you click Remove the downloaded model.
- Normalise the output. The model returns relative inverse depth: larger numbers mean nearer, but the numbers have no unit. The tool rescales them so the nearest point in the picture is 1 and the farthest is 0, then resamples the map back to your image's size.
Because the model sees your photo at about 518 pixels on its short side, the map is smooth at that scale: it captures the shape of a face or a building, not individual eyelashes or bricks. Scaling it back up does not invent detail that the model never saw.
Refining the subject at higher resolution
The model always sees the picture at about 518 pixels on its short side. In a group photo a face may be only 60 to 140 of those pixels wide, and the model returns it as an almost flat patch. Refine the subject at higher resolution runs the same model again on overlapping square crops of the subject, each magnified to fill the model's input, so a face gets two or more times as many pixels. Each crop's depth has its own arbitrary scale, so it is fitted to the whole-photo depth by least squares (one scale, one offset), and a crop whose depth runs the other way or does not fit is discarded. Only the fine detail a crop adds is kept, blended with soft edges; who stands in front of whom still comes from the pass that saw the whole scene. This follows the idea of merging depth estimated at several resolutions described by Miangoleh and colleagues. It is on by default: the unrefined map is shown first and replaced when the crops finish, and unticking the option stops them and keeps the quick result. It costs up to 16 more passes of the model (in our test, 12 crops and about 35 seconds on the processor for a photo of three people), and the summary says how many crops were merged. It cannot recover what the model does not see: hair hiding an ear stays hair, and glasses come out as a raised frame.
When the image is a cut-out, the 16-bit and 8-bit PNG keep the subject in an alpha channel (greyscale with alpha, still a standard PNG), so Depth Map to STL knows where the background is and can leave it unprinted.
Relative depth versus metric depth
This is the most common misunderstanding about AI depth. A relative depth map tells you the order and rough proportions of distances: the nose is in front of the ears, the tree is in front of the house. It does not tell you that the house is 12 metres away. Depth Anything V2 Small, as used here, produces relative inverse depth, and the tool normalises it to the 0–1 range of each picture, so two photos of the same scene can map to slightly different grey levels. That is ideal for reliefs, where you choose the physical height yourself in millimetres. It is not a measuring instrument. If you need real distances, you need a metric model, a depth sensor, or a calibrated stereo or photogrammetry setup.
8-bit or 16-bit PNG?
Both downloads are standard greyscale PNG files as defined by the W3C PNG specification, which allows greyscale images at 8 and 16 bits per sample. An 8-bit file has 256 possible grey levels. Spread over a 5 mm relief that is about 0.02 mm per level, far below what a printer can show; spread over a 50 mm relief it is about 0.2 mm per step, and a smooth cheek becomes visible terraces. A 16-bit file has 65,536 levels, so steps are never the limiting factor. Use 16-bit whenever the map is going to become geometry, and 8-bit when you only need a picture, for example as a displacement preview or in software that cannot read 16-bit images.
Getting a good result
- One clear subject against a background at a different distance gives the cleanest separation. A portrait, a statue, a car or a building front works well.
- Use Black point and White point to spend the whole grey range on the subject. If the background is not needed, raise the black point until it goes flat.
- Remove the background first when you want only the subject in relief. The Background Remover cuts it out and its "Use for bas-relief" button sends the cut-out here; in AI mode everything that is transparent stays at depth zero, so the relief gets a flat field around the subject. The empty background is left out of the range: the levels are stretched over the subject alone, so its darkest tone becomes black and its white stays white, and the subject uses the whole range of the map.
- Gamma above 1 pushes midtones back and makes the nearest parts stand out; below 1 lifts the midtones and flattens the front.
- Smoothing removes grain from brightness maps and softens small artefacts in AI maps; a radius of 1 to 3 is usually enough.
When not to use it
Do not use it when you need metric depth, real distances in metres or millimetres, for measurement, robotics or construction. Do not use it to rebuild a whole object from several photos: that is photogrammetry, which matches points between views and recovers real geometry, including the back of the object, which a single photo can never show. And expect trouble at hair, fur, glass and reflections: fine strands blur into the background at 518 pixels, and transparent or mirrored surfaces show the depth of whatever is behind or reflected in them, which is what the model then reports.
From depth map to object
Once the map looks right, Depth Map to STL turns it into a solid relief with a flat back, ready for a 3D printer, and the online STL slicer turns that into G-code, all in the same browser tab.
If your picture is a two-tone logo or drawing rather than a photo, you do not need a depth map at all: Image to STL traces its outline straight into a flat, printable part.