Nodes/BrainDead Nodes/BD Image To Greyscale
ComfyUI Node

BD Image To Greyscale

Greyscale the way your game engine does — or just one region of the image

By BizaNator·Created 8 months ago·Updated 3 days ago· 15
BD Image To Greyscale
  • image
  • mask
  • image
  • mask
modeluminance
mask_modeapply_within

Converting an image to greyscale sounds like the kind of thing you'd just do with one of a dozen ComfyUI nodes - until you care which grey. BD_ImageToGreyscale is the version that gets the coefficients right and adds a genuinely useful trick: it can desaturate only the pixels inside a mask, leaving the rest of the image in color.

For the pack's game-asset work this matters. Greyscale isn't aesthetic here - it's a data pass: luminance maps for shaders, masks, channel packing, LUT work, the "balance luma" steps in the game-engine packing templates. Getting the luma weights wrong shifts your values subtly but measurably.

The modes

  • luminance (default) - BT.709/sRGB weights: 0.2126·R + 0.7152·G + 0.0722·B. This is the modern standard, and the one the tooltips are right to recommend: it's what Unity and Unreal use, and it's perceptually accurate for modern displays and AI workflows.
  • luminance_bt601 - legacy NTSC weights (0.299/0.587/0.114). Matches older Photoshop "Desaturate" and legacy print tools. Pick this only when you're matching a legacy pipeline byte-for-byte.
  • average - (R+G+B)/3, the naive one. Rarely what you want.
  • max_channel - max(R,G,B), a brightness-ish take.
  • red / green / blue - single-channel pass-through, for when you literally want the red channel as grey.

The mask mode

The optional mask input plus mask_mode is what makes this node stand out:

  • apply_within (default) - only pixels inside the mask go greyscale; everything outside passes through in original color. Desaturate just the skin, leave the outfit alone.
  • cutout - greyscale × mask: inside shows grey, outside goes black. Isolation for cutout-style processing.

Soft mask edges feather naturally between modified and untouched regions, so the boundary isn't a hard line.

Outputs

  • image - 3-channel IMAGE (R=G=B=luma, alpha=1), for SaveImage, GLSL uniform inputs, or any image consumer.
  • mask - the same data as a single-channel MASK tensor, for downstream mask nodes.

Same computation, two shapes - grab whichever your downstream wants.

Install

Part of the BrainDead pack:

cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt

Or search "BrainDead" in ComfyUI Manager and restart. Pure tensor math - no extra dependencies.

Troubleshooting

  • Grey values don't match Photoshop - you're on luminance (BT.709) but comparing to a tool that uses legacy weights. Switch to luminance_bt601 to match.
  • The whole image desaturated when you only wanted a region - the mask wasn't wired; both mask modes only matter when a mask is connected.
  • It's darker than the source - that's correct for luma (it weights green highest). If you wanted the naive mean, use average.
Category🧠BrainDead/Segmentation

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
modeCOMBOluminance7 options: luminance, luminance_bt601, average, max_channel, red, green, +1
mask_modeCOMBOapply_withinHow the optional mask input affects the output (only matters when mask is wired): apply_within (default): Only convert pixels inside the mask to greyscale. Pixels outside the mask pass through UNCHANGED from the source (keeps original color). Use when you want to greyscale only a region (e.g. only the skin). cutout: Multiply greyscale by mask. Pixels inside mask show grey, pixels outside are zeroed out (black). Use for cutout-style processing where you want to isolate a region and discard the rest.
maskoptMASKOptional mask. Behavior controlled by mask_mode above. Soft edges in the mask give a natural feather between modified and untouched regions.

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK