Nodes/TrentNodes/White To Whatever
ComfyUI Node

White To Whatever

White Pixels Are a Problem. This Turns Them Into Any Color You Want.

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
White To Whatever
  • images
  • image
  • white_mask
color#ff3366
threshold0.90
softness0.05
preserve_luminancefalse

White is a surprisingly common problem in generated art. White text you need to recolor for a logo, white matte edges left over from a compositing pass, a white studio background that needs to become something else, a white shirt that keeps reading as "part of the background." White To Whatever is the node with the entire job in the name: find the white pixels, replace them with any color you pick, done. It even ships a native color-picker popup so you're not typing hex codes from memory.

It's the kind of tiny utility you don't think you need until you need it three times in one afternoon. It processes a whole batch, so it's also fine on video frames.

How it works

The detection is based on the min channel: a pixel counts as white when its R, G, and B are all high - pure white is 1.0 across the board, and a colored pixel always has at least one channel notably lower. Pixels at or above your threshold get replaced; below it, a softness ramp blends smoothly to the untouched color so you don't get a hard aliased edge. And if a flat color fill looks wrong, preserve_luminance scales the replacement color by each pixel's original brightness, which keeps shading and gradients instead of stamping a flat swatch.

The inputs that matter

  • images - the input, single image or batch.
  • color - a hex string (default #ff3366, a very confident pink). Click the swatch for the native picker.
  • threshold - how white is "white." 1.0 means pure white only; 0.9 catches near-white (good for slightly-dirty white backgrounds); 0.5 will grab anything light, which is usually more than you wanted.
  • softness - transition width below the threshold. 0 = hard cut, and hard cuts are where you see edge artifacts.
  • preserve_luminance - off by default (flat fill); flip it on when the white pixels carry shading you care about.

Outputs

  • image - the recolored result.
  • white_mask - 1.0 where pixels were treated as white and replaced, 0 elsewhere. This is genuinely useful: wire it downstream as a selection or matte.

Troubleshooting

The classic mistake is cranking threshold to 1.0 and getting nothing, because your "white" background is actually 0.96 or 0.98 from JPEG compression - drop to 0.9 and it works. The opposite trap is threshold 0.5 eating everything light, including highlights on objects you wanted left alone; the white_mask output lets you see exactly what got caught before you commit. And note it recolors, not removes - this is not a background-removal node, so don't reach for it expecting BiRefNet behavior. It's a deterministic pixel op, which is exactly why it's fast and deterministic.

Installing

Part of TrentNodes under Trent/Image. ComfyUI Manager → "Trent Nodes" → Install, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes
cd TrentNodes
pip install -r requirements.txt

Restart after. If Manager flags the pack (a day-one repo rename left a registry duplicate it still distrusts), the manual clone is the reliable path.

CategoryTrent/Image

Inputs (5)

NameTypeDefaultDescription
imagesIMAGEInput image or batch; white pixels will be recolored
colorSTRING#ff3366Replacement color as a hex string. Use the color swatch to open a native picker
thresholdFLOAT0.900–1How white a pixel must be to count. 1.0 = pure white only, 0.9 = near-white, 0.5 = any light pixel
softnessFLOAT0.050–1Soft transition width below the threshold for smooth edges; 0 = hard cut
preserve_luminanceBOOLEANfalseScale the replacement color by each pixel's original brightness so shading is preserved instead of a flat color fill

Outputs (2)

NameTypeDescription
imageIMAGEImage with white pixels recolored
white_maskMASKMask showing which pixels were treated as white (1.0 = fully replaced)