Nodes/ComfyUI-DepthNormalizer/Depth Range (Manual)
ComfyUI Node

Depth Range (Manual)

Stop Feeding Flat, Muddy Depth Maps to ControlNet

By vito0131·Created 6 months ago·Updated 6 months ago· 1
Depth Range (Manual)
  • image
  • image
min_8bit0
max_8bit255
target_max_8bit230
subtract_mintrue
clamp_to_targettrue
stats_json

Depth maps have a dirty secret: the value range a model actually outputs barely ever fills the 0–255 space you're picturing. Depth Anything might hand you a map where the meaningful pixels sit between 1 and 117, which means your ControlNet is working from a washed-out gray rectangle and your parallax effect has all the drama of a damp paper towel. Depth Range (Manual) - the one node in the tiny ComfyUI-DepthNormalizer pack - lets you take that compressed map, declare "my useful range is 1 to 117," and stretch it so it actually uses the brightness it deserves.

It's a fiddly little utility from a small, MIT-licensed repo with essentially no community footprint (search the reddit corpus for "DepthNormalizer" and you get zero hits). That's fine - this is a tool you reach for once, wire up, and forget, not a pack with a following. Its whole job is one mathematically boring remap, done in a way that doesn't fight ComfyUI.

How it works

The trick is that ComfyUI's IMAGE is a float tensor in 0–1, while everyone thinks about depth in 8-bit 0–255 terms. The node converts in and out for you: x255 = image * 255, does the remap in 8-bit space, then divides back by 255 so the output plugs straight into anything that expects a normal image.

With subtract_min on (the default), the math is (x255 - min) * (target / (max - min)) - so your min becomes black, your max becomes target_max_8bit, and everything between slides linearly. Leave subtract_min off and it just multiplies the whole map up by target / max, which keeps whatever dark floor your source had instead of forcing pure black. The whole thing is a couple of tensor ops, so it costs nothing on VRAM and doesn't care how big your batch is.

The inputs that matter

Despite the name, you don't touch all six. The ones you actually set:

  • min_8bit / max_8bit - your source map's useful floor and ceiling in 8-bit terms. This is the guesswork part; it's where the node earns its "Manual" label.
  • target_max_8bit - where max maps to. The default is 230, and that's the pack's whole point: leave a little headroom under 255 so highlights don't clip into pure white. Set it to 255 if you want the full range.
  • subtract_min - keep it on unless your map has a meaningful black floor you want preserved.

There's a genuinely clever optional input too: stats_json. Wire the "Histogram Data (JSON)" output from Olm Histogram into it and the node auto-fills min_8bit/max_8bit from the real luminance stats, skipping the eyeballing entirely. The only output is image, a normalized IMAGE you feed into your ControlNet depth conditioning, displacement/displacement-height, or parallax stack.

Installing it

ComfyUI Manager → Install Custom Nodes → search "DepthNormalizer". Or the manual route:

cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/vito0131/ComfyUI-DepthNormalizer.git

Then restart ComfyUI. There's no requirements.txt to babysit, no model files to download - it's pure torch and the stdlib. You'll find it under Depth/Normalize in the node menu.

Common gotchas

  • max_8bit must be greater than min_8bit. The code guards against division by zero, but if you feed it an inverted range you'll get a degenerate all-black or all-white output, and the error message won't tell you why.
  • Turn clamp_to_target off and you can blow past your target - output clamps at 255 instead, which sometimes overshoots and clips. Default on is the safe call.
  • Wrong min/max = washed result. Underset and your map stays muddy; overset and you crush the range into near-flat black/white bands. The histogram trick above is the fix, and it's the reason this little node is worth keeping around.
CategoryDepth/Normalize

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
min_8bitINT00–255
max_8bitINT2550–255
target_max_8bitINT2301–255
subtract_minBOOLEANtrue
clamp_to_targetBOOLEANtrue
stats_jsonoptSTRING

Outputs (1)

NameTypeDescription
imageIMAGE