π¨ Percentile Map Recolor
Recolor that survives glare, highlights and hotspots
- image
- mask
- recolored
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.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| mask | MASK | β | |
| target_r | INT | 1280β255 | β |
| target_g | INT | 1280β255 | β |
| target_b | INT | 1280β255 | β |
| luminance_strength | FLOAT | 0.700β1 | β |
| target_range_pct | FLOAT | 0.250β1 | β |
| edge_feather | INT | 20β50 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| recolored | IMAGE | β |