OpenCV applyColorMap_3
Give your grayscale a paint job with a custom OpenCV colormap
- src
- userColor
- dst
- nparray
If you've ever stared at a grayscale depth map or a raw mask and thought "this would be way easier to read in color," this is the node. applyColorMap_3 takes a single-channel image and recolors it through a lookup table - turning gray levels into a heatmap, a thermal look, a false-color glow, whatever palette you hand it. The _3 tells you it's one overload of OpenCV's cv2.applyColorMap, and this particular overload is the interesting one: instead of picking from OpenCV's built-in colormap integers, it lets you supply your own 256-color map.
The pack this ships in, opencv-comfyui, auto-generates a wrapper for every top-level OpenCV function, so the node is ugly and the author warns you to expect dragons. But the underlying function is rock-solid and useful: it's the same pseudocolor trick used on thermal cameras, depth sensors, and every "AI heatmap" visualization you've seen.
How it works
cv2.applyColorMap(src, userColor) treats your input as an intensity image. For each pixel, its 0–255 gray value indexes into userColor, and the pixel is replaced by the color stored at that index. That's it - a lookup table, milliseconds, fully deterministic. No model, no weights, no API key.
The inputs that matter:
- src - your image as an OpenCV
NPARRAY. It must be single-channel 8-bit (grayscale). Feed it an RGB image and OpenCV throwserror: (-215:Assertion failed) img.type() == CV_8UC1. - userColor - the custom colormap: an
NPARRAYshaped(256, 1, 3)or(1, 256, 3)of 8-bit BGR triplets. Row/column 0 maps to black, row/column 255 maps to white. If you're coming from a ComfyUI mask (0–1 float), you'll need to build this as a proper OpenCV array - a 256-row gradient from black through your accent colors to white is the classic. - dst (optional) - OpenCV's out-parameter. Leave it unwired; the node allocates the output for you.
- Output is a single nparray, the recolored BGR image.
The sibling applyColorMap_2 is an identical overload (OpenCV's type stubs list the same signature twice - MatLike vs UMat), so it doesn't matter which you grab. The _0 and _1 versions are the built-in COLORMAP_* variants; _3 here is the custom-palette one, which is why you'd pick it.
Where it fits in a workflow
Feed it a grayscale depth map, a disparity map, a normal map, or an attention/heatmap and it becomes immediately readable. Wire Image2Nparray → cvtColor (code 6, BGR2GRAY) if your source isn't already single-channel → applyColorMap_3 → Nparrays2Image → preview. The Nparrays2Image step matters - everything in this pack speaks OpenCV nparray, not Comfy IMAGE, and you need that last conversion to actually see your heatmap.
Common issues
img.type() == CV_8UC1assertion - yoursrcisn't grayscale. Convert withcvtColorfirst.userColorshape errors - it has to be exactly 256 entries wide (or tall). A 255-length array is a classic off-by-one.'NoneType' object has no attribute 'shape'on the way back - you fed a non-image intoNparrays2Image. Check your wiring, not the node.
Colors here are BGR, so a red-hot palette ends in (0, 0, 255)-style triplets - easy to get backwards if you're used to RGB. Worth one test render before you commit to the palette you hand it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| userColor | NPARRAY | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |