ComfyUI Node

Blur by Mask

Selective blur — soften exactly the region the mask says, leave the rest sharp

By Pirog17000·Created about a year ago·Updated 10 months ago· 3
Blur by Mask
  • image
  • mask
  • IMAGE
invert_maskfalse
blur_amount2.0

Depth-of-field, background blur, hiding a face or a license plate, forcing a soft focus where the model got too crunchy - all of these are "blur this region, leave the rest alone." Blur by Mask does exactly that: where the mask is white, the image gets blurred; where it's black, it stays untouched. It's a small node, but it's the kind of thing you end up wiring up by hand constantly - and this version does it fast and handles mismatched sizes without drama.

How it works

The node blurs the whole image with a Gaussian, then blends between the blurred and original versions using the mask. Where the mask is 1.0 you see blurred; 0.0 you see original; the values in between give you a smooth transition - which is exactly why you'd pair it with Blur Mask if your mask needs softening first.

The blur itself is a custom separable Gaussian done with PyTorch convolutions rather than PIL or scipy - horizontal pass then vertical pass, all channels at once. That's the implementation detail that makes it fast on GPU and keeps it dependency-light. It handles dimension mismatches by resizing the mask to the image, and invert_mask flips the selection so the sharp side is controlled by the mask instead.

The inputs that matter

  • image - what gets blurred.
  • mask - the selection. White = blurred, black = sharp.
  • invert_mask - flips that polarity.
  • blur_amount (0–50, default 2) - the Gaussian sigma. 0 = no blur.

Output: IMAGE, same dimensions as the input.

Where you'd use it

The obvious one is fake depth-of-field: get a depth map or a simple radial mask, and this becomes the blur pass in a background-focus look. It's also the fastest way to scrub out a watermark or anonymize a region - no inpainting needed, just a mask and a blur. Photorealism folks use it to knock back AI's too-clean synthetic edges on specific regions. It's a "one knob, one mask, done" node, and sometimes that's exactly what a workflow needs.

Installing it

Ships in Pirog's Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/Pirog17000/Pirogs-Nodes
pip install -r Pirogs-Nodes/requirements.txt

Or search "Pirog's Nodes" in ComfyUI Manager and restart. Pure PyTorch - no extra dependencies beyond what the pack already pulls in.

Gotchas

Batch handling is worth knowing: it processes min(image_batch, mask_batch) - if your image batch is larger than your mask batch, extra images just don't get processed, so keep the batch counts matched. And blur_amount is the sigma of a Gaussian, not a radius - the actual kernel is about six times that, so a value of 2 is already a decent soft blur and 10 is heavy. Start low; it's easy to nuke a region into mush.

Categorypirog/image

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskMASK
invert_maskBOOLEANfalse
blur_amountFLOAT2.00–50

Outputs (1)

NameTypeDescription
IMAGEIMAGE