LAB Color Detection
Is that frame actually in color? LAB Color Detection answers in one node
- image
- is_color
- color_difference
You've got a folder of images, or a pile of frames out of a video workflow, and you need to know which ones are actually in color and which are black and white - not to guess, but to make a decision in the graph. That's the whole job of LAB Color Detection, one of two nodes in DrMWeigand's tiny Color Image Detection pack. Feed it an image, it hands you a BOOL: True it's colored, False it's grayscale. That's it. No models to download, no API, no weights - just a few lines of OpenCV math.
It earns its "LAB" in the name. The image gets converted into the LAB color space, which splits every pixel into a lightness channel (L) and two color-opponent channels (A and B). Pure gray lives almost exactly on the A = B line; the moment real color shows up, A and B drift apart. The node measures that drift - the mean of |A − B| across all pixels - and compares it to a threshold. color_difference over the threshold means is_color = True. It's cheap, it's fast, and it's a genuinely clever proxy for what your eyes would tell you.
The inputs that matter
Only two, and one is obvious:
- image (IMAGE) - whatever you want classified.
- threshold (FLOAT, default 2.5) - how far A and B have to drift before the node cries "color." The author tuned the default empirically; if you're getting
Trueon stuff that's clearly gray, nudge it up, and vice versa.
That's the whole menu. Both outputs are worth keeping:
- is_color (BOOL) - the verdict.
- color_difference (FLOAT) - the raw measurement, which is your debugging window into why a threshold did what it did.
Where the BOOL goes
A BOOL with no destination is just a truth you stare at. Wire is_color into a switch node (core's Switch (Any) or rgthree's Power Switch both work) and you can route a whole branch: color images get a color-grading or upscaling pass, grayscale ones skip it. Pair it with a Show Text node if you just want the verdict printed on your output. That's the pattern people actually use this for - someone even built their workflow around surfacing that verdict in ViewComfy.
Installing it
Standard two ways:
cd ComfyUI/custom_nodes
git clone https://github.com/DrMWeigand/ComfyUI_ColorImageDetection
Then restart ComfyUI. Or, easier: ComfyUI Manager → Install Custom Nodes → search "Color Image Detection" and click Install. Dependencies are just numpy, torch, and opencv-python - if you've installed almost any other CV-adjacent pack you already have all three. Nothing heavy, nothing to download.
The gotchas
First, the README is honest about the trade-off: this node is the fast option, and speed costs it reliability on color-tinted black-and-white photos. A sepia scan or a heavily warm-toned B&W can drift A and B enough to read as color. If your images are tinted, the pack's other node, RGB Color Detection, is the more trustworthy pick - at the cost of being slower.
Second, a code-level quirk: if you feed a batch of images, only the last frame's verdict actually comes out - the loop overwrites is_color and color_difference on every pass. Feed it one image at a time, or be aware that "last image wins." Also worth knowing: the conversion runs through OpenCV's BGR → LAB path even though ComfyUI hands you RGB (a classic cv2 leftover). That scrambles which channel ends up in A versus B, so don't read too much into the exact color_difference number - the color-vs-gray verdict survives, the absolute value is a bit arbitrary.
It's not the node that changes your life. It's the node that makes a genuinely annoying classification problem a three-wire addition to your graph.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| threshold | FLOAT | 2.50 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| is_color | BOOL | — |
| color_difference | FLOAT | — |