DOGMA Harmonized Stitch Crops
DOGMA Harmonized Stitch Crops
- base_image
- patches
- masks
- stitch
- image
Take a crop out of a photograph, run a modern model over it, paste it back at full opacity, and it will look pasted on. Not because the model was bad - because the crop was re-rendered in isolation and came back with slightly different mean colour, slightly different contrast, slightly less grain than everything around it. The eye is absurdly good at spotting that.
This node is the version of the paste-back that fixes it. It's the one to reach for when someone looks at your restoration and says "there's something wrong with that building," and there isn't, quite.
What it is
Stitching is the last step of every crop-and-stitch pipeline, and it's the step that decides whether the whole approach reads as one photograph or a collage. The community pattern - crop around the target, run the model, stitch back - won the local-editing argument precisely because it leaves unmasked pixels alone. In ComfyUI that's Inpaint Crop → model → Inpaint Stitch, which does not even pass the unmasked region through VAE encode and decode.
DOGMA does the same job with more knobs, because it walks a list of crops rather than one region. Each crop carries its own metadata - position and size - which the pack passes on a DOGMA_STITCH wire, and each carries its own feathered mask. This node walks that list and composites each patch through its own mask, after two corrective steps.
How it works
For each crop, three things happen in order.
Colour and exposure matching. The node takes the region of the base image where this patch belongs, and the patch itself, and computes a per-channel mean and standard deviation over the pixels the mask is not going to replace - anything under 0.03 alpha. That outside region is the shared context between the two images, so matching patch statistics to base statistics over it is a least-surprises correction: the patch arrives pre-graded to its own surroundings. It requires at least 512 such pixels to engage, and color_match_strength (default 0.75) blends between the raw patch and the matched patch.
Grain restoration. It takes the base region, blurs it with a small 5x5 average pool, and subtracts to get the base's high-frequency signal - its grain and micro-texture. That signal, scaled by source_texture_strength (default 0.18), is added back onto the patch. This is the step that does the most for realism, because a re-rendered patch from any modern model is smoother than a scanned photograph, and the mismatch reads instantly on a source with visible grain. It also does not restore the old structure, which is the point: you get the source's texture statistics without the source's mangled geometry.
Masked composite. Alpha is the crop's mask multiplied by edit_mix (default 1.0), and the result is patch * alpha + base * (1 - alpha) inside the region. With a feathered mask the seam is a gradient, not a line, which is the other half of not looking pasted on.
Inputs and outputs
Four inputs are wired: base_image (IMAGE, the master you're stitching onto), patches (IMAGE - a list, consumed from the crop nodes' list outputs), masks (MASK, same), and stitch (DOGMA_STITCH - the crop geometry emitted by whichever crop node produced the patches). They must come from the same crop node or the geometry won't line up.
Three dials. color_match_strength (0–1, default 0.75) - drop it toward 0 if you want the patch to keep its own grade (often you don't; that's the pasted look). source_texture_strength (0–1, default 0.18) - the grain transplant, and the most satisfying dial in the pack to play with. edit_mix (0–1, default 1.0) - a global creative dial: set it to 0.8 and every edit lands at 80% strength, which is a cheap way to soften an over-enthusiastic batch of crops without re-running anything.
One output: image (IMAGE), the single composited master. That's it - no mask, no info string. It runs with INPUT_IS_LIST set, so it takes the list outputs directly and you don't need a batch-combining node in front of it.
Install
ComfyUI Manager → search DOGMA Nodes (publisher axior), install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
# restart ComfyUI
Zero external Python dependencies (requirements.txt says so outright) and no weights shipped. Everything it needs is torch and the crops you feed it.
Common issues
The node raises a clear error if there's no base image, which is worth knowing because a silently empty list upstream is otherwise the classic "why did nothing happen" in this kind of graph.
The real trap is mismatched lists. patches, masks and stitch are indexed together, so if a filter in between dropped some crops from one wire and not another, patch 7 gets pasted at crop 4's coordinates. The pack's own crop nodes emit all three in step, and the safest habit is not to interpose anything between them and this node.
Finally, when to reach for a different stitch: the pack ships several. DOGMAHarmonizedStitchCrops is the gentle one - good for texture and detail work where the change is subtle. The opaque stitch variants (v37, v40) composite with a harder core and are for when you genuinely want the cropped content replaced, and the v39 multiband detail stitch is for adding detail bands rather than whole patches. If your result looks washed out where the edit should be visible, you picked the diplomatic option for a job that wanted the blunt one.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| base_image | IMAGE | — | |
| patches | IMAGE | — | |
| masks | MASK | — | |
| stitch | DOGMA_STITCH | — | |
| color_match_strength | FLOAT | 0.750–1 | — |
| source_texture_strength | FLOAT | 0.180–1 | — |
| edit_mix | FLOAT | 1.000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |