Depth Metric to Inverse
1/(1+depth)
- depth
- inverse_depth
This is the pack's simplest node and it's happy to be that. DepthMetricToInverse takes a metric depth map and applies one transform:
inverse = 1 / (1 + depth)
That's the entire node. One input, one output, zero knobs. If you're the kind of person who skips these little utility nodes in a pack, don't - this one exists because the transform is genuinely useful, and it's the cheapest way to understand what "inverse depth" means in the refocus context.
Why the transform exists
Inverse depth (a.k.a. disparity-like depth) is what defocus math actually wants to work with. The problem with raw metric depth is that it's unbounded and dominated by far distances - a 50-meter background dwarfs a 2-meter subject, so the near/far contrast you care about gets crushed into a tiny range. 1/(1+d) compresses far distances aggressively while preserving the near-field structure where your subject lives. That's why the Refocus pipeline's Compute Defocus Map is documented to take disparity-style input, and why this node's description calls inverse depth "useful for defocus maps."
It's also the same first step that the beefier Depth Metric to Relative node runs internally before it normalizes - this is just the unnormalized, no-options version. If you only ever need near=bright disparity values and want them unclamped, this is your node.
When to reach for it
- Feeding a defocus map that's too flat - if Compute Defocus Map gives you a map with almost no contrast because your depth is metric and far-field-heavy, run the raw depth through this node first and the depth gradient will read properly.
- Visualizing depth correctly - inverse depth is what most depth visualizations actually show (near bright, far dark), so this is a quick sanity check on whether DepthPro actually separated your subject from the background.
It's a dumb pass-through; you'll notice it's only worth a node if the pack is already in your graph.
The single gotcha
The 1/(1+d) step assumes non-negative input. A normalized or metric depth map is fine. If you accidentally feed it something signed or inverted, you'll get values that don't mean what the name says - check the source of your depth before blaming the node. Also, unlike DepthMetricToRelative, there's no inversion toggle and no gamma: you get the raw transform, take it or leave it.
Install
Part of the Refocus pack - ComfyUI Manager ("Refocus - Generative Refocusing") or git clone https://github.com/EricRollei/comfyui-refocus into custom_nodes/, then restart. One of the always-available nodes, no diffusers required, no models, no pip extras. It's pure torch tensor math; if it's missing from your node list, the pack itself didn't load.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| depth | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| inverse_depth | IMAGE | — |