Nodes/RyanOnTheInside/Advanced Luminance Mask βš‘πŸ…‘πŸ…žπŸ…£πŸ…˜
ComfyUI Node

Advanced Luminance Mask βš‘πŸ…‘πŸ…žπŸ…£πŸ…˜

Cut out a subject by brightness, no segmentation model needed

By ryanontheinsideΒ·Created 2 years agoΒ·Updated 5 months agoΒ· 852
Advanced Luminance Mask βš‘πŸ…‘πŸ…žπŸ…£πŸ…˜
  • image
  • MASK
  • IMAGE
β—„luminance_threshold0.05β–Ί
β—„glow_radius5β–Ί
β—„edge_preservation0.50β–Ί
β—„background_samples10β–Ί
β—„denoise_strength0.30β–Ί

Sometimes you don't need a full segmentation model to get a usable mask - you just need "everything that isn't the background." If your subject and background sit at noticeably different brightness levels, this node gets you there without loading anything heavier than the image itself.

One of ryanontheinside's standalone mask utilities, sitting outside the FlexFeatures and ACE-Step sides of the pack.

How it works

It samples several corners of the image (background_samples, default 10) to work out what the background actually looks like, then thresholds every pixel against that using luminance_threshold - lower values catch subtler detail, higher ones only flag strongly different pixels. A glow_radius softens the resulting edges outward for a gentler mask boundary, edge_preservation trades that softness off against keeping sharp detail where it exists, and denoise_strength smooths out noisy speckling in the final result. All of this comes straight from the node's own tooltips, which are unusually thorough for a ComfyUI node.

The inputs and outputs that matter

  • image - the only required non-numeric input, your source IMAGE.
  • luminance_threshold - default 0.05. The main dial: drop it if you're missing subtle detail near the edges of your subject, raise it if the mask is grabbing background it shouldn't.
  • glow_radius - default 5 pixels. Higher gives a larger, softer glow around detected edges.
  • background_samples - default 10. More samples generally means a more accurate read on what "background" actually is, useful if your backdrop isn't perfectly flat.

Outputs are MASK (the mask itself) and IMAGE - a visual you can drop straight into a preview node to eyeball the result without adding a separate preview step.

How to install it

Via ComfyUI Manager, search RyanOnTheInside. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside

then restart. No models to fetch - it's plain image math.

Common issues & troubleshooting

Mask grabs way more than the subject. Usually means the background isn't uniform enough for corner sampling to characterize it well. Try raising background_samples first, or lower luminance_threshold if the issue is actually subtle-detail loss rather than background contamination.

Edges look blobby or over-glowed. Bring glow_radius down toward 0, or raise edge_preservation to keep more of the original edge sharpness.

This isn't a replacement for real segmentation. It has zero semantic understanding - it only knows about brightness. On a busy scene with a similarly-lit subject and background, or anything where "the subject" isn't also "the bright part," reach for an actual segmentation node (rembg, SAM) instead. This one shines on simple setups: a lit subject on a dark backdrop, a glowing element, that kind of contrast.

CategoryRyanOnTheInside/Masks

Inputs (6)

NameTypeDefaultDescription
imageIMAGEInput image to create mask from (IMAGE type)
luminance_thresholdFLOAT0.050–1Base threshold for detecting non-background elements (0.0 to 1.0). Lower values catch more subtle details.
glow_radiusINT50–50Size of the glow effect in pixels (0 to 50). Higher values create larger, softer glows.
edge_preservationFLOAT0.500–1How much to preserve sharp edges while allowing glow (0.0 to 1.0). Higher values maintain more edge detail.
background_samplesINT101–100Number of corner samples to determine background color (1 to 100). More samples give better background detection.
denoise_strengthFLOAT0.300–1Strength of noise reduction (0.0 to 1.0). Higher values smooth out noise while preserving edges.

Outputs (2)

NameTypeDescription
MASKMASKβ€”
IMAGEIMAGEβ€”