ComfyUI Node

Analyze Depth

Before you trust a depth map, ask it how it's feeling — this node does the asking

By gokayfem·Created 2 years ago·Updated about a month ago· 70
Analyze Depth
  • depth_map
  • statistics_json
  • histogram
bins64

Depth maps look confident and are frequently lying. A map that's actually flat, or inverted, or full of clamped garbage will still render as a pretty grayscale image - which is exactly why you want a node that refuses to be impressed. Analyze Depth is the sanity check of the ComfyUI-Depth-Visualization toolkit (gokayfem's pack, same author as ComfyUI-Texture-Simple and Decartunizer). It reads your depth and tells you, in numbers and a picture, what's actually in there.

How it works

Per image in your batch it computes the honest set of statistics - min, max, mean, median, std, and the p01/p99 percentiles that tell you where the bulk of the map actually lives - plus two fractions that answer the classic depth questions: how much of the map is "near" (depth ≤ 0.25) and how much is "far" (depth ≥ 0.75). Alongside the JSON it renders a 640×300 histogram of the depth distribution, axis labeled near 0 to far 1, so you can see the shape of the scene at a glance.

That's the whole mechanism, which is the point: it's cheap, CPU-only, and never guesses for you.

Inputs and outputs

One real input, depth_map. One knob, bins (default 64, 16–256) - how many buckets the histogram uses. More bins show fine structure; 64 is plenty for a diagnostic.

Outputs:

  • statistics_json (STRING) - the numbers, per batch item. Drop it into a ShowText node to read it in the graph.
  • histogram (IMAGE) - the chart. Wire it to a preview/save node and you've got a workflow-visible depth report you can eyeball without opening anything.

How to actually read it

This is where the node earns its keep. Three checks that catch most depth problems in seconds:

  • p01p99? Your map is essentially flat - one value everywhere. Either your estimator failed, or you fed it a blank/gray image. Nothing downstream will work.
  • near_fraction_0_25 is ~1.0 (or 0.0)? Your depth is inverted relative to what you assume, or clamped to one end. That's a Normalize Depth + invert fix, not a model problem.
  • The histogram is a single spike with tails? You've got a mostly-flat background with a small object - common and fine, but it explains why "everything looks the same depth" when you export a mesh.

Install

Manager: search ComfyUI-Depth-Visualization, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/gokayfem/ComfyUI-Depth-Visualization.git
python -m pip install -r ComfyUI-Depth-Visualization/requirements.txt

Restart, find it under depth/toolkit. numpy + Pillow, no models, no network, CPU-friendly - the whole pack is like this.

Where people get burned

  • The JSON is a string, not a table. It's meant for ShowText or a JSON-serializing node, not for wiring into arithmetic nodes - grab numbers from a JSON parse node if you want to act on them.
  • Statistics assume [0,1] depth. Run Depth Normalize first, or the near/far fractions and histogram axis are measuring whatever arbitrary range your estimator output.
  • It diagnoses, it doesn't fix. This is the "look, not touch" node - when the numbers say broken, the fix lives in Depth Cleanup and Depth Normalize upstream, not here.
Categorydepth/toolkit

Inputs (2)

NameTypeDefaultDescription
depth_mapIMAGE
binsINT6416–256

Outputs (2)

NameTypeDescription
statistics_jsonSTRING
histogramIMAGE