Depth-Based Pixelization
Far Away, Pixelated. Close Up, Detail.
- images
- depth_maps
- IMAGE
Depth-Based Pixelization is the pixelation filter that understands depth. Normal pixelation blurs the whole frame evenly - this one makes far-away content chunky and keeps near content detailed, so the result has a depth-of-field quality you can't get from a uniform mosaic. It's the perfect tool for "who's that blurry person in the background" censorship, stylized tilt-shift looks, or any privacy-blur where you want the foreground to stay readable.
It's one of the more interesting image nodes in DJZ-Nodes because it takes two inputs - the image and a depth map - and uses the depth to drive the block size. Wire in a MiDaS or Zoe depth estimate and suddenly your pixelation responds to the actual scene geometry.
How it works
The depth map gets normalized to 0–1, optionally inverted (invert_depth defaults to true, because most depth maps are "white = near"), then raised to the depth_influence power to shape the response curve. That value is mapped into the block-size range, and the image is pixelated block-by-block - each block replaced with its mean color. Near pixels get small blocks (min_block_size), far pixels get big ones (max_block_size). Raise depth_influence and the transition between zones becomes more dramatic; lower it and it's mushier.
The batch handling is a plus: it processes image/depth pairs together, so you can run it across a whole video's frames as long as each frame has a matching depth map.
The inputs that matter
imagesanddepth_maps- both requiredIMAGEinputs. The depth map can be grayscale or RGB (it's averaged); it gets resized to match your image if the sizes differ.min_block_size/max_block_size- the block range. 4–32 is a good default pair; wider gaps make the depth effect more obvious.depth_influence(0.1–2, default 1) - how aggressively depth controls block size. Above 1 exaggerates the near/far split.invert_depth- leave true unless your depth map is already inverted (black = near).
Output is an IMAGE at the same size as the input.
Installing it
Depth-Based Pixelization ships in DJZ-Nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/DJZ-Nodes
cd DJZ-Nodes
pip install -r requirements.txt
Restart ComfyUI or install via Manager ("DJZ-Nodes"). Needs OpenCV and torch - both present in any normal ComfyUI install. The depth map itself comes from a separate node (MiDaS/Zoe via the depth-estimation packs), so that's the extra piece you'll add to the graph, not a download this node needs.
Common issues
The classic failure is a garbage depth map - if your depth_maps are all one brightness, the whole image collapses to a single block size and you get uniform pixelation (or nothing). Check your depth output visually before wiring it in. Second, min_block_size: 1 is legal but produces a weird mix where some pixels aren't pixelated at all; keep it ≥4 for a clean look. And watch the batch: if the image batch and depth batch have different frame counts, the node won't pair them sensibly. One image + one depth map is the boring, reliable setup.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| depth_maps | IMAGE | — | |
| min_block_size | INT | 41–32 | — |
| max_block_size | INT | 321–64 | — |
| depth_influence | FLOAT | 1.00.1–2 | — |
| invert_depth | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |