Nodes/ComfyUI-Image-Toolkit/AlphaToGrayscale
ComfyUI Node

AlphaToGrayscale

Alpha channel → grayscale, cleanly

By keit0728·Created 2 years ago·Updated about a year ago· 3
AlphaToGrayscale
  • images
  • IMAGE

Here's a niche one. AlphaToGrayscale takes the transparency of an image and converts it into a grayscale image, so you can see and manipulate your alpha channel as if it were a regular picture. It's the least glamorous node in this pack and also the most "wait, that's actually useful" one once you've fought with masks.

The alpha channel is just a single value per pixel - 1.0 fully opaque, 0.0 fully transparent. But ComfyUI doesn't give you a great way to look at that data directly, and a lot of nodes won't take an alpha channel as input at all. Turning it into a normal RGB image means you can preview it, save it, run it through an image-based processor, or feed it back into your workflow like any other image. The output is pure grayscale: dark where the original was transparent, bright where it was opaque.

How it works

The math is intentionally trivial:

grayscale = 1.0 - alpha

That single line is then copied into all three RGB channels and the alpha channel is dropped, giving you a 3-channel float image. Why the inversion (transparent becomes dark rather than bright)? Because the pack's BrightnessTransparency node does the reverse operation - it maps brightness to transparency with alpha = 1.0 - grayscale, so bright areas go transparent. AlphaToGrayscale is explicitly designed as its inverse, which means you can round-trip: encode brightness as alpha, later decode it back to a gray image, and get your original luminance back.

One honest gotcha from reading the source: if the input image has no alpha channel (plain RGB), this node just passes it through unchanged. It doesn't error, it doesn't warn - it silently does nothing. If you're feeding it a 3-channel image expecting a result, check your upstream - the alpha has to actually exist for this to have a job.

Inputs and output

  • images (IMAGE) - an RGBA image or batch.

Output: a single IMAGE tensor, 3-channel RGB where each pixel's value is 1 - alpha. Dark = transparent, white = opaque.

When you'd reach for it

The honest answer: mostly when you're doing the brightness↔alpha dance with BrightnessTransparency, or when you need to debug why a transparency-based workflow is misbehaving. A common real-world use is taking a soft alpha mask (say, from a background-removal or matting step) and dumping it out as a viewable image so you can see exactly how the edges fall off. It's also a clean way to convert an alpha matte into a mask-like image for nodes that expect grayscale rather than a dedicated mask type. It won't change the world, but it's the right tool for a specific job that keeps coming up.

Installing

Part of the keit0728/ComfyUI-Image-Toolkit pack:

cd ComfyUI/custom_nodes
git clone https://github.com/keit0728/ComfyUI-Image-Toolkit

Restart after cloning, or install "ComfyUI-Image-Toolkit" through ComfyUI Manager. Only dependency is opencv-python==4.11.0.86 (pinned), no model files, no GPU - it's plain numpy math on CPU and it handles batches.

Gotchas

Beyond the silent pass-through on RGB inputs, the main thing to know is that this pack is a tiny personal project - anonymous author, Japanese code comments, last touched in mid-2025, and the README's clone command uses a placeholder your-username URL (the real repo is keit0728/ComfyUI-Image-Toolkit). For a node this small, "read the source if you want certainty" is the support model. The source is short enough that you can.

CategoryComfyUI-Image-Toolkit

Inputs (1)

NameTypeDefaultDescription
imagesIMAGEInput images to convert alpha to grayscale.

Outputs (1)

NameTypeDescription
IMAGEIMAGE