Nodes/Region Edit Toolkit/图像分区 · 图像扫描窗口
ComfyUI Node

图像分区 · 图像扫描窗口

Scan a huge image with SAM3 without resizing it into mush

By Liu-Bot24·Created 2 months ago·Updated about a month ago· 1
图像分区 · 图像扫描窗口
  • image
  • windows
  • x
  • y
  • width
  • height
  • report_json
window_size1536
overlap384

Here's the problem this node solves: your image is 4000px wide, SAM3 has a practical window it scans well, and if you shrink the whole image to fit that window you lose the small stuff - a face that's 100px of a 4000px frame becomes 25px of a 1000px frame and stops being findable. RegionEditImageGridWindows splits a native-resolution image into overlapping scan windows without resizing anything, so you can run your detector over each window at full detail and stitch the results back.

It's the "sweep the scene" node in the Region Edit Toolkit's Selection group, and it's the pair to RegionEditDetectionsToRegionCrops (crops) and RegionEditWindowMaskMerge (merging per-window masks back to the full frame). The README's multi-target flow is: mask → tile plan → batch prepare; for detection the flow is: this node → detect in each window → merge. The overlap is what makes it work: without it, an object sitting on a window seam gets sliced and detected as two broken halves.

How it works

window_size (default 1536) is the size of each scan window; overlap (default 384) is how much adjacent windows share. The node walks the image in a grid - window step = window_sizeoverlap - emitting windows at every position. Overlap of 384 on a 1536 window means 25% shared context, which is enough that SAM3 (or whatever you feed the windows to) sees each object whole in at least one window. Windows are emitted at native resolution, never resampled.

Outputs are a dynamic list: windows (the images), and parallel x, y, width, height lists in lockstep. That coordinate contract is the whole point - when your detector returns boxes for a window, you offset them by the window's origin to get full-image coordinates, then feed them to RegionEditDetectionsToRegionCrops or merge masks with RegionEditWindowMaskMerge. report_json summarizes the grid.

Inputs that matter

  • window_size - match it to your detector's happy zone. 1536 is a good default for SAM3-class models; raise it if your detector handles bigger.
  • overlap - the seam insurance. Too little (say, 64px) and objects on seams get cut; too much (say, 1024) and you're re-detecting the same content four times, wasting VRAM and time. 25% of window size is the sane starting point.

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, pip install -r requirements.txt into ComfyUI's Python environment, restart. Python 3.10+, deps numpy/Pillow/scipy/argostranslate. No models bundled.

Gotchas

The duplicate detection problem is real and it's yours to manage: the same object will appear in multiple overlapping windows, so your downstream dedup matters. That's exactly what deduplicate_iou on RegionEditDetectionsToRegionCrops is for - run that node on the concatenated detections and it'll collapse the duplicates. And don't confuse this with a tiling/editing node: it doesn't generate anything, it just makes windows for detection. Editing the whole image in chunks is RegionEditTilePlanner + RegionEditBasicTileBatchPrepare's territory, and mixing the two up is the classic way to end up with a stitched Frankenstein image.

CategoryRegion Edit Toolkit/Selection

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
window_sizeINT1536256–16384
overlapINT3840–4096

Outputs (6)

NameTypeDescription
windowsIMAGE
xINT
yINT
widthINT
heightINT
report_jsonSTRING