Nodes/ComfyUI-Recolor/🎨 Percentile Map Recolor
ComfyUI Node

🎨 Percentile Map Recolor

Recolor that survives glare, highlights and hotspots

By benjamin-bertramΒ·Created 6 months agoΒ·Updated 6 months agoΒ· 1
🎨 Percentile Map Recolor
  • image
  • mask
  • recolored
β—„target_r128β–Ί
β—„target_g128β–Ί
β—„target_b128β–Ί
β—„luminance_strength0.70β–Ί
β—„target_range_pct0.25β–Ί
β—„edge_feather2β–Ί

The one for photos with a few bad pixels

The statistical transfer node has one real weakness: the standard deviation it computes gets dragged around by outliers. A blown-out specular highlight, a hotspot on a glossy sleeve, a stray reflection - a handful of pixels can stretch the whole mapping and wash out your recolored garment. This node is the same family of technique with a sturdier backbone: it maps color using the 5th-to-95th percentile range of the masked region instead of the mean-and-std pair. Percentiles ignore the extremes, so glare stops being able to hijack the result.

In plain terms: if your source product photo has visible highlights or uneven lighting, this is often the recolor that comes out cleanest. Statistical Transfer is the purist's choice; this is the practical one.

How the mapping works

In CIELAB (L* for lightness, a*/b* for color), the node finds the 5th and 95th percentiles of each channel inside the mask, then remaps those channels so the source's middle range lands on your target color, with the spread controlled by one knob.

  • target_r / target_g / target_b - the colorway RGB, 0–255.
  • target_range_pct - 0 to 1, default 0.25. At 0 the color flattens to the target; at 1.0 you keep the full source variation. It's the "how much of the source's tonal range do I trust" dial - 0.25 means the mapping only uses a quarter of the observed range, which is the safe zone for noisy photos.
  • luminance_strength - 0–1, default 0.7. How far the lightness channel chases the target.
  • edge_feather - mask-edge blur in pixels, default 2.

Inputs are image, mask, and those four settings; output is recolored, a single IMAGE. Same shape as the other single-zone nodes in the pack, so it slots into the identical graph: mask β†’ node β†’ preview.

When to pick which

Rough rule of thumb across the pack's three single-zone nodes: Direct Replace for pixel-exact spec colors on flat shots, Statistical Transfer for real lighting on clean photos, Percentile Map when the photo is noisy, glossy, or has highlights you can't reshoot. They share target RGB inputs, so it's trivial to try all three on the same mask and keep the one that survives your worst image.

Install and gotchas

Same story as the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/benjamin-bertram/ComfyUI-Recolor
cd ComfyUI-Recolor
pip install -r requirements.txt

Restart ComfyUI, or grab it from Manager by searching "ComfyUI-Recolor". No model files, no downloads - the dependencies are torch, opencv-python, and scikit-image, all pure pixel math.

Two things to know before you wire it up. First, the mask is not optional and not generated here - bring it from SAM (ComfyUI-Impact-Pack is the README's recommendation), GroundingDINO, or rembg. Second, like the other single-zone nodes it processes only image[0], and if the mask is empty it silently returns the source image - an output that looks unchanged usually means your mask doesn't overlap the frame, not that the node is broken.

CategoryAICG/Recolor

Inputs (8)

NameTypeDefaultDescription
imageIMAGEβ€”
maskMASKβ€”
target_rINT1280–255β€”
target_gINT1280–255β€”
target_bINT1280–255β€”
luminance_strengthFLOAT0.700–1β€”
target_range_pctFLOAT0.250–1β€”
edge_featherINT20–50β€”

Outputs (1)

NameTypeDescription
recoloredIMAGEβ€”