Nodes/DOGMA Nodes/DOGMA v54.2 HD Opaque-Core Stitch
ComfyUI Node

DOGMA v54.2 HD Opaque-Core Stitch

Paste at native resolution, resample nothing twice

By axior·Created 4 months ago·Updated 3 days ago· 1
DOGMA v54.2 HD Opaque-Core Stitch
  • base_image
  • patches
  • masks
  • stitch
  • image
  • info
category
kind

Every stitch node in this pack resamples the patch to fit the rectangle it came from, and every resample costs you sharpness. DOGMARegionStitchV542 is the version that noticed the obvious thing: if the chunk was generated at exactly the master resolution it's going back into, don't touch the pixels at all.

Its class docstring lists the three rules, and they're worth reading as a summary of everything the earlier stitches got wrong: "strips model-only /16 padding; avoids any resample when the chunk ran at native post-Stage-2 resolution; uses a fully opaque slightly-expanded semantic core; feathers only a few final/master pixels OUTSIDE that core."

The mechanism, rule by rule

Strip the padding first. The stitch metadata can carry pad_right and pad_bottom - padding added to make a chunk a multiple of 16 for the latent grid. The node crops those columns and rows off the patch and mask before anything else, so you never paste replicated padding pixels into your master.

Resample only if you have to. If the patch is already exactly height × width, it's used as-is and counted as native. If it isn't - because a small chunk was enlarged so the model had something to chew on - it's brought back with bicubic, antialiased, and counted as resized. Both numbers are reported in info, so you can see at a glance whether your pipeline is doing a needless round trip.

Opaque core, grown by kind. The mask is thresholded at 0.20 for objects, 0.28 for structures, 0.34 for surfaces, then dilated by 3, 2 and 1 pixels respectively. That growth is deliberate: an object repair often needs to push a corrected silhouette a few pixels past the old mask boundary, and a naive core would clip it right there - the "corrected shape with its edge chopped off" artefact.

Feather outside only. Alpha is max(core, blur(core) × 0.90) with a 6px feather for objects (8 for structures, 10 for surfaces). Because of the max, every pixel inside the semantic core is 100% generated, and the ramp exists purely in the few pixels beyond it. No translucent band across the object, no double-image halo, no low-definition "pasted patch" ring.

The tradeoff against the region-safe soft stitch is exact and worth naming: this one gives you a crisp, fully-generated object with a narrow transition, and a hard-ish edge if your mask is wrong. The soft one gives you no visible edge and a 4–28% blend of original pixels throughout the repair. Cars and lamps: this node. Sky and road: the soft one.

Inputs and outputs

base_image, patches, masks, stitch, category, kind in; image and info out. The category and kind strings are canonicalised inside the node and select the threshold/grow/feather triple, so they must match what the crop side used. info reads like a small report card:

v54.2 HD stitch | cars [OBJECT] | 12 region(s) | opaque core grow 3px / feather 6px | 12 native no-resample, 0 enlarged-small chunks reduced back

Install

ComfyUI Manager → search DOGMA Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
# restart ComfyUI

No dependencies, no downloads. As with every semantic node in the pack, the README doesn't mention it.

Gotchas

Zero native in the info line means you're losing sharpness. If every chunk reports as resized, your generation stage isn't running at master crop size - often because the crop was upscaled for the model and never brought back. Check the crop node's target_long_side against your master resolution.

The 3px growth is not a cure for a bad mask. It buys you a little slack around a corrected silhouette; it won't cover a mask that missed half the wheel.

pad_right/pad_bottom only exist if something upstream put them there. If your crop source doesn't record padding, this node's first step is a no-op and info won't mention it - that's expected, not a failure.

CategoryDOGMA/v54.2

Inputs (6)

NameTypeDefaultDescription
base_imageIMAGE
patchesIMAGE
masksMASK
stitchDOGMA_STITCH
categorySTRING
kindSTRING

Outputs (2)

NameTypeDescription
imageIMAGE
infoSTRING