OpenCV sqrBoxFilter_1
The other sqrBoxFilter — no, really, it's the same node
- src
- dst
- nparray
Let me save you the confusion you're probably feeling right now: sqrBoxFilter_1 is the exact same node as sqrBoxFilter_0. Same inputs, same output, same generated wrapper, same OpenCV function behind it. I checked the source - the two classes are copy-paste identical apart from the name suffix. The _1 isn't a "newer version" or a "faster variant"; it's just what happens when you auto-generate one node per overload from OpenCV's type stubs and the generator doesn't bother deduplicating. Pick whichever you like and never think about the suffix again.
So what does it actually do? It's the local-variance building block: it computes, for each pixel, the sum (or mean, with normalize on) of the squared pixel values in a rectangular window. Where a normal box blur averages x, this averages x². That's the first half of variance, which makes it the workhorse for texture/detail maps, local standard deviation, and contrast-weighted effects. Pair the output with sqrt_0 and you've got root-mean-square; subtract a plain boxFilter mean squared and take sqrt_0 again for true local std. It's the raw material behind a lot of "detail enhancer" nodes, just without the friendly face.
The inputs you'll actually touch:
ksize- STRING; type the window as a Python literal, e.g.[3, 3]. Malformed strings throwinvalid syntax (<unknown>, line 0).anchor- STRING;(-1, -1)centers the kernel.ddepth- INT;-1keeps the source depth.normalize- BOOLEAN; on means you get a mean of squares, which is what you want.borderType- INT enum; leave at the default.
There's an optional dst out-parameter too, and the pack's README explicitly tells you to avoid those. Listen to it.
Setup. Install from ComfyUI Manager by searching "opencv-comfyui", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
then restart. The pack depends on opencv-contrib-python, numpy, and torch (the first is the one that might be missing - pip install opencv-python-contrib). If you hit Cannot import name 'guidedFilter' from 'cv2.ximgproc', you've got two conflicting OpenCV installs and need to fix that before any of this works.
The trap that gets everyone: these nodes don't take ComfyUI IMAGEs. They want NPARRAY - a BGR, 0–255, uint8 numpy array. Run your image through Image2Nparray on the way in (it only accepts batch_size 1; use ImageFromBatch(length=1) for batches) and Nparrays2Image on the way out. Get that chain right once and every node in this pack behaves.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| ddepth | INT | — | |
| ksize | STRING | — | |
| anchor | STRING | — | |
| normalize | BOOLEAN | — | |
| borderType | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |