ImageFilterMode
The salt-and-pepper scrubber you forget exists
- images
- IMAGE
Most image filters average or order their neighborhood. ImageFilterMode does something different and weirdly useful: it replaces each pixel with the most common value in the surrounding window - the mode, as in "majority vote." Think of it as consensus filtering. If most of the pixels around a spot agree on a color, that color wins and the oddball pixel gets corrected. It's the classic scrubber for salt-and-pepper noise: those random black-and-white speckles are almost never the local majority, so they vanish while real edges and textures mostly hold.
It's part of the Allor Plugin (Nourepide/ComfyUI-Allor), the image-processing pack that keeps RGBA and multi-image batches intact across every node. Mode sits in the filter family with Min, Max, Rank and the blur cluster, and it's the one that handles "dirty scan," "speckled composite," and "grainy flat area" cleanup better than any blur.
How it works
Under the hood this is PIL's ImageFilter.ModeFilter run per image in the batch. As with the pack's other rank-style filters, the kernel is size + 1, and size steps by 2 so you always get an odd window. The default size of 2 becomes a 3×3 kernel. In that window, every channel votes and the majority value is written to the center pixel.
That mechanism explains both the strength and the limitation. Because it's a vote, it's excellent at killing sparse noise - a single white pixel surrounded by eight consistent pixels gets overwritten every time. But it's bad at anything with real texture: fine detail is rarely the majority in a window, so on noisy-but-textured regions it can plaster over detail with the dominant color. Where a min/max filter shrinks highlights, Mode removes outliers outright, which makes it the better tool for scanned images and upscaled-then-noisy compositions. The trade-off is that large kernels posterize - increase size and flat areas start to band, because the window fills with a single winning tone.
Inputs and outputs
Two inputs, one output:
images(IMAGE) - a single image or a whole batch; every frame gets filtered.size(INT, default 2, step 2) - the voting window. Low for light cleanup, higher only if the speckle is dense.
The output is an IMAGE at the same resolution and channel count, RGBA preserved, ready to feed PreviewImage, a SaveImage, or the next node in your Allor chain.
Installing it
It ships in the Allor Plugin, so the install is the pack's install: search "Allor Plugin" in ComfyUI Manager, install, restart. The manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor
Restart after either path. This node is pure PIL and needs no model downloads; the pack's heavier dependencies (rembg, onnx) are only exercised by its segmentation module. First launch writes a config.json that enables daily auto-update - harmless, but know it's there.
Where people get burned
The classic mistake is using Mode on a noisy photo and watching fine detail turn to paint. It's a consensus filter, not a denoiser; if you want to soften without detail loss, reach for ImageFilterStackBlur from the same pack instead. Reserve Mode for the sparse-speckle case, keep the window small, and if you need more aggressive cleanup, run it twice with a small kernel rather than once with a huge one - repeated small passes keep more detail than a single large window.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| size | INT | 2 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |