Nodes/Image Filter/Masked Section
ComfyUI Node

Masked Section

See Only the Part You Changed

By chrisgoringe·Created 2 years ago·Updated 2 months ago· 132
Masked Section
  • mask
  • image
  • image
minimum512

After an inpaint pass you usually want to check what actually changed - and scrolling a full-frame before/after comparison to find a small fix is a waste of attention. Masked Section takes the mask you already have and crops the image down to the bounding box of the masked region, so you can look at just the part that was regenerated. It's the pack's "show me the diff" node.

It's a quiet helper, but it slots into a genuinely good workflow: generate, mask the bad region, inpaint, then use Masked Section to preview only the fixed area side by side with the original. The README's example does exactly this - crop to the changed section so you can eyeball whether the repair blended in, without your eyes wandering across the whole frame. It also happens to be a cheap way to focus an upscale or a detail pass on just the region that matters.

How it works

Three inputs, one output:

  • mask - the mask whose bounding box defines the crop.
  • image - the image to crop. Works on a batch, cropping every frame to the same box.
  • minimum - the minimum size of the output square, default 512. If the masked region is smaller, the crop is padded outward (clamped to the image edges) to reach at least this size, so you don't get a 40-pixel sliver back.

The output image is the original image cropped to the mask's bounds (mask pixels above 0.5 count). If the mask is empty, the image passes through untouched. The minimum control is the one worth setting: too small and you can't see detail, too big and you've re-cropped half the frame.

Installing it

Part of chrisgoringe/cg-image-filter. ComfyUI Manager, search "cg-image-filter" or "Image Filter":

cd ComfyUI/custom_nodes
git clone https://github.com/chrisgoringe/cg-image-filter

Restart ComfyUI. No dependencies, no models.

Gotchas

The mask is the boss here - the crop follows the mask's bounding box, not the visible mask shape. If your mask has a stray pixel far from the real region, the crop expands to include it. And minimum pads the crop but can't extend past the image edges, so a mask right at the border produces an asymmetric crop; that's fine for inspection, just don't expect it to be centered. Feed it the mask straight out of Mask Image Filter and you get a tidy before/after of exactly what the inpaint changed.

Categoryimage_filter/helpers

Inputs (3)

NameTypeDefaultDescription
maskMASK
imageIMAGE
minimumINT51216–16384Minimum image size to output

Outputs (1)

NameTypeDescription
imageIMAGE