Nodes/comfyui_cv/CV Find Absent Color (Lab)
ComfyUI Node

CV Find Absent Color (Lab)

Finds a CSS named color that does not appear in the image and sits furthest (in L*a*b*) from the colors that do. Converts the image to L*a*b*, measures each of the 148 CSS named colors' distance to its nearest pixel (Euclidean L2 or Manhattan L1), treats colors within 'threshold' as present, and returns the absent color with the greatest distance - its RGB scalar, CSS name and #RRGGBB hex. If every color is present, 'found' is false and the returned color is still the one furthest from the image's existing colors.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Find Absent Color (Lab)
  • image
  • color_rgb
  • color_name
  • color_hex
  • distance
  • found
metricEuclidean (L2)
threshold10.0
max_pixels200000
Categoryimage/CV

Inputs (4)

NameTypeDefaultDescription
imageIMAGEInput image. A batch is accepted: a color counts as present when it occurs in ANY frame.
metricCOMBOEuclidean (L2)Distance in L*a*b* space: Euclidean (L2) is the classic delta-E; Manhattan (L1) sums the channel differences and is cheaper to reason about per channel.
thresholdFLOAT10.00–255A CSS color counts as present when any pixel is within this Lab distance (OpenCV L*a*b* uint8 space: L 0-255, a/b 0-255). 0 = only an exact match counts; larger = more colors considered present.
max_pixelsoptINT2000001000–100000000Per-frame cap on pixels searched, applied as an even deterministic stride so big images stay fast. A color present in only a few pixels below this stride may be missed - raise it for large canvases.

Outputs (5)

NameTypeDescription
color_rgbNPARRAYCV Scalar (r, g, b) float64 of the chosen CSS color (the image arrives in RGB, so the color is returned in the same order).
color_nameSTRINGCSS name of the chosen color, lowercase (e.g. 'rebeccapurple').
color_hexCOLORHex as #RRGGBB uppercase, typed as a COLOR socket - links straight into ComfyUI color-picker inputs (e.g. 'CV Color From Hex').
distanceFLOATLab distance of the chosen color to its nearest image pixel (its distance to the existing colors).
foundBOOLEANTrue when an absent color exists (distance above the threshold). False when every CSS color is present - the color is then still the furthest of the 148 from the existing colors.