Nodes/opencv-comfyui/OpenCV convertScaleAbs_0
ComfyUI Node

OpenCV convertScaleAbs_0

ConvertScaleAbs

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV convertScaleAbs_0
  • src
  • dst
  • nparray
alpha
beta

Every pack like this has one node that's secretly the useful one, and for opencv-comfyui, convertScaleAbs_0 is it. It's the classic OpenCV contrast-and-brightness trick, wrapped for the graph: the node computes dst = saturate_cast<uchar>(|alpha * src + beta|) across every pixel. In English: alpha scales the values (contrast), beta shifts them (brightness), and the result gets clipped and abs'd into a proper unsigned-byte image. Set alpha = 1.0, beta = 0.0 and you get your image back unchanged - bump alpha to 1.5 for punchier contrast, add a little beta to lift the shadows.

Unlike half the nodes in this pack, this one is friendly in exactly the ways that matter. Inputs are src (NPARRAY), alpha (FLOAT), beta (FLOAT). Output is a single nparray that's uint8 - meaning it is a real image and it converts back to a viewable IMAGE through Nparrays2Image without drama. It's the node for "this render came out washed out, fix it inline" - a quick tonal adjustment you can drop into any post-processing chain, and it's exactly the kind of small, fast OpenCV operation the author says these nodes are for.

It's also a workhorse for intermediate stages: after a filter has pushed values out of display range, convertScaleAbs_0 normalizes them back into 0–255 where the next node can see them. If you ever get a black screen where there should be an image, this is frequently the fix - the values were there, just out of range.

The two numbers that matter

  • alpha - multiplicative gain. < 1 dims/dulls, > 1 boosts contrast. Your contrast knob.
  • beta - additive offset, applied after scaling. Your brightness knob.

That's the whole UI. The optional dst input is an OpenCV out-parameter; skip it like the README tells you.

Install

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib

Or ComfyUI Manager → opencv-comfyui → restart. No model files.

Troubleshooting

  • The saturate_cast<uchar> part is why the output is an image and not a float mess - the abs and clamp make negative values fold up rather than crash. That's a feature, but it means alpha and beta are tuned by eye, so expect to iterate.
  • Colors: remember this pack speaks BGR, not RGB. Feed it through Image2Nparray (batch size 1 only) and convert back with Nparrays2Image - if a hue looks swapped, that's the color-order bridge, not this node.
  • convertScaleAbs_0 and _1 are the identical two-overload pair (MatLike vs UMat in the type definitions). Same node, two names; either works.

If you only install one node from this pack, this is the one that'll actually earn its place in a workflow.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
srcNPARRAY
alphaFLOAT
betaFLOAT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY