Nodes/ComfyUI_CGAnimittaTools/CGA_ColorToGrayscale
ComfyUI Node

CGA_ColorToGrayscale

A grayscale that uses luminance weights, not a lazy channel average

By cganimitta·Created about a year ago·Updated about a year ago· 47
CGA_ColorToGrayscale
  • image
  • IMAGE

A lot of "desaturate" nodes in the wild just average the red, green, and blue channels, which is wrong in a way you can actually see: a saturated red and a saturated blue that look equally bright end up as wildly different grays. CGA_ColorToGrayscale does it properly. It converts to grayscale using the standard luminance weights - 0.299 red, 0.587 green, 0.114 blue - the Rec.601 formula that matches how human vision actually weighs color. Same brightness in, same gray out.

That matters more than it sounds. If you're feeding a B&W version of an image into a depth estimator, a line preprocessor, or using it as a consistent base for style transfer, a perceptually-correct gray keeps tonal relationships intact. An average-of-channels conversion silently reshuffles which parts of the image read as dark and light.

What it does

One input, one output:

  • image (IMAGE) - anything ComfyUI hands you.
  • Returns IMAGE - a grayscale version, but expanded back to 3 channels (R=G=B) so it plugs into any node that expects a normal RGB image. If the input had an alpha channel, the alpha is preserved untouched, which is a nice touch for compositing work.

There are no settings. It's a single-purpose converter and it doesn't pretend otherwise.

The honest caveats

The name says "ColorToGrayscale" but the code comment calls it the brightness method - and it's worth knowing which flavor you're getting. This is a straight luminance map, not the filmic "desaturate while preserving hue" look that some image editors default to. A dark navy blue becomes a dark gray, not a mid-tone with a blue tint. If you wanted the tinted version, this isn't that node.

Also note it's a pure pixel transform - same dimensions in and out, no resizing, no batch gymnastics beyond what it's given. Feed it a batch and it converts the whole batch.

When you'd actually use it

Honestly, it's a small convenience. ComfyUI has multiple ways to get a grayscale image, and you could write the same math in a tiny custom node. What this buys you is not having to think about it - it's a known-good luminance conversion in one drag. If you keep building B&W-styled img2img passes or want a grayscale reference branch in your graph, it earns its slot.

Install

Same as every node in this pack, and the pack is gloriously light - requirements.txt is torch, numpy, pathlib, all already present, no models to download. In ComfyUI Manager, search ComfyUI_CGAnimittaTools, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/cganimitta/ComfyUI_CGAnimittaTools

Restart and find it under the CGAnimittaTools menu group.

CategoryCGAnimittaTools

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE