OpenCV applyColorMap_0
OpenCV applyColorMap_0
- src
- dst
- nparray
applyColorMap_0 is the heatmap node. It takes a grayscale image and maps every brightness level to a color from a built-in palette - so a depth map becomes the familiar blue-to-red "terrain" look, a saliency map becomes a glow-y rainbow, a mask becomes an intensity plot. If you've ever seen a depth-estimation demo where the distance is rendered as a smooth gradient of colors, this is the exact function producing it: cv2.applyColorMap(src, colormap).
In a ComfyUI pipeline this is the display-and-diagnose node. Depth maps from MiDaS-class estimators, disparity maps from stereo, attention or saliency maps - all of them are grayscale, all of them read way better as a heatmap when you're trying to see what the model actually thinks is close, or what region it's focusing on. It costs nothing, changes nothing about the underlying data, and makes an unreadable gray blob into something you can actually look at. That alone earns it a spot in your debugging graph.
How it works
The node wraps cv2.applyColorMap(src, colormap). The src is your grayscale (single-channel) image, and colormap is an integer selecting one of OpenCV's 23 predefined palettes (0–22). The ones you'll actually use:
- 2 (JET) - the classic blue→cyan→green→yellow→red rainbow. The default heatmap for depth.
- 12 (PARULA) - the modern perceptual alternative; smoother, less banded.
- 11 (HOT) - black→red→yellow→white, great for intensity/masks.
- 16 (VIRIDIS) - the colorblind-safe choice.
Any value 0–22 works; the rest are variations on the same idea (BONE, RAINBOW, OCEAN, TURBO, DEEPGREEN…). Pick by taste, switch to 2 when you want the look everyone recognizes as "depth".
The inputs that matter
- src (NPARRAY) - the grayscale image to colorize.
- colormap (INT) - which palette; 0–22, with 2/12/11/16 the useful ones.
- dst (NPARRAY, optional) - out-parameter; skip it.
Output: one nparray - the colorized image, ready for Nparrays2Image.
Wiring it up
IMAGE → Image2Nparray → cvtColor (code=6, BGR2GRAY) → applyColorMap_0 → Nparrays2Image. If your grayscale already came from a node that outputs single-channel data you can skip the cvtColor, but for ordinary RGB input you need the gray conversion first. The colorized result comes back through Nparrays2Image's channel handling, so it displays as normal RGB.
Installing opencv-comfyui
ComfyUI Manager → search "opencv-comfyui", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Restart ComfyUI. Dependency: opencv-contrib-python.
Gotchas
- Feed it grayscale - an RGB input colorizes in a way that looks wrong (it maps each channel independently and then merges). Convert with cvtColor first.
colormapis an int, not a name - this pack doesn't give you dropdowns; you type2for JET. The README openly says the enum-as-COMBO is on the todo list.- Batch_size == 1 - use
ImageFromBatchfor batches.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| colormap | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |