Nodes/opencv-comfyui/OpenCV pow_1
ComfyUI Node

OpenCV pow_1

Pow_1 — the same exponent math, minus the mystery (and what power values actually do)

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV pow_1
  • src
  • dst
  • nparray
power

pow_1 is pow_0's clone. The opencv-comfyui pack generates one node per OpenCV overload, cv2.pow declares two, and so you get two identical-looking nodes that both compute output = input^power per pixel. Same inputs - src (NPARRAY) and power (FLOAT) - same optional dst out-parameter, same single nparray output. There is no hidden difference; pick pow_1 or pow_0 and move on with your life.

So instead of re-explaining the math (it's a per-pixel power curve, the raw form of gamma - see the pow_0 article for the full mechanism), let's spend this one on the practical numbers, because that's where people actually get lost.

What the power value does, with real numbers

On a normalized 0..1 image:

  • power = 0.45 - this is "gamma 2.2." Brightens shadows a lot, whites stay put. The classic filmic lift.
  • power = 0.5 - square root curve. The standard "just lift it a touch" value.
  • power = 1.0 - identity. Nothing changes.
  • power = 1.5–2.0 - darkens midtones, increases perceived contrast. 2.0 is the square curve, punchy and slightly crunchy.
  • power = 3.0+ - crush. Only for deliberate, almost-black-shadow looks.

Here's the connection that trips people up: gamma and power are inverses. When a color-management doc says "apply gamma 2.2," the exponent you type is 1/2.2 ≈ 0.45, not 2.2. Type 2.2 expecting a gamma lift and you'll get the exact opposite - a dark, contrasty image. It's the single most common mistake with this node, and it's silent. Nothing errors; the image just looks wrong, and you blame the workflow.

The float trap (again, it matters)

cv2.pow only accepts floating-point input. Image2Nparray hands you uint8 (0..255, BGR), which pow will refuse with a type assertion. Convert to float before the node, and be aware the curve behaves differently across ranges: on 0..255 floats, values above 1.0 are exactly the brights, and a large exponent amplifies them dramatically - clipping happens fast. If you're going for a controlled gamma look, normalize to 0..1 first. And when you come back out, make sure Nparrays2Image sees a BGR or grayscale array, or you'll meet its "NoneType object has no attribute shape" error for non-image arrays.

Install

Identical to every node in opencv-comfyui: ComfyUI Manager → search "opencv-comfyui", or

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

restart, and pip install opencv-contrib-python. Chain as IMAGE → Image2Nparray → pow_1 → Nparrays2Image, batch size 1 only (ImageFromBatch fixes the batch error).

The take

If you need gamma, a purpose-built gamma node from WAS Node Suite or the Kornia-based packs is friendlier. But pow_1 gives you the raw exponent with no slider sugar-coating, and it's deterministic and free. Just remember the reciprocal relationship and the float requirement, and this becomes one of the more dependable nodes in the pack - the kind that does exactly what it says, once you know what you're asking.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
powerFLOAT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY