Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Mask Center Hole XY
ComfyUI Node

EmAySee Mask Center Hole XY

Punch a rectangle out of the middle of your subject

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Mask Center Hole XY
  • mask
  • MASK
hole_width25
hole_height150

The "leave an outline" mask

EmAySee_MaskCenterHoleXY takes a mask and removes the middle: it finds the center of your masked region, then zeroes out a hole_width × hole_height rectangle there. What comes out is your original mask with a hole punched through its center - a ring/outline shape instead of a filled blob. The defaults say it all: hole_width 25, hole_height 150, which is a tall skinny slit - the sort of shape you'd use to cut a vertical gap through a subject.

This is a niche but real mask-operation, and it lives in the classic mask-arithmetic toolbox: the kind of thing people reach for when building inpaint regions, applying masked styling, or composing "keep the subject's silhouette but blank the torso" layouts. In the mask-based inpainting world (which still uniquely owns bit-identical unmasked pixels), punching a hole in the middle of a selection is how you force a regeneration of just the central region while everything else stays put.

How it works

The interesting detail: the "center" is not the image center - it's the center of the mask's bounding box, computed from the min/max of pixels above 0.5. So the hole lands in the middle of whatever you selected, wherever that is in the frame. It then zeroes a hole_width×hole_height rectangle centered on that point, clamped to the mask's edges so it never goes out of bounds. If both dimensions are zero or below, the mask is returned unchanged. It's simple, deterministic, and per-batch-frame: multi-frame masks each get their own hole centered on their own bounding box.

Inputs and output

  • mask (MASK) - the selection to punch through.
  • hole_width (INT, 0–8192, default 25) - width of the removed rectangle.
  • hole_height (INT, 0–8192, default 150) - height of the removed rectangle.

Output: MASK - the mask with the hole zeroed out.

Install

From ComfyUI_EmAySee_CustomNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
# restart ComfyUI

Or via ComfyUI Manager → "ComfyUI_EmAySee_CustomNodes". No dependencies.

Gotchas

The bounding-box behavior is the main surprise - if your mask has multiple disjoint blobs, the "center" is the center of the overall bounding box, so the hole can land in empty space between blobs. And it only removes mask; there's no mode to keep just the hole. If you want that inverted result, flip it with a MaskInvert after. Also remember the coordinates come from the mask's own resolution, so a 25×150 hole on a 512×512 mask is a lot bigger relative to the image than the same values on a 2048 mask - tune per resolution. If your downstream wants an image rather than a mask, the pack's EmAySee_MaskGuard will convert it.

CategoryEmAySee/Mask

Inputs (3)

NameTypeDefaultDescription
maskMASK
hole_widthINT250–8192
hole_heightINT1500–8192

Outputs (1)

NameTypeDescription
MASKMASK