Nodes/ComfyUI-YogurtNodes/Crop Image By Regions (Yogurt Nodes)
ComfyUI Node

Crop Image By Regions (Yogurt Nodes)

Crop only the regions your mask wants repainted — dynamic, not fixed

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
Crop Image By Regions (Yogurt Nodes)
  • image
  • masks
  • region_info
  • images
  • edit_masks
  • blend_masks
  • object_masks
  • region_info

Masked inpainting has one golden rule, and the knowledge base states it plainly: crop a small region, render it at the model's native resolution, paste it back. A 64px eye gets 1024px of generation budget. The catch is doing that for multiple regions at once, where each one needs its own crop, its own mask, and its own blend edge. Crop Image By Regions is the node that makes the multi-region version work: feed it your image, a per-object mask batch, and region metadata, and it returns a batch of crops plus the masks you need to repaint and re-blend them.

How it fits the pipeline

It's the middle step in a four-node family this pack ships for region-based repainting:

Mask Region PlannerCrop Image By Regions(repaint the crops)Composite Repaint Regions

Mask Region Planner takes a mask batch and plans fixed-size tiles around each region, producing region_info (a DICT). You also run Split Mask to turn one combined mask into a batch with one item per connected component - that's the masks input. Crop Image By Regions then cuts each region out of the full image at the planned size, producing a batch where every item is a self-contained repaint job. You run those crops through your sampler (usually with the crop's own edit mask), and Composite Repaint Regions stitches them back onto the base image using the blend masks this node also produces.

Inputs

  • image - the original full image.
  • masks - the split mask batch that matches the regions in region_info (one item per region).
  • region_info - the planning dict from Mask Region Planner.

Outputs

  • images - the crops, one per region. These go to your repaint step.
  • edit_masks - the masks that define what to actually repaint inside each crop.
  • blend_masks - soft-edge masks for blending the repainted crop back seamlessly - feed these to Composite Repaint Regions.
  • object_masks - the per-object masks, kept separate.
  • region_info - passed through so Composite Repaint Regions knows where each crop came from.

Install

Standard Yogurt Nodes install. ComfyUI Manager → search "ComfyUI-YogurtNodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes && pip install -r requirements.txt

Then restart ComfyUI. Pure tensor work - no models to download.

Where people get burned

The wiring is unforgiving: the masks input must match the regions in region_info, and if the order or count disagrees, the crops come out misaligned with their masks and the composite step puts things back in the wrong places. Keep the family's outputs labeled and don't reorder the mask batch between nodes. Second, understand what "dynamic" buys you: because Mask Region Planner sizes tiles to the mask rather than using one fixed crop box, small regions don't waste generation budget on empty canvas - but that also means the crop resolution varies per region, so your sampler needs to handle per-item resizing or you lose the "native resolution" benefit the whole technique exists for. And remember the honest tradeoff from the broader inpainting picture: for a single fix, a plain inpaint with padding is simpler; this pipeline earns its complexity when you're fixing many objects across one image and you want each one rendered at full budget.

CategoryYogurtNodes/Masks

Inputs (3)

NameTypeDefaultDescription
imageIMAGEOriginal image.
masksMASKSplit mask batch used by region_info.
region_infoDICTRegion info from Mask Region Planner.

Outputs (5)

NameTypeDescription
imagesIMAGE
edit_masksMASK
blend_masksMASK
object_masksMASK
region_infoDICT