Clamp Image
Crush the range instead of stretching it — know the difference
- image
- IMAGE
VAE decodes can overshoot - a value that should sit right at pure black or pure white slips slightly past 0 or 1, which shows up as faint noise or banding once it hits an 8-bit export. Clamp Image is the blunt, deliberate fix: anything outside the range you set for blackpoint/whitepoint gets hard-cut to that boundary. No rescaling, no stretching - just a ceiling and a floor.
That's worth being precise about, because it's easy to confuse this with a contrast tool. It isn't one. A remap/normalize operation stretches your existing range to fill 0–1, which changes contrast. This node clamps - it leaves values inside the range untouched and just cuts off anything outside it.
The inputs
image(IMAGE) - required.blackpoint(default 0, 0–1) - anything below this value gets forced toblackpoint.whitepoint(default 1, 0–1) - anything above this value gets forced towhitepoint.
At the defaults (0 and 1) this node does nothing - it's already the valid image range. You're reaching for it specifically to tighten that range.
One output: IMAGE.
Where it's actually useful
Cleaning up VAE decode overshoot before export is the main one - a small nudge like blackpoint: 0.001, whitepoint: 0.999 catches stray out-of-range values without visibly changing the image. Push it further and you get a deliberate black-crush or white-crush effect: raise blackpoint toward, say, 0.1 and every shadow below that value goes to flat black, which reads as a stylized high-contrast look rather than a subtle fix. It's also a reasonable guardrail step right before you export to 8-bit, if you want explicit control over what clips rather than trusting the export path to handle it silently.
How to install it
ComfyUI Manager: search "ComfyUI-Image-Filters", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters
then restart. Dependency is opencv-contrib-python; if cv2 throws an import error, it's almost always another node pack's conflicting opencv variant rather than this pack being broken - fixed on Windows with the author's install.bat/import_error_install.bat, or manually elsewhere by uninstalling stray opencv variants and reinstalling opencv-contrib-python alone. No models, negligible cost.
Common issues & troubleshooting
Set blackpoint/whitepoint aggressively expecting more contrast, got flat blocks instead. That's the clamp-vs-remap confusion - this node crushes to a flat value, it doesn't stretch the remaining range to compensate. If you want the shadows to get darker and more detailed, not flat black, you want a remap/normalize tool instead of this one.
Subtle banding or noise still visible after a light clamp. Your source values might be overshooting by more than the small margin you clamped - check how far out of range the actual pixel values go before assuming a tiny blackpoint/whitepoint nudge will catch it; widen the clamp margin if needed.
Using this as a general "fix bad colors" step. It only does one specific thing - cut off values outside a range. If your actual problem is a color cast or shifted tone rather than out-of-range values, this node won't touch it; that's Color Match Image's job instead.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| blackpoint | FLOAT | 0.0000–1 | — |
| whitepoint | FLOAT | 1.0000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |