Nodes/Link Comfy Nodes/Find Furthest Color
ComfyUI Node

Find Furthest Color

Auto-pick a color that will never blend into your image

By Mister-Link·Created 9 months ago·Updated 23 days ago· 0
Find Furthest Color
  • images
  • 24-bit
  • hex
  • rgb
sample_rate10
max_brightness140
min_saturation0.20
max_saturation0.60

Picking a padding color, an outline color, or a chroma-key-style background by eye is fine for one image; across a whole batch of varied generations, a hardcoded color you liked for one frame can quietly blend into the next. Find Furthest Color removes the guesswork: it analyzes an image and hands you back a color that's maximally distant from what's actually in it - in three formats, ready to plug straight into whatever needs a color value.

How it works

It samples pixels across your image batch and searches for a color that stands as far as possible from the colors actually present, while staying within sane, visible bounds - it's constrained away from pure extremes (near-black, near-white, near-gray) so what it hands back is a genuinely usable, distinguishable color rather than a degenerate edge case.

The inputs and outputs that matter

  • images (IMAGE, required) - the image(s) to analyze.
  • sample_rate (INT, optional, default 10, 1–100) - rather than scanning every pixel, it samples every Nth one for speed. Lower it for more thorough (slower) analysis on a batch where precision matters; the default is a reasonable speed/accuracy tradeoff.
  • max_brightness (INT, optional, default 140, 50–200) - caps how bright the chosen color can be, keeping it away from washed-out near-white results.
  • min_saturation / max_saturation (FLOAT, optional, defaults 0.2 / 0.6) - bounds the color to a visibly saturated range rather than a dull gray or an oversaturated neon.

Three outputs, all describing the same color: 24-bit (INT), hex (STRING), and rgb (STRING). The hex output is worth noting specifically - it's the exact format that Crop by BBox's and Auto Cropper's padding_color fields expect, so this pairs directly with either of them if you want padding that's guaranteed not to blend into your subject.

How to install it

Through ComfyUI Manager: search "Link Comfy Nodes," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
pip install -r link-comfy-nodes/requirements.txt

Restart ComfyUI afterward.

Common issues & troubleshooting

Result looks like an odd, slightly muddy color rather than something bold. That's the max_brightness/saturation bounds doing their job - the node deliberately avoids extremes, so don't expect pure neon or pure white/black back. If you specifically want a bolder result, widen min_saturation/max_saturation and raise max_brightness toward its ceiling.

Result changes noticeably run to run on the same image. Check sample_rate - a coarser sample (a higher number) means it's only looking at a subset of pixels, and on an image with subtle variation that can shift which color reads as "farthest" between runs if anything else about the input changes even slightly. Lower it if you need a more stable, deterministic result.

Picking a color for a batch, not a single image. If your batch has varied content frame to frame, a single "farthest color" computed once may not stay maximally distinct for every frame - it's a batch-level analysis, not a per-frame one. For content that varies a lot, treat the result as a good general-purpose choice rather than a guarantee for every single frame.

Categoryutils

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
sample_rateoptINT101–100
max_brightnessoptINT14050–200
min_saturationoptFLOAT0.200–0.5
max_saturationoptFLOAT0.600.3–0.9

Outputs (3)

NameTypeDescription
24-bitINT
hexSTRING
rgbSTRING