π¨ Direct Replace Recolor
Repaint a product in the exact RGB you were handed
- image
- mask
- recolored
The node that does the actual repainting
Every recolor pack has a workhorse, and this is it. Feed it a product photo, a mask of the region you want changed, and a target RGB, and you get back the same image with that region recolored to exactly the color you specified - fabric folds, shading and texture intact. It's the node behind the README's "Precise LAB Recolor" workflow, and it's the first one you should learn because the whole pack is built around it.
The pack comes from an apparel company's colorway pipeline (Wiethe Content GmbH, built for generating product colorways from article specs), so "recolor this tee to RGB 66,17,34 and make it look real" is precisely the job this was written for. If you've ever tried to swap a garment's color with a hue/saturation node and watched the shading die, this is the fix.
Why LAB makes it work
The trick is in the color space. Instead of shifting RGB channels directly, the node converts the image to CIELAB (via scikit-image), where L* is lightness and a* / b* carry the actual color. The color and the lighting are no longer tangled together. So it can set the masked pixels' a*/b* to the exact target color while leaving L* alone - all the brightness variation from the source photo survives, which is what sells the result as a real photograph rather than a bucket fill.
That's also why texture_preserve exists. At 0 the color goes perfectly flat (which looks plastic on fabric). At 0.15 it re-injects a bit of the source's chroma variation so the knit or weave reads; at 0.4 you get heavy texture retention. Default 0.15 is a fine starting point.
The inputs that matter
- image + mask - the photo and the region. Mask comes from a segmentation step (see install below); it's not generated here.
- target_r / target_g / target_b - 0β255. This is your colorway spec.
- luminance_mode -
scale,blend, orkeep.scalemultiplies the source brightness toward the target's lightness (best for big lightβdark jumps like whiteβnavy),blendadds a fixed offset,keepleaves brightness untouched. Defaultscaleis right most of the time. - luminance_strength - 0β1, default 0.7. How far toward the target's brightness you go. The README's 0.5β0.7 recommendation is worth respecting.
- edge_feather - Gaussian blur on the mask edge, default 2px. Bump to 5β10 if your SAM mask has ragged edges.
Output is a single recolored IMAGE - wire it straight into a preview or Save Image.
Install and the segmentation step
cd ComfyUI/custom_nodes
git clone https://github.com/benjamin-bertram/ComfyUI-Recolor
cd ComfyUI-Recolor
pip install -r requirements.txt
Restart ComfyUI. ComfyUI Manager also finds it by searching "ComfyUI-Recolor". The pack itself downloads no models - it's all pixel math on torch + opencv-python + scikit-image, so nothing heavy to fetch.
The mask, though, has to come from somewhere else. The README recommends installing ComfyUI-Impact-Pack for SAM (click on the garment, get a mask), or GroundingDINO + SAM for text-prompted regions, or rembg for simple background removal. For a single garment that's the core ComfyUI habit anyway: detect/mask first, edit second.
Gotchas
The node only processes image[0] - the first frame of the batch. Feed it a batch and the extras are ignored, so run single images or handle batching yourself.
And if the output looks identical to the input, your mask doesn't overlap the image content - the code returns the original image unchanged when the masked region is empty. Check that the mask came from the right frame and that it isn't all zeros.
One more, from reading the source: luminance_mode: scale only engages when the source region's mean lightness is above a threshold, so very dark garments won't get brightness-scaled. If you're going blackβred and the result looks off, switch to blend.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| mask | MASK | β | |
| target_r | INT | 1280β255 | β |
| target_g | INT | 1280β255 | β |
| target_b | INT | 1280β255 | β |
| luminance_mode | COMBO | 3 options: scale, blend, keep | |
| luminance_strength | FLOAT | 0.700β1 | β |
| texture_preserve | FLOAT | 0.150β1 | β |
| edge_feather | INT | 20β50 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| recolored | IMAGE | β |