Nodes/comfyui_bmad_nodes/FindComplementaryColor
ComfyUI Node Runs on cloud

FindComplementaryColor

Ask the Image What Color It's Missing

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
FindComplementaryColor
  • image
  • color_dict
  • mask
  • COLOR
  • STRING
power0.50

FindComplementaryColor looks at an image and tells you which color from a given palette is least present in it - the complement. It doesn't compute an artist's color wheel opposite; it computes the color that's farthest from what the image already contains, and that's usually more useful for composition.

Why you'd reach for it

This is a color-analysis node for collage and composition work. If you've composited a subject onto a background and the result feels flat, the fix is often a color the image is missing - an accent that pops because nothing else in the frame competes with it. FindComplementaryColor answers "what should that accent be?" by measuring, pixel by pixel, how far every color in your palette sits from the colors actually in the image, and returning the palette color with the worst (i.e. least similar) match.

It pairs with the pack's color ecosystem: feed it a palette from ColorDefaultDictionary (a built-in list of up to 12 named colors) or ColorCustomDictionary (your own names + RGB values), and it hands you both the matching COLOR and its name as a STRING. That name is handy - you can feed it straight into a text-based color picker or a prompt.

How it works

The metric is average ISD - inverse squared distance. For each palette color, every pixel (optionally restricted by a mask) contributes 1/(1 + d²) where d is the pixel's distance to that color: close pixels weigh heavily, distant ones barely at all. The palette color with the lowest average score wins, because it's the one the image already resembles least. The power input overrides the squaring (default 0.5) to tune how aggressively closeness is penalized.

If you supply a mask, the analysis ignores pixels outside it - essential when you only care about a region. And it will quietly resize the image to match the mask if their dimensions differ (it prints a note when it does).

The inputs that matter

  • image - what you're analyzing.
  • color_dict - the candidate palette, from the pack's dictionary nodes.
  • power - ISD exponent; lower favors mid-distant colors, higher hammers close matches.
  • mask (optional) - restrict the analysis to a region.

Outputs: a COLOR (the RGB value) and a STRING (the palette name).

Install

Ships in bmad4ever's pack; it's OpenCV-backed so the requirements matter:

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

then restart ComfyUI. Manager users search "comfyui_bmad_nodes" and install dependencies automatically.

Common issues

  • "The color it picked is obvious/wrong." It's answering "least similar," not "nice looking." If the palette has no useful candidate, use ColorCustomDictionary to define better ones.
  • Forgetting the mask. Without it, a large background swath can dominate the average. Mask the region you care about.
  • Color dictionary not connected. The color_dict input is required - you can't type a palette in.

For color-aware compositing it's a genuinely thoughtful little node - the rare one that tells you something you couldn't eyeball reliably.

CategoryBmad/CV/Color A.

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
color_dictCOLOR_DICT
powerFLOAT0.500.01–10
maskoptIMAGE

Outputs (2)

NameTypeDescription
COLORCOLOR
STRINGSTRING