Nodes/ComfyUI-Majoor-ImageOps/〽️ ImageOps Mask Convert
ComfyUI Node

〽️ ImageOps Mask Convert

Turn any image into a mask (and back) with real matte extraction

By MajoorWaldi·Created 8 months ago·Updated 8 days ago· 11
〽️ ImageOps Mask Convert
  • image
  • mask
  • image
  • mask
reversefalse
mask_sourceauto
black_point0.00
white_point1.00
antialias_radius0.0

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 (reverse off): feed image, get a mask. Standard flow: a rendered image, a luma or saturation extraction, levels-adjusted, into whatever node wants a mask.
  • mask → image (reverse on): feed mask, 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. The image input 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.

Categoryimage/imageops

Inputs (7)

NameTypeDefaultDescription
reverseBOOLEANfalse
mask_sourceCOMBOauto8 options: auto, luma, max_rgb, saturation, red, green, +2
black_pointFLOAT0.000–1
white_pointFLOAT1.000–1
antialias_radiusFLOAT0.00–4
imageoptIMAGE,VIDEOImages/Video input used when reverse is enabled.
maskoptMASK

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK