RC Mask Apply
Turn any mask into real transparency
- image
- mask
- IMAGE
A mask and an alpha channel are the same thing wearing different clothes: both describe "how much of this pixel is real." But ComfyUI nodes don't always agree on which one they want, and if you've got a perfect cutout mask - from BiRefNet, from the mask editor, from a segmentation model - and a node that wants RGBA, you need a bridge. RC_MaskApply is that bridge: it takes an image and a MASK and bakes the mask into the image as alpha (or multiplies it into the colors), with threshold and feathering for edges.
It lives in the RC Image Compositor pack under RC/Channel, right next to the channel extractor that produces masks in the first place. Together they form the pack's matting story: extract a mask, apply it, composite.
How it works
It merges the mask with the image per frame (it cycles both tensors, so a batch of images and a batch of masks work together even at different lengths):
- mask_mode -
alphawrites the mask into a new alpha channel and outputs RGBA.multiplyscales the RGB by the mask instead, which darkens masked-out areas rather than making them transparent. Alpha is the one you want for matting; multiply is the "black it out" trick. - threshold (0–1) - anything below this value becomes fully transparent. Values above get rescaled back to the 0–1 range, so it's a hard clip + renormalize, not a gradual fade.
- feather (0–0.5) - a Gaussian-style smoothing on the mask edges before it's applied. This is your fix for jagged mask boundaries; it trades crisp edges for soft ones, and it's relative to image size, not a fixed pixel count.
Output is a single IMAGE (RGBA in alpha mode), ready to feed any alpha-aware node - the pack's compositor, layer effects, or a save.
Installing it
ComfyUI Manager → search "RC Image Compositor" → install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/kj863257/ComfyUI_RC_Image_Compositor
cd ComfyUI_RC_Image_Compositor
pip install -r requirements.txt
Dependencies: pillow, numpy, opencv-python. Nothing to download.
Where people get burned
- Mask convention is the eternal gotcha. ComfyUI masks are white = keep/action. If your mask comes out inverted (subject erased, background kept), flip it before applying - there's no invert toggle here, so an upstream invert node is your friend.
thresholdis a clip, not a levels control. Values below the threshold are zeroed, above are stretched. Set it too high and you blow out soft edges that feather would have kept.- Feather does a lot at 0.5. The tooltip's max is 0.5 and it's relative to image dimensions, so 0.3 on a big image is a serious blur. Start near 0.05.
- The mask and image should share dimensions. If they don't, results get odd because the alpha is sampled at the image's size. Resize the mask to match first.
This is the node that makes background-removal workflows feel complete: model spits out a mask → RC_MaskApply turns it into transparency → compositor places the cutout. Simple, and exactly the right amount of control.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| mask_mode | COMBO | alpha | Mask application mode: - alpha: Use mask as alpha channel - multiply: Multiply image by mask (darken) |
| threshold | FLOAT | 0.000–1 | Threshold for mask (values below this become transparent) |
| feather | FLOAT | 0.000–0.5 | Feather/smooth the mask edges |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |