Nodes/opencv-comfyui/OpenCV colorChange_0
ComfyUI Node

OpenCV colorChange_0

Recolor a masked region without repainting it — OpenCV's colorChange effect

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV colorChange_0
  • src
  • mask
  • dst
  • nparray
red_mul
green_mul
blue_mul

colorChange is OpenCV's "recolor this, but keep the texture" effect. You give it an image, a mask marking the region you want to change, and three channel multipliers, and it returns the image with that region's colors shifted - while keeping the underlying detail and shading intact. It's from OpenCV's Photo module's non-photorealistic rendering family, the same group as edge-preserving filters and stylization. If you've ever wanted to recolor a shirt, a car, or a background element in a composited image without painting over its folds and highlights, this is the primitive.

The difference from a simple "fill the mask with a color" is the whole point: colorChange does a seamless recolor that preserves the local luminance structure. The masked region keeps its shading and texture, it just takes on a new color cast. That makes it useful for quick color swaps on objects in a generated image - a classic post-processing move, the kind of deterministic pixel op the KB's post-processing doc calls out as "Photoshop had it for thirty years, wrapped as a node."

Inputs. src (NPARRAY, the base image), mask (NPARRAY, same size - white pixels mark the region to recolor), then three FLOAT multipliers: red_mul, green_mul, blue_mul. These scale how strongly the source's original color contributes per channel; lower them and the region takes on a more uniform, recolored look, higher and it stays closer to the original. Play with them rather than assuming a recipe - the effect is interactive by nature. The optional dst input is an OpenCV out-parameter the generator exposed; ignore it. Output is a single nparray - the recolored image.

Realistic expectations. This is a stylization effect, not a precision tool - expect it to behave like a filter you audition on a value before committing, not like a careful relight. And remember the pack's representation rules: everything on this side of the graph is BGR 0..255 uint8 nparrays at batch_size == 1, so bridge with Image2Nparray / Nparrays2Image and pull single frames with ImageFromBatch. Your mask also needs to be an OpenCV-side nparray - make it from a Comfy mask with the pack's conversions or a threshold.

Install. ComfyUI Manager → search "OpenCV", or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib

Restart after; no model files. And colorChange_1 is the identical twin of this node - the pack's overload-duplication pattern again, so pick either. Expect dragons, as the author warns - though a recolor filter is one of the more pleasant ones to meet.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
srcNPARRAY
maskNPARRAY
red_mulFLOAT
green_mulFLOAT
blue_mulFLOAT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY