OpenCV pow_0
OpenCV pow_0 and the per-pixel exponent
- src
- dst
- nparray
pow_0 does one dumb, powerful thing: it raises every pixel of an image to a power. output = input^power, applied across the whole array, with no model, no weights, no fuss. It's cv2.pow wearing a ComfyUI jacket, from the opencv-comfyui pack that auto-generated ~635 of these thin wrappers from OpenCV's Python stubs.
And yes - "raise every pixel to a power" is the entire mechanism of gamma correction. If you've read any guide to fixing flat images, you've seen gamma. This is the math under it: a power curve lifts shadows or crushes them while leaving white untouched. The KB's post-processing notes make exactly this point - gamma (output = input^gamma) is the operation people actually want when an image looks flat, and it beats additive brightness because it doesn't blow out highlights. pow_0 is that operation, exposed as a raw power rather than a friendly "gamma" slider.
How to use it
Two required inputs:
src(NPARRAY) - your image array.power(FLOAT) - the exponent.
The rule of thumb: power < 1 brightens shadows, power > 1 darkens and boosts contrast. Since gamma is usually written as input^(1/gamma), a gamma of 2.2 corresponds to a power of about 0.45. So if someone says "apply gamma 2.2," you set power to 0.45. If you want the look of a contrastier, punchier image, try 1.5–2.0. These are deterministic, millisecond, zero-model operations - exactly the move the KB recommends over re-rolling a generation because "the colors are off."
The optional dst input is an OpenCV out-parameter; the README's standing advice applies - leave it unconnected.
The trap that will actually bite you
cv2.pow requires a floating-point source. A uint8 BGR array - which is exactly what Image2Nparray hands you (it scales your ComfyUI 0..1 RGB tensor to 0..255 BGR uint8) - will be rejected. Feed it uint8 and you'll get a type assertion error, not a friendly message.
You have two ways around it. Convert the array to float first (an astype-style operation, or use an OpenCV conversion that yields CV_32F), then remember that on a 0..255 float range a power curve behaves like classic gamma on normalized values - and, crucially, that values above 1.0 grow the brighter they get, so big exponents can blow out highlights fast. Or work in the normalized 0..1 world. Either way, make sure Nparrays2Image gets something it can display (BGR or grayscale), or you'll hit its "NoneType object has no attribute shape" complaint about non-image arrays.
Install
Same as every node in this pack. ComfyUI Manager → search "opencv-comfyui", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
restart ComfyUI, then:
pip install opencv-contrib-python
Chain it as IMAGE → Image2Nparray → pow_0 → Nparrays2Image → IMAGE, and remember Image2Nparray only handles batch_size==1 - use ImageFromBatch (length 1) if you get the batch error.
Where it fits
If you just want to brighten a dark image, honestly, a dedicated gamma node from a friendlier pack is less fiddly. But pow_0 shines when you want precision - a specific exponent, per-channel work, or a power curve that's part of a larger math chain (flow magnitudes, mask scaling, exposure math). It's the raw ingredient. Know what power maps to what look, feed it float, and it's a genuinely useful little node. There's also pow_1, an identical twin generated from a second overload - pick either.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| power | FLOAT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |