Image to Depth Map

Image to Depth Map

Turn a photo or drawing into a greyscale depth map in your browser, by brightness or with on-device AI (Depth Anything V2). Export 8- or 16-bit PNG.

3D Printing

Your image never leaves your browser. The AI model is downloaded from Hugging Face once; your image is not sent anywhere.

Examples
Mode
Adjustments
1.00
0.00
1.00
0

Keywords

image to depth mapdepth map generatorai depth estimation onlinephoto to depth mapdepth anything v2 online16-bit depth map pngdepth map for 3d printing

Need something else?

How to use

1

Drop a JPG, PNG or WebP onto the page, or open Examples and pick one of the built-in test images. The image is decoded in your browser and never uploaded.

2

Choose a mode. Brightness works instantly on logos, drawings and images that already encode height as grey. AI estimates depth from the content of a photo: click Download the AI model once (about 50 MB from Hugging Face) and it is stored in your browser for next time.

3

Refine the result with the adjustments: Invert swaps near and far, Gamma bends the midtones, Black point and White point stretch the useful range, and Smoothing removes grain. The preview updates as you move each slider.

4

Compare the original and the depth map side by side. Brighter means nearer. Check that the subject stands out from the background the way you want before exporting.

5

Download the depth map as an 8-bit or 16-bit greyscale PNG, or press Turn into 3D to send it straight to the Depth Map to STL tool and build a printable relief.

Features

Two ways to get depth

Brightness mode reads Rec. 709 luma and treats bright as near, which is exactly right for artwork, embossing masks and height maps. AI mode runs Depth Anything V2 Small, a monocular depth model that infers which parts of a photo are closer from the shapes and perspective it contains.

AI that runs on your device

The model runs in a background worker with ONNX Runtime Web, on your graphics card through WebGPU when the browser offers it and on the processor through WebAssembly otherwise. The page shows which one is in use. Your photo is never sent anywhere.

Adjustments you can see

Levels (black and white point), gamma, invert and a smoothing radius reshape the map without re-running the model. Each change redraws the preview after a short pause, so you can tune it by eye in a few seconds.

16-bit PNG export

An 8-bit PNG stores 256 grey levels; a 16-bit PNG stores 65,536. Both are plain greyscale files that any editor opens, and the 16-bit one keeps smooth gradients smooth when they become millimetres of plastic.

One click to a 3D relief

Turn into 3D hands the full-precision map to the Depth Map to STL tool in the same browser, where it becomes a watertight, flat-backed mesh you can download as STL, OBJ or 3MF or send on to the online slicer.

Why Choose This Tool?

Your photos stay on your device

Online depth services upload the picture to a server that runs the model. Here the model itself is downloaded to your browser and runs there, so family photos, client work and unreleased product shots never leave your machine. The only network request the tool makes is the one-time model download.

An honest model with an open licence

Depth Anything V2 Small is published by its authors under the Apache-2.0 licence, unlike the larger variants of the same family, which are for non-commercial use only. That is why this tool uses the Small model and nothing else: what you make with it is yours to use.

No account, no queue, no watermark

There is nothing to sign up for and no credits to buy. After the model has been stored once, estimating depth for another photo costs nothing but a few seconds of your own computer's time, and the result is a clean PNG with no branding on it.

Made for making things

Most depth tools stop at a picture. This one exports the precision a 3D printer or CNC router needs and connects directly to a relief generator and a slicer on the same site, so an image can become a physical object without installing anything.

How an image becomes a depth map: brightness, AI and what the numbers mean

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.

Frequently Asked Questions

Is my image uploaded?

No. The image is decoded and processed in your browser. In AI mode the model file is downloaded to your browser and runs there; no picture, depth map or personal data is sent to any server. Hugging Face, which hosts the model file, sees only an ordinary download request for it.

Why does AI mode need a download?

The model is about 50 MB of weights, and running it on your own device is what keeps your photo private. It is downloaded only when you click Download the AI model, then stored in your browser's cache storage so later visits start instantly. Remove the downloaded model deletes it again.

Which is brighter, near or far?

Near is brighter: white is the nearest point and black the farthest. This matches what relief and lithophane tools usually expect. Some 3D software uses the opposite convention; tick Invert before downloading if yours does.

Can I get distances in metres?

No. Depth Anything V2 Small, as used here, estimates relative inverse depth: it knows what is in front of what and roughly by how much, but not in any unit. Each map is normalised so its nearest point is 1 and its farthest is 0. For real distances you need a metric model, a depth sensor or photogrammetry.

Which mode should I use for a logo or a drawing?

Brightness. A logo or a drawing already says how high each part should be through its grey levels, and brightness mode reads that directly. AI mode would try to interpret the drawing as a photographed scene, which rarely gives what you intended.

Why is the AI depth map blurry at the edges of hair?

The model sees the image at about 518 pixels on its short side, so single strands of hair are smaller than a pixel of its input. Around hair, fur, glass and reflections the depth is a soft average. Smoothing will not fix that; for those subjects consider cleaning up the map in an image editor.

Should I download the 8-bit or the 16-bit PNG?

16-bit if the map will become geometry, such as a relief, a lithophane or a CNC toolpath: its 65,536 levels avoid visible steps. 8-bit if you just need an image, or your software cannot read 16-bit PNG. Both are standard greyscale PNG files.

Does it work on phones?

Brightness mode works on any modern phone. AI mode works too, but the 50 MB download and the inference itself are heavy for a phone; on the processor without WebGPU a single photo can take a noticeable time. A desktop browser with WebGPU is the fastest option.

Do I have to download the model every time?

No. The model is downloaded once and kept in your browser's cache storage, so later photos and later visits use the stored copy. It stays until you click Remove the downloaded model or clear your browser's site data. Brightness mode never needs the model at all.

Learn more