DOGMA v42 Safe Tile Statistics Lock
Colour-matching each tile without painting halos — non-spatial stats only
- generated
- source
- image
- info
The VLM's leftover gift to tiled restoration: one tile comes back warmer, or a touch brighter, and the composite shows it as a flat rectangle. The obvious fix is a spatial colour transfer - and that's the trap. Any per-pixel correction map trained against a neighbouring tile will happily paint coloured halos and blotches into the middle of your restored detail.
This node does the affine-only version, on purpose, and says so in its own comment: "Pure per-tile affine statistics. NO spatial correction map => cannot paint halos/blobs."
What it computes
Per tile, per channel: the mean and standard deviation of both the generated image and the source. The gain the tile wants is source_std / generated_std, the offset it wants is source_mean - generated_mean * gain. Both get clamped - gain to 1 ± gain_limit (default 10%), shift to ± shift_limit (default 5%) - and the corrected image is mixed back in at strength.
The clamp is the entire safety story. A global gain and offset can't move a pixel relative to its neighbours, so there is no mechanism by which this node can invent local structure. It can only nudge the tile's overall exposure and contrast toward the master it will be pasted into.
That matters more on this pipeline's model than on most. The KB's Flux 2 doc notes the known, reproducible one: Klein edits come back warmer and slightly yellow-shifted on both fp8 and fp16, and the standard community fix is a histogram or colour match against the source. This is that fix, in the one form that's safe at tile scale.
Inputs and outputs
generated- the restored tile.source- the corresponding region of the master. Mismatched sizes get bicubicked into place, and a single-frame source gets expanded across a batch, so you can be a bit loose here.strength(0.55) - how much of the correction actually lands. At 1.0 you fully impose the source stats; at 0.3 you're just nudging.gain_limit(0.10) andshift_limit(0.05) - the clamps. Raise them only when you've confirmed the tile genuinely is off, because a large gain on a low-contrast source over-brightens flat areas.
Outputs image and info, where info reports the effective strength, mean gain and mean absolute shift. Those three numbers are how you tell "it did a subtle correction" from "it hit the clamp on every tile" - if gain sits exactly at the limit, your tile really was far off and the clamp is doing damage control.
Install
ComfyUI Manager → search DOGMA Nodes, or:
cd ComfyUI/custom_nodes && git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
Restart. No dependencies (requirements.txt = # No external dependencies.), no model files, no network. One caveat worth stating plainly: the repo README lists neither this node nor its ~300 siblings, because the whole semantic suite is registered from dogma_semantic_v5641.py. There's no community writeup to fall back on.
Where it bites
It cannot fix a spatial mismatch. If a tile was generated from a slightly shifted region - an off-by-a-few-pixels crop - average statistics will match beautifully and the composite will still show doubled edges. That's an edge-anchoring job, not a statistics job.
Mean/std matching ignores the midtones. Two tiles can have identical mean and std and still look different because one has a colour cast in the shadows. This is a coarse instrument; it removes the flat-rectangle seam, not a colour-management error in your chain.
Run it per tile before stitching. Applied to a finished master, it will happily equalise the whole image's statistics, which is just a contrast-and-saturation change you didn't ask for.
Don't stack it with another auto colour-match. Two statistics passes on the same tile double the correction and drift away from the source.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| generated | IMAGE | — | |
| source | IMAGE | — | |
| strength | FLOAT | 0.550–1 | — |
| gain_limit | FLOAT | 0.100–0.3 | — |
| shift_limit | FLOAT | 0.050–0.2 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| info | STRING | — |