DOGMA v37 Opaque Stitch
Paste repaired crops back without a translucent halo
- base_image
- patches
- masks
- stitch
- image
- info
You've repaired six objects in six crops. Now they have to go back, and this is where good repairs die: blend the patch back at 50% everywhere and you get a ghost - the repaired wheel and the broken wheel both visible, half-transparent, in a halo around your object. DOGMAOpaqueMaskedStitchV37 is the version that decided the inside of the object should be 100% the model's output, and only the rim should fade.
How it works
Four inputs: base_image, patches, masks and stitch. It's a list-mode node - INPUT_IS_LIST is on - so it expects the parallel lists that a crop node emits, and a single base image.
For each entry in stitch, it reads x, y, width, height out of the metadata dict and skips anything flagged empty. It resamples the patch to the recorded rectangle with bicubic (antialiased) and the mask with bilinear. Then it builds the alpha:
core = (m > 0.58).float()
feather= avg_pool2d(m, 17, 1, 8).clamp(0,1)
alpha = torch.maximum(core, feather * 0.70)
Two terms, and the maximum is the whole idea. core is a hard binary region at mask confidence 0.58 - opaque, 100% generated pixels. feather is a box-blurred version of the mask, scaled to 0.70 so it can never fully replace the base. Taking the max means: inside the mask you get pure patch, outside you get a soft 0–70% ramp that dissolves the seam, and there's no band of half-and-half across the object itself. That last point is what "opaque" in the name means, and it's the fix for the low-definition ring you get when a feathered patch is blended over a sharp original.
info returns v37 stitched N crops, and the composite is written only into the RGB channels.
Wiring
stitch ← the crop node's stitch list output. patches ← your repaired crop images, in the same order. masks ← the crop node's crop_masks list. base_image ← the master you want the repairs pasted onto.
Order matters and there's a subtle trap in the code: it pairs patch i with stitch entry i, but indexes patches[min(i, len(patches)-1)] and the same for masks. If your repaired list is shorter than the stitch list - because a sampler skipped an item, or you filtered crops somewhere - you don't get an error, you get the last patch stamped into the leftover regions. Check that your list lengths match before blaming the blend.
Also note the pair must be parallel, not just same-length. Sorting or filtering the crops anywhere after the crop node without doing the same to stitch will paste the right pixels in the wrong places, which looks uncannily like a model hallucination.
Install
ComfyUI Manager → search DOGMA Nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
# restart ComfyUI
No dependencies - this is interpolation, a max-pool and a lerp. The README doesn't document the semantic family, this node included.
Gotchas
x/y are in base-image pixels. If you stitched onto a differently-sized master than the crops were cut from, everything lands offset. The stitch dicts carry source_width and source_height for exactly this reason - compare them, don't assume.
The mask is the model's mask, not yours. crop_masks is what the crop node rebuilt from the selected objects only, so an over-eager mask means an over-eager paste. If a repair bleeds onto neighbouring pixels, the mask is the lever, not the stitch.
The feather is generous, ~17px. On small crops that's a wide ramp, which is fine for asphalt and foliage and slightly soft on hard edges - a railing, a window frame. If you're repairing architecture and the result looks smudged at the borders, that's the 0.70 feather doing what it does; a later version of this node in the same pack tightens it.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| base_image | IMAGE | — | |
| patches | IMAGE | — | |
| masks | MASK | — | |
| stitch | DOGMA_STITCH | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| info | STRING | — |