〽️ ImageOps Mask Convert
Turn any image into a mask (and back) with real matte extraction
- image
- mask
- image
- mask
ImageOps Mask Convert is the node for the single most annoying gap in ComfyUI: images and masks are two different data types, and they don't just swap. It converts an image into a mask, or (with reverse) a mask back into a previewable image - and it does the conversion properly, with selectable matte extraction, level remapping, and antialiasing. It's from the ComfyUI-Majoor-ImageOps pack.
Why the conversion isn't trivial
A mask in ComfyUI is a single channel [B, H, W]; an image is [B, H, W, C]. If you've ever jammed an image into a mask input and gotten a confusing error - or worse, a silently wrong result - this node is the fix. But it also does more than flatten: mask_source lets you choose which aspect of the image becomes the matte:
auto- picks a sensible default for you.luma- brightness becomes the matte (Rec. 709 weighted, in this pack's linear float space). The go-to for most images.max_rgb- the brightest channel. Good for fire, glows, anything where "what's brightest" is the signal.saturation- colorfulness becomes the matte. The move when you want "the colorful thing" separated from the grey background.red/green/blue/alpha- grab a specific channel as the matte.
Then black_point and white_point (0–1) remap the extracted values - sliding the black point up hardens the matte, sliding the white point down cuts the top end. And antialias_radius applies a tiny blur before the level step to smooth jagged edges on a rough source, which is the difference between a matte with jaggies and a matte that composites cleanly.
The two directions
- image → mask (
reverseoff): feedimage, get a mask. Standard flow: a rendered image, a luma or saturation extraction, levels-adjusted, into whatever node wants a mask. - mask → image (
reverseon): feedmask, get a previewable image. This is the one people forget exists - it's how you actually look at a mask you generated, or how you feed a mask-shaped thing into a node that demands an image. Theimageinput is used when reverse is enabled.
Outputs are image and mask both, so whichever direction you're going, the node hands you both representations.
Install
ComfyUI Manager (search "ComfyUI-Majoor-ImageOps"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/MajoorWaldi/ComfyUI-Majoor-ImageOps
Restart and hard-refresh the browser (Ctrl+F5 / Cmd+Shift+R). No models, no extra deps.
The gotchas
The direction is the trap. With reverse off (image→mask) the node needs the image input wired; with it on (mask→image) it needs the mask input. Get them crossed and it errors out telling you exactly which input is missing - which is honest, but still a minute of head-scratching the first time. Just remember reverse turns around which input is the source. Second, auto on mask_source is decent but not magic - for skin-tone mattes or specific scenes, luma with a black-point push usually beats it. And if the matte looks noisy, that's what antialias_radius is for - a couple of pixels smooths it before the levels bite.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| reverse | BOOLEAN | false | — |
| mask_source | COMBO | auto | 8 options: auto, luma, max_rgb, saturation, red, green, +2 |
| black_point | FLOAT | 0.000–1 | — |
| white_point | FLOAT | 1.000–1 | — |
| antialias_radius | FLOAT | 0.00–4 | — |
| imageopt | IMAGE,VIDEO | Images/Video input used when reverse is enabled. | |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |