ComfyUI Node

UnTonemap

Undo the highlight roll-off and get your linear values back

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

The exact inverse of this pack's Tonemap node. Where Tonemap compresses bright highlights with a log-plus-contrast S-curve so they roll off smoothly instead of clipping to flat white, UnTonemap reverses that curve mathematically and hands you back (approximately) the original linear values. The pack's README gives the actual reverse formula alongside the forward one, so this isn't a guess-and-check approximation - it's the deliberate algebraic inverse of the same S-Log3-style curve.

Why you'd need to undo a tonemap

Tonemapping is a display/grading operation - it's meant to make an image look right when you look at it, not to preserve the underlying math for further processing. If you tonemapped something to check how it'll look, or received an image that's already been through a tonemap curve somewhere upstream, and you now need to do more linear-space work on it - compositing, frequency separation, exposure adjustments, anything that assumes linear light - running it straight through those operations on top of the tonemapped values will give you subtly wrong results, because the curve has already reshaped the highlight response. UnTonemap gets you back to (approximately) the pre-curve values first, so downstream linear-space math behaves the way it's supposed to.

Inputs and outputs

  • images (IMAGE) - the tonemapped source.
  • input_mode - sRGB or linear, describing the color space of what you're feeding in.
  • output_mode - linear or sRGB, describing what you want back. Note the default ordering here is the mirror image of Tonemap's - makes sense, since you're running the pipeline in reverse.
  • tonemap_scale (0.1–10, default 1) - has to match whatever value was used on the Tonemap node that produced the image, or the reversal won't be accurate.

Output is a single IMAGE.

Installing it

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

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

pip install -r requirements.txt (or install.bat on Windows), restart ComfyUI. No models involved, same as its counterpart.

Same OpenCV note as everywhere in this pack: a conflicting cv2 build from another node pack can break this entire repo's import on startup. import_error_install.bat is the fix - it wipes every opencv variant and reinstalls the one this pack actually needs.

Common issues

The math only reverses cleanly if tonemap_scale here matches what was used going in - mismatch that value and you get an incomplete or over-corrected reversal rather than a clean return to the original linear values. Same goes for input_mode/output_mode: since the curve operates specifically on linear-light data, getting the color-space settings backwards on either Tonemap or UnTonemap compounds across the pair and leaves you further from the original than if you'd done nothing. If you're chaining Tonemap into some other operation and then UnTonemap to get back, it's worth sanity-checking on a test image that round-tripping through both nodes with matching settings actually returns something visually close to the original - if it doesn't, mismatched settings between the two nodes is the first thing to check.

CategoryImage-Filters/image

Inputs (4)

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

Outputs (1)

NameTypeDescription
IMAGEIMAGE