ComfyUI-BarCensor
A ComfyUI extension with 2 custom nodes.
Nodes (2)
ComfyUI-BarCensor
Censor a region with parallel solid-color bars (black / white / custom) instead of mosaic.
A companion to β and derivative of β 1038lab/ComfyUI-Mosaic: that project does mosaic detection / creation, this one replaces the mosaic with proper censor bars.

δΈζθ―΄ζοΌδ½Ώη¨θ―΄ζ.txt ο½ README_CN.md
Why
- Mosaic looks like mosaic. A bar censor looks like a bar β straight edges, sharp corners.
- All bars are parallel by construction. Bar #1 defines the direction; every other bar is
generated by translating bar #1 along its own normal. Measured angle spread across bars:
0.000 deg. - The angle can be read from the mask automatically (minimum area rectangle / PCA).
- Bar thickness auto-scales with the bar count, so the covered block keeps its size.
Nodes
Menu: π§ͺAILab β β¬BarCensor
BarCensor β Bar Censor (Parallel Bars)
image + optional mask β image + censor_mask + info
| Parameter | Values | Meaning |
|---|---|---|
| bar_count | 1β32 | 1 = solid block; >1 = evenly spaced parallel bars |
| angle_mode | auto_rect (default), auto_pca, horizontal, vertical, diagonal_down, diagonal_up, manual | source of the base angle. auto_rect fits a minimum area rectangle to the mask and uses its long side |
| angle | -180β180 | only used by manual (0 = horizontal, 90 = vertical) |
| bar_orientation | along_axis (default), across_axis, axis_plus_offset | bars along / across / offset from the region axis |
| axis_offset | -180β180 | offset used by axis_plus_offset |
| bar_shape | rectangle (default), conform_mask | straight-edged rotated rectangle, or follow the mask outline |
| thickness_mode | auto (default), manual | auto: thickness = period Γ ratio, rescales with bar_count |
| thickness_ratio | 0.05β1.0 | thickness / period (auto), or its upper bound (manual) |
| bar_thickness | px | fixed thickness for manual |
| length_mode | fit_region (default), full_image | bar length = region span, or span the whole image |
| length_overflow | px | extra length at both ends |
| color | black, white, gray, custom | bar color |
| custom_color | hex, e.g. #1a1a1a | used when color = custom |
| opacity | 0β1 | bar opacity |
| feather | px | edge softening (0 = hard, 1 β anti-aliased) |
| mask (optional) | MASK | region to censor; without it the whole image is striped |
| invert_mask | bool | invert the mask |
| region_expand | px | grow the block (rectangle) or dilate the mask (conform_mask) |
MaskMerge β Mask Merge (Combine Overlaps)
mask_a + up to 7 more β mask + info
Merge several detector masks into one before censoring, so you only need a single censor pass and never stack a second layer on already covered pixels.
| Parameter | Values | Meaning |
|---|---|---|
| operation | union (default), intersection, add, average | max / min / clamped sum / mean |
| batch_mode | flatten (default), elementwise | flatten: every frame of every input collapses into one mask. elementwise: frame i merges with frame i (video) |
| threshold | 0β1 | 0 = off; e.g. 0.5 binarizes soft masks |
| mask_b β¦ mask_h | MASK | up to 8 slots total; cascade nodes for more |
Typical wiring
detector A ββ
detector B ββΌβ> MaskMerge ββ> one merged mask ββ> BarCensor ββ> censored image
detector C ββ β
image ββββββββββββββββββββββββββββββββββββββββββββββββ
Installation
cd ComfyUI/custom_nodes
git clone https://github.com/InfinityTechnology/ComfyUI-BarCensor.git
Restart ComfyUI. Dependencies (torch, numpy, opencv-python) ship with ComfyUI.
Relation to ComfyUI-Mosaic
This project is not a fork of 1038lab/ComfyUI-Mosaic β
no code was copied from it. It follows the same node interface convention
(image + optional mask β image + mask) so the two can be swapped inside a workflow,
and it exists because that project covers mosaic while this one covers bar censor.
Upstream: https://github.com/1038lab/ComfyUI-Mosaic
Tips
- For video, avoid the auto angle modes: per-frame estimation jitters. Use
manualorhorizontal. - Tall regions (a standing person) give vertical bars with
along_axis; switch toacross_axisif you want horizontal bars. BarCensortreats the whole mask as one region. If the merged mask holds several separate blobs, it builds one bounding block that covers all of them (gaps included).
License
GPL-3.0 β same as the upstream project, so the two stay compatible.