Nodes/ComfyUI-ZML-Image/ZML_遮罩描边
ComfyUI Node

ZML_遮罩描边

Outline the edge of a mask, for when you need to see where the mask ends

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_遮罩描边
  • 遮罩
  • 图像
  • 遮罩描边
  • 描边图像
描边大小3

A mask outline generator that's mostly about seeing - you feed it a mask, it finds the edges, and hands you both a clean stroke mask and a red-outlined image so you can actually eyeball where your mask boundary is.

That second output is the sleeper feature. Masks are invisible by themselves; when you're debugging why an inpaint is feathering in the wrong place or why a detailer is cropping the wrong region, drawing the boundary over the real image tells you in one glance whether your mask is too big, too small, or drifting. This node exists so you don't have to build that visualization by hand.

How it works

The node is pure PIL, no OpenCV involved. It takes the mask, runs ImageFilter.FIND_EDGES to locate the boundary, and then - this is the thick-stroke trick - repeatedly applies MaxFilter(3) (a 3×3 maximum filter, which is morphological dilation) 描边大小 - 1 times. More dilations, thicker outline. 描边大小 is 1–20, default 3.

Then it does its two outputs:

  • 遮罩描边 - the edge-only mask (dilated). This is the "just the outline" output, a MASK you can wire into other mask consumers if you want, say, to inpaint only along a contour.
  • 描边图像 - an IMAGE with the outline drawn in red. If you provided the optional 图像 input, the red stroke is composited over that image. If you didn't, you get the stroke on a black background - which is genuinely useful on its own, because you get a high-contrast version of your mask's silhouette with nothing else to distract you.

So: no 图像 input → a black-background red-silhouette image; 图像 input → your image with a red boundary painted on it.

The inputs that matter

  • 遮罩 - the MASK to outline.
  • 描边大小 (1–20, default 3) - outline thickness. A single dilation pass is fairly chunky already; start at 3, drop to 1 if you want a hairline.
  • 图像 (optional) - the image to draw the outline over. Leave unconnected for the black-background silhouette.

Outputs: 遮罩描边 (MASK) and 描边图像 (IMAGE).

Where it fits

Use it in the mask-debugging stage of any detect-and-detail workflow. The KB's detailing doc makes the point that the mask is the thing you're always iterating on - too much mask and the re-render bleeds, too little and it misses the face. A node that draws the boundary over the source image is the fastest way to sanity-check that loop. It's also just handy for annotation, diagrams, and the pack's own text-image / watermark tooling where an outlined region reads better than a solid fill.

Install

Part of ComfyUI-ZML-Image, installed once for the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
# restart ComfyUI

or via ComfyUI Manager → search "ComfyUI-ZML-Image". Requires Pillow, which the pack installs as a baseline (this node doesn't touch the OpenCV/ultralytics dependencies, so it stays light). Chinese-first UI; grab the translation patch at https://github.com/zml-w/ZZZ_ZML_English_Patch if the labels are Greek to you.

The author flagged this node as a deliberate addition in the 2025.10 update notes ("新增了遮罩描边节点") - it's one of the more recent tools in the pack, but the implementation is simple enough that it doesn't have the rough edges some of the heavier UI nodes carry.

Categoryimage/ZML_图像/遮罩

Inputs (3)

NameTypeDefaultDescription
遮罩MASK
描边大小INT31–20
图像optIMAGE

Outputs (2)

NameTypeDescription
遮罩描边MASK
描边图像IMAGE