Mask: Preview Overlay
You Can't Debug a Mask You Can't See
- mask
- image
- preview
A raw MASK in ComfyUI is an unlabelled grey image. Is the subject white-on-black or black-on-white? Is that halo a soft edge or a hole? You can't tell from a thumbnail, so people run the whole workflow, look at the finished composite, spot a grey rim around the hair, and go back to guess at where the mask went wrong. This node exists to stop that loop.
Mask: Preview Overlay (class JHPixelProMaskPreview) renders any mask four different ways on top of your photo. It's the visual-debugging half of the pack, and the piece I'd install first, because every other mask node in PixelPro is easier to trust once you can see what it produced.
What each view is actually for
Four modes, and they answer four different questions:
overlay- the photo tinted where the mask is on. This is your "did it cover the right thing" check.heatmap- mask values run through a colormap, so 0 is cold and 1 is hot. This is the one people underuse. Any feather, any gradient, any half-on value shows up as colour you didn't expect. If you're trying to work out how wide the soft band from a refiner actually is, heatmap tells you in one look.mask_only- plain greyscale. For when you just want the mask, like Photoshop's quick mask.cutout- the photo shown only where the mask is on, over an 8-pixel checkerboard. This is how you catch halos: a light fringe that vanishes against a bright background shows up loudly against grey checks.
That cutout mode is why the node earns a slot in a retouch graph rather than being a nicety. Inpainting and background swaps fail at the edges, and edges are exactly what a flat preview hides.
The inputs you actually touch
mask is the only required wiring. Then three settings do most of the work: mode, color (eight options, red through black - pick something that contrasts with your photo, cyan on a blue sky is useless), and opacity, which sets how hard the tint sits, default 0.5. colormap only matters in heatmap mode and takes Kornia's colormap names, so turbo, viridis, jet, magma and the rest are all there; the list is generated from the installed Kornia, so it won't drift.
show_edges draws the 0.5 contour of the mask as a one-pixel line in your chosen colour. Turn it on when you're comparing two masks - run the node twice, once per mask, in two colours - or when you want to see how tightly a segmenter hugged the subject.
The optional image is the background. Leave it unconnected and you get neutral grey (or, in heatmap mode, the bare colormap with nothing mixed in), which is genuinely useful for judging shape without the picture arguing with you.
One output: preview, an IMAGE. Wire it into a Preview Image or Save Image node - it is not itself an output node. And do not feed preview back in as a mask; it's an RGB picture now.
How it works
Mechanically it's all cheap arithmetic on GPU tensors. Overlay lerps the photo toward the tint by opacity × mask. Heatmap applies the Kornia colormap to the mask and blends that over the photo at opacity. Cutout mixes the photo and the checkerboard by the mask. The edge line is a one-pixel band from a dilation minus erosion of the mask thresholded at 0.5 - so it sits exactly on the boundary you'd call the boundary.
Batches behave sensibly: a batch of 1 on either side broadcasts against the other. Sizes must match exactly, though - no auto-resize, so if the image and mask come from different branches of the graph, check that a resize didn't slip in between them.
Install
ComfyUI Manager, search ComfyUI-JH-PixelPro, install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/ComfyUI-JH-PixelPro.git
cd ComfyUI-JH-PixelPro
pip install -r requirements.txt # the Python that runs ComfyUI, not some other env
Then restart ComfyUI and look under Add Node → ComfyUI-JH-PixelPro → mask. The pack is 64 nodes (Apache-2.0, one maintainer, @jetthuangai) pulling in Kornia, MediaPipe, OpenCV headless and SciPy - nothing model-based for this particular node, so no download.
Worth knowing up front: this pack has essentially no community trail yet. Searching the usual subreddits turns up nothing for the pack name, which means no crowd-sourced "here's the fix" threads. The trade-off is that it also ships per-node docs (English and Vietnamese) with test counts behind them, so read those rather than assuming it behaves like the node you used from another pack.
Common issues
Nothing shows up. You connected preview to nothing, or to a node that expects a MASK. It's an image; give it a Preview Image.
"image spatial size ... must match mask". Your mask is a different resolution. Very common when the mask came through a resize or was built at proxy size by a segmenter. Resize it back, or preview without image.
Mask looks inverted from what you expected. That's not a bug you can see in grey - you're probably used to a different convention. In this pack the pipeline convention is white = 1 = selected, e.g. Sky Mask and SAM both return the selection as 1. If your mask came from a node that returns a protection mask, you're previewing the inverse of what you think. The overlay makes that obvious immediately, which is the point.
Heatmap looks blown out. Overlay opacity also scales the heatmap blend. Push it to 1.0 for maximum saturation when you're reading values rather than judging the picture.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | Mask to visualise. | |
| mode | COMBO | overlay | overlay = colour tint, heatmap = colormap of mask values, mask_only = greyscale mask, cutout = image over checkerboard. |
| color | COMBO | red | Tint colour (overlay) and edge colour. |
| opacity | FLOAT | 0.500–1 | Overlay strength (overlay and heatmap modes). |
| colormap | COMBO | turbo | Colormap used by heatmap mode. |
| show_edges | BOOLEAN | false | Draw the 0.5 mask contour in the chosen colour. |
| imageopt | IMAGE | Background image. Omit for a neutral grey background. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| preview | IMAGE | — |