Censor with Mask
Blur, pixelate, or paint over exactly what a mask says
- image
- mask
- censored_image
The node that obeys your mask
Censor with Mask is exactly what the name promises: give it an image and a mask, and it blurs, pixelates, or paints over the region the mask covers - nothing else. It's from the same pack as the detectors, but it does zero detecting on its own. The mask is on you, and that's the point. It slots into a pipeline where something upstream decides what to hide: typically Imgutils Generic Detector in "Censor Detection" mode finds the region, SAM Predictor refines it into a precise mask, a Mask Morphology node cleans that up, and this node does the hiding. The pack ships a censor example workflow wired exactly that way.
How it works
The three modes are unglamorous PIL/CV operations under the hood, which is fine - this is not a place that needs AI.
- blur - Gaussian blur with a
blur_radius, composited back only inside the mask. - pixelate - downscales the image by
pixelate_size, then upscales with NEAREST. That's the classic mosaic. - color - fills the mask region with a solid
color_hexvalue atcolor_opacity.
The color mode is the one people sleep on. Crank color_opacity down to 0.4 and you get a tint instead of a slab, which looks far less jarring than a hard black rectangle when you're hiding a watermark or a stray hand.
Inputs and outputs that matter
Required: image, mask, and censor_mode (blur / pixelate / color). The three optional fields only matter for the mode you picked:
blur_radius(default 5, 0.1–50) - blur mode.pixelate_size(default 10, 1–100) - bigger is chunkier blocks.color_hexandcolor_opacity(default#000000, 1.0) - color mode.
Output is a single censored_image. One minor gotcha: the blur radius is cast to an int internally, so 1.9 becomes 1, not a rounded 2. Doesn't matter much in practice.
Install
It's part of the LK-168/comfyui_imgutils pack. ComfyUI Manager → "Install Custom Nodes" → search "comfyui_imgutils", or:
cd ComfyUI/custom_nodes
git clone https://github.com/LK-168/comfyui_imgutils
Restart ComfyUI. The pack pulls torch, numpy, opencv-python, Pillow, segment_anything, and dghs-imgutils[gpu] - Manager handles those; manual installers may need pip install -r requirements.txt. This node itself is pure image math, but the detection and SAM nodes it's designed to chain with download models to $HF_HOME on first run, so set that env var before you start (the README is explicit about it).
Common issues
- Mask doesn't match the image. If your mask came from a different resolution or a cropped image, the censored region is in the wrong place. Resize the mask to the image's dimensions upstream.
- "Nothing changed." Check the mask isn't empty - run Mask Info from this same pack: 0% coverage means an all-black mask, and no censor mode will save that.
- Blurry blob around your subject. That's the mask being loose, not the node being broken. Tighten it with a morphology/edge operation before feeding it in.
Reach for this when you want selective hiding without rebuilding it yourself - it's one of those small nodes that makes the whole detection side of the pack feel finished.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| censor_mode | COMBO | 3 options: blur, pixelate, color | |
| blur_radiusopt | FLOAT | 5.000.1–50 | Blur radius for blur mode |
| pixelate_sizeopt | INT | 101–100 | Pixel block size for pixelate mode |
| color_hexopt | STRING | #000000 | Hex color for color mode (e.g., #FF0000 for red) |
| color_opacityopt | FLOAT | 1.000–1 | Opacity/transparency for color mode |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| censored_image | IMAGE | — |