ComfyUI Node

Mask Process

Blur or pixelate exactly the region your mask says

By gasdyueer·Created 12 months ago·Updated 11 months ago· 0
Mask Process
  • image
  • mask
  • IMAGE
effect_typegaussian_blur
apply_modemasked_area
mosaic_pixel_size16
gaussian_kernel_size25
gaussian_sigma5.0

Mask Process (class MaskedImageEffects) is the small, useful node that does exactly one thing: takes an image and a mask, and applies either a Gaussian blur or a mosaic to the masked region - or, if you flip a toggle, to everything except the masked region. It's the "blur the face, pixelate the license plate" utility of the ComfyUI YOLO Mask Process pack, and it doesn't need a single model download to do it.

You'll usually reach for it in the obvious pair: run YOLO Detection on your image, grab the mask it produces for class person, and feed it here to blur out everyone but your subject. But the input is just any mask tensor, so it works equally well with an inpaint mask, a rembg cutout, or a SAM mask you drew by hand. The pattern is everywhere in the ecosystem - ADetailer and Impact Pack built their reputations on detect-then-mask - but those are aimed at inpainting. This node is for post-processing: hiding a face for privacy, censoring an area, or just directing attention away from a noisy background.

How it works

The mechanism is refreshingly simple, and it's worth understanding one quirk. The mask is thresholded at 0.5 - anything above half-white counts as "masked" - so a soft, feathered mask becomes a hard-edged selection. It also resizes the mask to match the image dimensions automatically (LANCZOS upsampling), so mismatched resolutions don't blow up in your face.

For mosaic, it walks the image in blocks of mosaic_pixel_size and replaces the pixels inside the mask with that block's average color. Blocks that straddle the mask edge only affect the masked pixels, which keeps the boundary clean. For gaussian_blur, it prefers a torchvision GaussianBlur (blending the blurred and original frames pixel-by-pixel using the mask) and falls back to a pure-PIL blur if torchvision isn't available. The apply_mode toggle simply inverts the selection - masked_area affects the white region of the mask, unmasked_area affects the black region.

The inputs that matter

Only a handful, and they're all self-explanatory:

  • effect_type - gaussian_blur or mosaic. Pick one; the other's parameters become dead weight, which is fine.
  • apply_mode - masked_area (the mask's white region) or unmasked_area (everything outside it). The background-blur trick lives in the second option.
  • mosaic_pixel_size (default 16) - bigger blocks, chunkier mosaic. 16–32 reads as "pixelated for privacy," past 64 it gets abstract.
  • gaussian_kernel_size (default 25) and gaussian_sigma (default 5.0) - the kernel is auto-adjusted to an odd number if you feed it an even one, and sigma is the "how much blur" dial. Start at the defaults and drop sigma if the result feels like looking through a fogged window.

The output

One thing out: IMAGE, the processed frame. It's a standard ComfyUI image tensor, so it wires straight into Save Image, a VAE encode for further sampling, or a video frame sequence. There's no mask passthrough, so if you need the selection downstream, keep the original mask on a separate wire.

Installing it

There are no extra downloads for this node - no models, nothing heavy. It's part of the same pack as YOLO Detection, so installing the pack gets you both. ComfyUI Manager, searching "ComfyUI YOLO Mask Process", or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/gasdyueer/comfyui-yolo-mask-process.git
cd comfyui-yolo-mask-process
pip install -r requirements.txt

Then restart ComfyUI and you'll find it under the yolo-mask-process category. The one dependency you don't already have is probably scipy (for the optional mask smoothing over in the detector), and the README asks for Python 3.11+.

Where people trip

Nothing about this node is exotic, but three small gotchas will save you a confused look. First, that 0.5 threshold: if your mask came out of an impaint or SAM node with soft edges, the effect will be sharply cut off rather than feathered - blur the mask before feeding it in if you want a gentle transition. Second, unmasked_area with a tiny mask does what it says: you asked for "everything except the face," and you'll get a heavily processed background. Third, since mosaic only touches pixels inside the mask, a low-resolution mask upsampled to a big image can look blocky at the edges. And if you see a log line about resizing, that's the node doing its job - the mask dimensions didn't match, and it fixed it silently.

Categoryyolo-mask-process

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
maskMASK
effect_typeCOMBOgaussian_blur2 options: gaussian_blur, mosaic
apply_modeCOMBOmasked_area2 options: masked_area, unmasked_area
mosaic_pixel_sizeINT162–256
gaussian_kernel_sizeINT253–255
gaussian_sigmaFLOAT5.00.1–20

Outputs (1)

NameTypeDescription
IMAGEIMAGE