ComfyUI Node

Remap Range

Levels-style blackpoint/whitepoint contrast stretch

By spacepxl·Created 3 years ago·Updated 8 months ago· 293
Remap Range
  • image
  • IMAGE
blackpoint0.00
whitepoint1.00

If you've used Levels in Photoshop or GIMP, you already know this node - set a new black point and white point and everything in between gets stretched to fill the full range. It's a small, unglamorous node that shows up as a building block behind a lot of other operations: fixing a low-contrast depth map before you feed it somewhere that needs full range, cleaning up a washed-out mask, or just correcting an image that's clearly not using its full dynamic range.

How it works

Every pixel value gets remapped so that your chosen blackpoint becomes 0 and your chosen whitepoint becomes 1, with everything in between scaled linearly, and the result clamped so nothing goes outside 0-1. Set blackpoint to 0.2 and everything at or below 0.2 crushes to pure black; set whitepoint to 0.8 and everything at or above 0.8 blows to pure white. Everything in the 0.2-0.8 band stretches to fill the full 0-1 range. It's a contrast stretch, not a curve - linear in, linear out.

Inputs and outputs that matter

  • blackpoint (0-1, default 0) - anything below this becomes 0.
  • whitepoint (0.01-1, default 1) - anything above this becomes 1.

That's genuinely the whole node - two sliders and an image in. Output: a single IMAGE.

Installing it

Through ComfyUI Manager, search ComfyUI Image Filters, or clone directly:

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

Restart afterward. No models to download - it's arithmetic on pixel values, about as lightweight as a node gets. The pack's opencv dependency is the thing that occasionally bites on install: if you get import errors after adding this pack alongside others that also bundle opencv, run the repo's import_error_install.bat, or manually strip the conflicting opencv-* packages and install only opencv-contrib-python.

Where people get burned

The main mistake is treating this like a gamma/curves adjustment when it's strictly linear. If your image has detail concentrated in the shadows or highlights specifically, a straight blackpoint/whitepoint stretch won't bring that detail out the way a curve or gamma adjustment would - it just changes where the clip points land. If you need non-linear tone shaping, this isn't the tool; Exposure Adjust's tonemap options, also in this pack, are closer to what you want.

Second: setting blackpoint higher than whitepoint, or values that leave almost no range between them, crushes your image to near-solid black or white with essentially nothing in between. That's not a bug, it's exactly what a contrast stretch does when there's almost no range to stretch - if your output looks blown out or crushed, check that the two values actually leave reasonable room between them before assuming the node's broken.

CategoryImage-Filters/image

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
blackpointFLOAT0.000–1
whitepointFLOAT1.000.01–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE