Mask Area Probe (C2C)
A coverage meter for your masks, especially video frames
- mask
- mask
- report
- coverage_mean_pct
- coverage_min_pct
- coverage_max_pct
Some nodes make images. This one asks questions. Mask Area Probe (C2C) is a passthrough: it returns your mask completely unchanged, plus a coverage report telling you what percentage of each frame the mask actually covers. It's a tiny diagnostic, and it's quietly the most useful thing you can stick in the middle of a video-mask workflow.
The situation it solves: you ran SAM on 200 frames, and on frame 140 the subject walked behind a tree and the mask vanished. Did you notice? No, because nobody watches 200 masks. This node turns "the mask disappeared" into a number you can act on.
How it works
For every frame it computes (mask > threshold).mean() - the fraction of pixels above your threshold - and multiplies by 100. The threshold input (default 0.5) decides what counts as "covered"; for soft alpha masks, raise it to 0.7 or 0.8 if you only care about solid coverage.
Outputs:
mask- the input, untouched, so you can splice this node into a wire without breaking the chain.report- a human-readable string: frame count, threshold, and mean/min/max coverage.coverage_mean_pct,coverage_min_pct,coverage_max_pct- the floats. The min is the interesting one: that's your worst frame. Wirecoverage_min_pctinto a text display or a conditional and you've got an automated "subject lost" alarm.
Where it shines
Video mask QA is the headline use. Feed it the output of MaskTracker or a SAM2 propagation, and a single glance at report tells you if any frame dropped. It's also handy for the opposite problem - spotting a mask that's too big (a segmentation that spilled into the background), where coverage jumps up and stays up.
There's a genuinely neat automation here: this pack has a MaskFailureExplainer for why a mask looks wrong, and this node for when it stopped covering the subject. Put the explainer on a problem frame, put the probe on the whole batch. Different questions, same workflow.
Install and notes
Pack install as usual:
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
or ComfyUI Manager → search "CustomNodePacks", restart, look for [MEC] Loaded ... in the console. No dependencies beyond torch - it's a mean over a thresholded tensor, the cheapest operation in this pack.
One caveat about interpretation: coverage is area, not correctness. A mask that covers 30% of every frame might be a perfectly tracked subject or a mask stuck on a background bush. Use it as an alarm, not a verdict - when a number changes, that's when you go look at the frame.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| threshold | FLOAT | 0.500–1 | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| report | STRING | — |
| coverage_mean_pct | FLOAT | — |
| coverage_min_pct | FLOAT | — |
| coverage_max_pct | FLOAT | — |