图像分区 · 基础批量区域裁块
How to hand a big image to a small model without losing your mind
- image
- plan
- protection_mask
- tile_images
- ownership_masks
- protection_crops
- x
- y
- width
- height
- grow
- blur
- tile_index
- report_json
The wall you hit with local editing on a big image is boring and universal: your model takes 1024px happily, your image is 3000px wide, and there are five separate targets spread across it. You can't fit the whole thing in one pass, and hand-cropping five regions is how you end up with five different resolutions and five coordinate mistakes. RegionEditBasicTileBatchPrepare is the part of the Region Edit Toolkit that does that drudge work for you.
It takes a tile plan (a REGION_TILE_PLAN from RegionEditTilePlanner, which does the actual "where do the tiles go" thinking) and turns it into a dynamic batch of actual crops - images, ownership masks, protection crops, and coordinates - that you can fan out into an edit pass and later merge back with RegionEditTileMerge. This is the "big image, multiple targets" workflow the pack's README sketches: target mask → RegionEditTilePlanner → this node → process each tile → RegionEditTileMerge.
How it works
The plan you feed it is a list of tile rectangles with an ownership mask per tile (which pixels belong to this tile's edit and no other). This node just executes the plan: for each tile it crops the source image at native resolution, crops the matching protection-mask slice, and attaches the x, y, width, height you'll need later for exact compositing. It also assigns each tile a grow (how far the editable region expands beyond the tile bounds) and a blur (edge feather). In the basic version, blur is derived from grow (grow // 2 + 1), which is why you get both as list outputs even though you only set one.
The defaults are sane because the planner already sized the tiles. The one thing you're really choosing here is default_expand - 128, 192, 224, or 256 px of context around each tile's edit region. 128 is the conservative "small model" option; 256 gives the model more room to breathe but eats more VRAM per tile. The RegionEditTileControlPreset node exists to drive the controlled variant with these numbers; the basic node keeps it simple.
The one input that trips people up
tile_expansion_overrides. It's a text box that takes per-tile overrides like 2=192,5=256 - tile number 2 gets 192px, tile 5 gets 256px, everything else uses the default. Tile numbers are 1-indexed and must match the planner's preview. Get the tile number wrong and it throws rather than guessing. Leave it empty for uniform expansion.
Everything else is pass-through: image and plan must match dimensions or it errors, and protection_mask is cropped per-tile so protected regions survive the tiled edit intact.
Outputs
Ten of them, all lists except the report: tile_images, ownership_masks, protection_crops, x, y, width, height, grow, blur, tile_index, plus report_json. The pattern to learn: feed tile_images through your edit pass (Klein, inpainting, whatever), then hand the edited tiles back together with the original x/y/width/height and ownership_masks to RegionEditTileMerge. If you edit a tile and change its resolution, everything downstream screams at you - which is the pack's way of saying "resize it back first."
Install
ComfyUI Manager → search "Region Edit Toolkit" (package ID native-region-tile-planner-merge) → install → restart. Or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into ComfyUI/custom_nodes, then pip install -r requirements.txt into ComfyUI's Python (portable installs: ComfyUI_windows_portable\python_embeded\python.exe), restart. Python 3.10+, deps are numpy/Pillow/scipy/argostranslate. No bundled models.
Gotchas
This node is a plan-executor, so 90% of its problems are really the planner's. The classic beginner mistake is thinking the tiles are independent images you can do anything to - they're not; they're aligned slices with ownership boundaries, and the seam between two tiles is deliberately generated by both tiles so the merge has nothing to bridge. Edit them at native resolution, don't resize, and let the merge do its job.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| plan | REGION_TILE_PLAN | — | |
| protection_mask | MASK | — | |
| default_expand | COMBO | 128 | 4 options: 128, 192, 224, 256 |
| tile_expansion_overrides | STRING | 例如:2=192,5=256;块号与分块预览一致并从1开始。留空表示全部使用默认值。 |
Outputs (11)
| Name | Type | Description |
|---|---|---|
| tile_images | IMAGE | — |
| ownership_masks | MASK | — |
| protection_crops | MASK | — |
| x | INT | — |
| y | INT | — |
| width | INT | — |
| height | INT | — |
| grow | INT | — |
| blur | INT | — |
| tile_index | INT | — |
| report_json | STRING | — |