Nodes/ComfyUI-StringsAndThings/Apply Mosaic Effect
ComfyUI Node

Apply Mosaic Effect

Pixelate an image the old-fashioned way — with tile-size control

By PressWagon·Created 2 years ago·Updated about a year ago· 3
Apply Mosaic Effect
  • image
  • MosaicImage
tile_size10

Apply Mosaic Effect does what it says: takes an image and a tile_size, and blurs each tile of the image into a solid color so the whole thing turns into chunky pixels - the classic mosaic/censor look. It's the most immediately useful of the pack's "Extras," because it has two genuinely different jobs that don't overlap.

The first is aesthetic: pixel-art style renders. Feed it a clean image with a small tile size and you get a crisp retro-pixelation effect, not a mushy blur. The second is practical: censor regions of an image. That one's the killer feature, because the README spells out the intended combo - mosaic the whole image, detect a face (or license plate) with a BBox/SEGS detector, and composite the mosaic back over just that region. The pack ships a demo workflow doing exactly this with Ultralytics + ImageCompositeMasked.

How it works

The mechanism is worth knowing because it explains why the output looks the way it does. The image is sliced into tile_size squares, and each tile is replaced by the median color of the pixels inside it. Median, not average - that's a deliberate choice, and it's why the effect reads as "blocky and deliberate" rather than "washed out." A median survives outliers, so a tile with a few bright pixels doesn't get tinted by them the way an average would.

Two implementation details from the source:

  • It converts to PIL and uses nested loops (putpixel per tile) rather than a vectorized op. For a 1024×1024 image at tile_size: 10 that's ~10,000 tiles each doing a small numpy median - a second or two, not a problem. At tile_size: 1 you're basically doing nothing, so don't bother.
  • Only the first image of a batch is processed, then it's re-batched. Feed it a batch and the rest silently don't get mosaicked.

The inputs that matter

  • image - any IMAGE tensor from your graph (VAE-decode output, an upscaled result, whatever).
  • tile_size - the only real control. INT, 1–100, default 10. Small (2–5) = subtle pixelation; 10–20 = classic censor; 50+ = abstract color blocks. There is no smoothing or blend control - the look is what it is, and that's honestly its charm.

Output is MosaicImage (IMAGE), same dimensions as the input. It's an output node, so it'll render in your preview.

The censoring pattern that actually works

Rather than mosaicking the whole image (which ruins a render), the smart workflow is selective:

  1. Mosaic the full image.
  2. Run a detector (BBoxDetectorSEGS, Ultralytics provider, etc.) on the original to get a mask of what you want to hide.
  3. Use ImageCompositeMasked to paste only the mosaicked region back over the original.

Result: a clean image with a perfectly pixelated face/plate and everything else untouched. This is the same "detect + inpaint" choreography the community uses for face fixing, just with pixelation as the fill instead of an inpainting model - and it's much cheaper.

Installing it

It's one of the nine nodes in ComfyUI-StringsAndThings. ComfyUI Manager: search "ComfyUI-StringsAndThings" → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/PressWagon/ComfyUI-StringsAndThings

No model downloads for the node itself. If you want the face-detection censoring workflow, you'll need a detector pack like Impact Pack (for SEGS) plus the Ultralytics model it loads - those are separate installs, not this pack's job.

Caveats

  • Batch limitation - first image only. For video/batch pixelation you'll need to iterate frames yourself.
  • The per-tile median is fine at sane tile sizes, but don't feed it a 4K image with tile 2 and expect instant results; the Python loop shows.
  • No alpha/feather/blend parameter. If you need soft-edged mosaic tiles, you're compositing afterward, not asking this node.
CategoryStrings&Things/Extras

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
tile_sizeINT101–100

Outputs (1)

NameTypeDescription
MosaicImageIMAGE