OpenCV sqrt_0
Square roots, pixel by pixel — finish the variance recipe
- src
- dst
- nparray
sqrt_0 takes the square root of every pixel. That's the whole node. And if that sounds too trivial to bother with, you're missing the trick: on its own it's nothing, but as the second half of a two-node pipeline it's how you turn OpenCV's raw stats primitives into something you can actually use.
The pairing that matters is with sqrBoxFilter_0. That node gives you the window-averaged square of the pixels (a mean of squares). Run that output through sqrt_0 and you get the root-mean-square - a smooth, local "how much energy is in this neighborhood" map. Subtract the plain boxFilter mean squared first and then sqrt_0 gives you local standard deviation, which is the classic contrast/detail map used to weight sharpening or denoising by local texture. There's no "Local Contrast" convenience node in this pack - everything is the raw cv2 function - so this is the raw function that completes the recipe.
Inputs and output. It takes one required input, src (NPARRAY), plus an optional dst that you should leave alone - the author's README calls out the optional out-parameters as the thing to avoid. Output is a single nparray. Remember: no ComfyUI IMAGEs here. Feed it Image2Nparray output (BGR, uint8, 0–255) and convert the result back with Nparrays2Image before you try to preview it.
Two small honest caveats. First, precision: Image2Nparray hands you uint8 arrays, and cv2's square root behaves best on float input - convert to float32 upstream if you're building a variance map you'll actually use numerically. Second, anything negative or NaN in the input quietly produces a NaN/garbage output rather than an error, so make sure your upstream subtract actually went through a saturating node like subtract_0 rather than raw numpy territory.
Install. Grab it via ComfyUI Manager (search "opencv-comfyui"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Restart. Requirements are opencv-contrib-python, numpy, torch - if OpenCV is missing, pip install opencv-python-contrib, and if you see Cannot import name 'guidedFilter' from 'cv2.ximgproc', sort out the duplicate OpenCV installs first. And sqrt_1 is this node's identical twin, so don't go hunting for a difference - there isn't one.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |