πΎ Channel Mask Pro
Extract R, G, B, and Alpha straight out of the image
- image
- mask
- red_mask
- green_mask
- blue_mask
- alpha_mask
Most people only ever touch masks as "the thing the background-removal node spat out." Channel Mask Pro is the reminder that a mask can be derived from any image, by pulling the red, green, blue, and alpha channels out as separate single-channel masks - then polishing each one with levels, gamma, contrast, and brightness before it ever reaches your sampler. If you've ever wanted a luma mask, a "reddest parts of the image" mask, or a way to isolate a subject by color, this is the node.
The mechanism
Feed it an image, and it splits the four channels: R, G, B, and (if the image has one) Alpha - if there's no alpha channel, it emits a solid white one. Each channel is then run through the same adjustment stack: black_point/white_point/gamma (the classic levels trio) plus contrast/brightness, and optionally flipped with invert_channel_mask. The outputs are four masks: red_mask, green_mask, blue_mask, alpha_mask.
The inputs that matter
- mask + invert_input_mask - a whole-image mask that constrains where channel extraction is "valid." Wire in a subject silhouette and the channel masks only show through inside it, which is how you get a selective color mask rather than a whole-frame one. This is the feature that separates it from a toy.
- preview_channel - an in-node B&W preview selector (
all,red,green,blue,alpha), so you can eyeball each channel's extraction before you commit. - The levels/contrast/brightness sliders - used to make the extracted mask actually usable: push
black_pointup to kill noise in the dark channel regions, or crankcontrastto harden a soft color separation into a clean mask.
Where it fits
Channel masks are the unglamorous backbone of compositing and selective grading. A red-channel mask is a natural luma-ish luminance mask; a blue-channel mask is how you isolate sky; an alpha-channel mask from a transparent PNG is how you get a subject mask without any segmentation model at all. Pair the output with Mask Composite Pro 2X/6X to union or isolate channels, or with Inpaint Mask Pro to constrain an inpaint region. In the same pack it also shares the levels code with Levels Adjust, so the numbers behave the way you already know.
Install
Standard MachinePainting Nodes install:
cd ComfyUI/custom_nodes
git clone https://github.com/machinepainting/ComfyUI-MachinePaintingNodes.git
pip install -r requirements.txt
or ComfyUI Manager β "MachinePaintingNodes" β install β restart. Deps are opencv-python-headless, numpy<3, and rembg (the last one mostly for the pack's background-removal node, not this one).
Gotchas
The channel order is R,G,B as ComfyUI stores them - don't be surprised if the "blue" mask looks like the sky and the "red" mask looks like skin; that's just what the channels contain. If your image has no alpha, the alpha_mask output is a solid white pass-through, so don't wire it into a mask stack expecting transparency that was never there. And if a channel mask looks too noisy to be useful, hit it with black_point and contrast rather than reaching for a blur - the node gives you the cleanup tools precisely so you don't have to bolt on another one.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| maskopt | MASK | β | |
| invert_input_maskopt | BOOLEAN | false | β |
| black_pointopt | FLOAT | 0.000β0.5 | β |
| white_pointopt | FLOAT | 1.000.5β1 | β |
| gammaopt | FLOAT | 1.000.1β3 | β |
| contrastopt | FLOAT | 0-100β100 | β |
| brightnessopt | FLOAT | 0-100β100 | β |
| invert_channel_maskopt | BOOLEAN | false | β |
| preview_channelopt | COMBO | all | 5 options: all, red, green, blue, alpha |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| red_mask | MASK | β |
| green_mask | MASK | β |
| blue_mask | MASK | β |
| alpha_mask | MASK | β |