Modulation
Error-diffusion halftoning with a scan direction
- images
- direction
- images
Modulation applies a directional error-diffusion effect - think Floyd–Steinberg halftoning with a specified scan direction - across an image batch. The result is the classic dithering look: a grayscale image built from binary-looking dots, the texture you see in old newspaper halftones and stylized game art. If you want that aesthetic on generated images, this is the node, and it's one of the more unusual things in the FairLab pack.
It's worth being precise about what it does before you fall in love with it: the input is converted to grayscale first. Your colorful image comes out as a halftoned black-and-white rendition, not a dithered color version. That's the point of the effect, but it surprises people who expect a color-preserving filter.
Inputs and outputs
images(IMAGE) - the batch to process.direction(ModulationDirection) - which way the error propagates; wire inModulation Directionor leave the defaultup_to_down.speed(FLOAT) - a per-frame bias, default 0.01, stepped by 0.01.images(IMAGE) out - the processed batch, same size.
The speed parameter is the interesting one: the error accumulates a small bias scaled by speed, and that bias scales with the frame index within the batch. So speed isn't just "how dithered" - it controls how the effect ramps across a batch, which makes it a tool for sequences or animation-style variation rather than a single-image knob.
How it works
Each image becomes a single-channel numpy array, then a directional error-diffusion loop runs: quantize a pixel, distribute the quantization error to the next pixel in the scan direction, and on the first pixel of each scan line subtract the accumulated per-frame bias. It processes the batch in parallel - a process pool with thread-pool fallbacks and a per-image timeout, which is more defensive engineering than you usually see in a utility node.
Where it fits
Stylized posterization, halftone looks, texture generation, and any project chasing that dithered print aesthetic. It's not a general-purpose image filter - it's a specific look, applied deliberately.
Install
FairLab, one pack: ComfyUI Manager (search ComfyUI-FairLab) or:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
cd ComfyUI-FairLab
pip install -r requirements.txt
Restart, then look under Fair/image. Requires numpy (ships with ComfyUI) and nothing pack-specific.
Gotchas
- Grayscale output, always. Feed it color, get halftone monochrome - by design, but plan for it.
- The effect is implemented in pure Python loops, so it's not fast on large batches. The parallel processing helps, but a 4K batch will still take a while.
speedramps the bias across frames - leave it near the default for a uniform look and only push it when you actually want the per-frame variation.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| direction | ModulationDirection | up_to_down | — |
| speed | FLOAT | 0.01 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |