DOGMA Exact Masked Stitch v10
Pure geometry, no colour matching, no cleverness
- base_image
- patches
- masks
- stitch
- image
The last step of a crop-and-stitch run is the one people get wrong, and the KB's oldest piece of advice about it is one sentence from a 2024 thread: "PLEASE composite your image after inpainting!" The reason is that the obvious implementation - run the whole image through the model, decode, save - degrades pixels that were never supposed to change. This node is the discipline in node form. Its docstring says it plainly: no colour matching, no texture synthesis, no global correction; only pixels allowed by the final semantic mask are copied.
How it works
You give it the base_image (your master, untouched), patches (a list of sampled crops), masks (a list, one per patch), and stitch - the DOGMA_STITCH list that a crop node emitted, carrying each crop's x, y, width, height back in master coordinates.
For each entry it resamples the patch to the recorded rectangle with bicubic + antialias, resamples the mask the same way, and composites:
result = patch * (mask * strength) + region * (1 - mask * strength)
That's it. One number does everything: strength (default 1.0) scales the mask uniformly, so it's a global opacity on the whole paste. At 1.0 the mask's own values are the only thing deciding what changes; at 0.5 you're half-blending the entire region no matter what the mask says.
Entries flagged noop are skipped - that's the crop node's "I couldn't find anything to fix" signal, and skipping it is why you don't get a pointless paste of the centre of the frame.
Why "exact" matters
Two things this node deliberately does not do, both of which other stitching nodes do and both of which cause visible artefacts.
It doesn't colour-match. Some stitchers compute a mean offset between patch and region and correct for it. That's exactly the operation that turns a slightly-off tile into a tile with a different slightly-off cast applied to it - you've now moved the error rather than hiding it. If the colour is wrong, the fix is upstream: check the VAE is the same one, and lower the denoise.
It doesn't synthesise a blend. The mask is the boundary, full stop. If the mask is a hard SAM polygon with no feather, you'll see the seam as a hard edge. That's not a bug in the stitch; it's a bug in the mask, and the fix is a mask node that produces an outward feather - DOGMAFastDualMaskV34 is the one in this pack.
Inputs, outputs, plumbing
Four list inputs and strength, one output: image (IMAGE), the patched master. Note it reads base_image[0] - a single image, not a batch, which is the right call for the crop-and-stitch pattern and a surprise if you were expecting batch behaviour.
Everything is INPUT_IS_LIST=True, so patches, masks and stitch must all be lists of equal length, in the same order. The node iterates min(len(patches), len(masks), len(stitch)), which means a length mismatch truncates silently instead of erroring. If half your crops came back unpasted, count your lists before you debug the images.
Same pack, same family: DOGMAStitchCrops is the older sibling and does the same arithmetic with a mask_strength widget, and DOGMAExactCoreStitchV35 is the successor - see below.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
ComfyUI Manager → DOGMA Nodes, or comfy node install comfyui-dogma-nodes. Zero Python dependencies (requirements.txt is a comment; pyproject.toml lists none) and no model files. It's arithmetic on tensors - you could read the whole function in a minute. MIT licensed.
Where people get burned
The list discipline above is the main one. The second is picking this when you want the newer behaviour. v10 applies strength across the entire alpha, including the middle of the mask. DOGMAExactCoreStitchV35 splits the mask into its opaque core (>= 0.999) and its feather, replaces the core at full strength regardless, and applies strength only to the feather. That's the one you want when you want less blending without wanting a lighter paste - which is usually the case for a repair pass. v10 is the blunt instrument, and blunt is fine when the mask is the thing you trust.
Tie it off with a composite you can see: preview the result against the base, not just the output. When only a few percent of the frame changed, the standard complaint about detailing demos applies - if you can't see the improvement at viewing size, the pass bought you nothing.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| base_image | IMAGE | — | |
| patches | IMAGE | — | |
| masks | MASK | — | |
| stitch | DOGMA_STITCH | — | |
| strength | FLOAT | 1.000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |