DOGMA Sector Crops v26 — Grouped High Resolution
Few big crops, cut at full resolution
- image
- reference_image
- masks
- crops
- reference_crops
- crop_masks
- stitch
- info
Every automatic detailing loop needs one honest moment: cutting the region out of the image. Get it wrong and no amount of clever stitching saves you. Crop too small and the model has no context; crop per-instance and a crowd becomes twenty jobs; crop at the wrong resolution and you're feeding the model interpolated mush.
Sector Crops v26 is the pack's cropper for grouped, high-resolution regions. Its docstring is the pitch: V21 spatial grouping with native-resolution preservation up to ~3.6MP / 2560px.
How it works
Give it the current master (image), the original source (reference_image) and the masks (masks). It takes the union of all masks, thresholds at mask_threshold, downscales that union to a 640px preview, dilates the preview by group_radius - this is what turns scattered small blobs into one group - then finds connected components with a flood fill and sorts them by area.
Each component's bounding box gets padded by context_px of real image, then regions are merged pairwise (closest first) until there are at most max_crops. If a region is still larger than max_source_side, it's split into non-overlapping ownership windows of max_source_side - 2 × context_px. That detail matters: the windows don't overlap, so the same semantic pixel isn't edited twice, even though each crop carries context padding that does.
Then each region is cut from both the master and the reference - the reference is resized into master coordinates first, so the two crops are the same spatial location - and downscaled to target_long_side (max 2560) with a hard 3.6MP ceiling, dimensions floored to multiples of 16. If a crop is already smaller than the target, it is not upsampled. The info output reports the sizes and says whether native detail was preserved.
Inputs and outputs
The nine inputs: image, reference_image, masks, group_radius (200, i.e. how aggressively nearby blobs become one group), context_px (208, the context ring around each region), max_source_side (3200, the splitting limit), target_long_side (2560, the model's working size), max_crops (4) and mask_threshold (0.5).
For a beginner the two that matter are group_radius and max_crops. Everything else can stay put until something specific annoys you.
Outputs, all lists except info: crops, reference_crops, crop_masks, stitch, info. The stitch output is the important one - it's a list of DOGMA_STITCH dicts carrying x, y, width, height, source_width, source_height and a noop flag. That's the receipt your stitch node needs to put the repaired patch back in the right place, and it's a custom type: only this pack's crop nodes produce it, so you can't hand-feed a stitch node with a primitive.
Wire crops through your edit model, keep crop_masks as the mask input to the samplers, and pass stitch straight to DOGMASafeMaskedStitchV34 or DOGMARegionStitchV543. reference_crops is what makes crop-based editing coherent: the model gets the current (damaged) crop and the original (clean) crop of the same coordinates, which is the same alignment trick the KB's crop-edit-stitch discussion calls for and is easy to get wrong by hand.
Install
Manager → search DOGMA Nodes → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
No dependencies, no models - pure torch plus numpy, both already inside ComfyUI; the pack's requirements.txt declares nothing. Registered in DOGMA/Semantic Detailer. The mask crop math assumes Flux-friendly multiples of 16, so don't be surprised when sizes come out a few pixels off your ideal number.
DOGMA Nodes is by axior, the studio arm of a Milan production team whose commercial work runs through hundreds of ComfyUI inpaints per job. "Few big grouped crops at native resolution" is a render-budget decision from people paying for the GPU time.
Where it goes wrong
"Semantic union needs N macro crops... but max_crops=M". A real error message. The union needs more windows than you allowed, and the node refuses to discard any of them. Raise max_source_side (bigger windows, fewer of them) or raise max_crops.
No active mask. Then it returns a centred square crop with noop: True and an all-zero mask, plus No active semantic mask: safe no-op. Downstream stitch nodes skip no-op regions, so the graph runs and changes nothing. If your output is identical to your input, check this before anything else.
Crops looking soft. You asked for a target_long_side above what the region actually is - no upsampling happens, so a soft crop means the source was soft. Conversely, if you're seeing interpolation artifacts on a big region, check target_long_side; 2560 is the cap for a reason.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| reference_image | IMAGE | — | |
| masks | MASK | — | |
| group_radius | INT | 2000–1200 | — |
| context_px | INT | 2080–1024 | — |
| max_source_side | INT | 3200768–8192 | — |
| target_long_side | INT | 2560768–2560 | — |
| max_crops | INT | 41–8 | — |
| mask_threshold | FLOAT | 0.500.01–0.99 | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| crops | IMAGE | — |
| reference_crops | IMAGE | — |
| crop_masks | MASK | — |
| stitch | DOGMA_STITCH | — |
| info | STRING | — |