Censor Bars By Mask
The anime-style bar censor, driven by any mask
- image
- mask
- image
You know the look: a face, a sign, a license plate hidden under parallel black bars - the censorship stripe that shows up in anime, Japanese print media, and news broadcasts alike. This node recreates it in ComfyUI, pointed at exactly what you want by a mask, and leaves every pixel outside that mask untouched. If you've been doing this with a flat fill or a soft brush, this is the upgrade.
It ships in the same small pack as Mosaic By Mask - the two are the pack author's "hide something by mask" pair. Mosaic pixelates; this one lays down stripes. Which you want is an aesthetic call, but the bar look reads unmistakably as "censored" in a way mosaic sometimes doesn't.
How it works
You feed it an image and a mask. The mask's non-zero region is the target - it's used as a placement basis for the bars, not painted over directly. The node finds the region's bounding box, then in angle_mode = auto runs a quick PCA over the mask's pixels to estimate its long axis, so bars automatically run perpendicular to a thin region (a face, a plate). angle_mode = manual lets you set the angle yourself with angle_deg.
Bars are drawn as a stack of parallel stripes along that axis. Each bar's bar_width and bar_spacing get a small random nudge from width_jitter and spacing_jitter, driven by seed, so the result looks organic instead of laser-cut. Everything is clipped to the mask, so bars never bleed outside it, and the final composite is an alpha blend at opacity with your chosen bar_color_r/g/b (default black). It's all pure torch tensors - fast, no models involved.
The inputs that matter
image+mask- the pair. White mask areas are what get hidden.angle_mode-auto(PCA, good enough for most regions) ormanual.bar_width(18) andbar_spacing(8) - chunkier bars and tighter spacing make it look more like the classic censor stripe.seed- jitter reproducibility; fix it if you're comparing runs.opacity- 1.0 is solid; lower lets the image ghost through.
The single output, image, is the composited result - wire it to a preview or a save node.
Install
It's part of ComfyUi_zaknak_nodes. In ComfyUI Manager, search for that pack title and install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zaknak/ComfyUi_zaknak_nodes
Then restart ComfyUI. No model downloads, no extra Python deps for this node - the pack's only real dependency (tomli) exists for its LLM nodes.
Where it fits in a workflow
Put it after VAE Decode, with a mask from any MASK-producing node - Segment Anything via Impact Pack, a mask editor, or a face-detection mask. Common uses: anonymizing faces or plates before you post a generation, building parody or "censored preview" thumbnails, or just replicating the anime censor aesthetic for a joke that's funnier than it should be.
Troubleshooting
- Empty mask, or
opacity = 0: the node returns the input image unchanged - no error, which is nice, but also a silent way to wonder why nothing happened. - Bars look wrong direction:
automode falls back to 0° for tiny, near-circular, or low-contrast masks where PCA has no strong axis. Give it amanualangle in those cases, or nudgeangle_offset_deg(default 90, which is the perpendicular-to-axis look). - It prints timing lines to the ComfyUI console (
[CensorBarsByMask] preprocess_mask: ...). Harmless - the author added them for debugging, and they're genuinely handy when a batch is slow. - Mask batch size mismatch: if your mask batch isn't 1 or equal to the image batch, it errors. Switch
mask_batch_modetomerge_batch_to_oneto collapse several masks into one region.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| mask_batch_mode | COMBO | match_image_batch | 2 options: match_image_batch, merge_batch_to_one |
| bar_color_r | INT | 00–255 | — |
| bar_color_g | INT | 00–255 | — |
| bar_color_b | INT | 00–255 | — |
| opacity | FLOAT | 1.000–1 | — |
| angle_mode | COMBO | auto | 2 options: manual, auto |
| angle_deg | FLOAT | 0-180–180 | — |
| angle_offset_deg | FLOAT | 90-180–180 | — |
| bar_width | FLOAT | 181–512 | — |
| bar_spacing | FLOAT | 80–512 | — |
| width_jitter | FLOAT | 3.00–256 | — |
| spacing_jitter | FLOAT | 2.00–256 | — |
| seed | INT | 00–2147483647 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |