ComfyUI Node

Tonemap

Pull blown-out highlights back instead of hard-clipping them

By spacepxl·Created 3 years ago·Updated 8 months ago· 293
Tonemap
  • images
  • IMAGE
input_mode
output_mode
tonemap_scale1.00

When a value in an image tries to go brighter than pure white, a display or a straight clip just chops it off - you lose all the gradation in that blown-out area, it's just flat white. Film and cinema color science solved this decades ago with tonemapping: instead of a hard clip, compress the top end of the range with a curve so bright areas roll off smoothly and keep some detail instead of slamming into a wall. This node applies exactly that kind of curve to your images, and the pack's README hands you the actual formula it uses rather than leaving it a black box - it's built around an S-Log3-style log-plus-contrast curve, the same family of math used in real cinema camera color spaces.

When you'd reach for this

Anything that clips to flat white in a generation - a bright light source, sun glare, an overexposed highlight from an Exposure Adjust push that went too far - is a candidate. Instead of accepting a dead, flat white patch, running it through Tonemap first gives you a filmic roll-off where the brightest areas still carry some shape and gradation. It's also useful as a general "make this look less like a raw render and more like it went through a color pipeline" step, since a hard, un-tonemapped highlight is one of the more obvious tells of an untouched digital image versus something that's been through actual color grading.

Inputs and outputs

  • images (IMAGE) - the source.
  • input_mode - linear or sRGB, telling the node what color space your input is already in.
  • output_mode - sRGB or linear, telling it what you want out. The tonemap math itself needs to operate on linear-light values to behave correctly, so these two settings exist to convert in and out around the actual curve, the same way a real color-grading pipeline moves into a working space, does the operation, then converts back.
  • tonemap_scale (0.1–10, default 1) - an overall intensity multiplier on the curve. Higher values push the effect harder.

Output is a single IMAGE.

Installing it

ComfyUI Manager: search "ComfyUI-Image-Filters," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters

pip install -r requirements.txt (or install.bat on Windows), restart. No models - this is a deterministic color curve, not a learned effect.

The recurring pack-wide dependency issue is OpenCV: a conflicting cv2 build installed by another node pack can throw import errors across this entire repo on startup. import_error_install.bat reinstalls the single correct variant (opencv-contrib-python) if that happens.

Common issues

The single most common mistake is getting input_mode/output_mode backwards or leaving them at values that don't match your actual pipeline - since the math genuinely depends on operating in linear light, applying it to an sRGB image while telling the node it's linear (or vice versa) produces a curve applied to the wrong data, which usually shows up as either a washed-out, flat-looking result or an oddly over-contrasted one rather than the smooth highlight roll-off you're after. If the effect looks wrong, check those two settings first before assuming tonemap_scale is the problem. Second, this node pairs with UnTonemap for the reverse operation - if you tonemap for display but then need to do more linear-space math (compositing, frequency separation, further exposure work) on the result, remember to run it back through UnTonemap first rather than operating directly on the tonemapped output.

CategoryImage-Filters/image

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
input_modeCOMBO2 options: linear, sRGB
output_modeCOMBO2 options: sRGB, linear
tonemap_scaleFLOAT1.000.1–10

Outputs (1)

NameTypeDescription
IMAGEIMAGE