OpenCV integral2_1
The duplicate with the variance trick inside
- src
- sum
- sqsum
- nparray_0
- nparray_1
The pattern should be familiar by now: OpenCV integral2_1 and OpenCV integral2_0 are the same node. This pack auto-generates one node per overload found in OpenCV's type stubs, cv2.integral2 is listed twice (MatLike and UMat variants), and the _1 here is that duplicate. Same inputs, same two outputs, no behavioral difference. Read the integral2_0 article for the full mechanics; this page covers the practical side and the numbering trap.
What it does
Computes two summed-area tables in a single pass: sum, the ordinary integral image, and sqsum, the integral of squared pixel values. Together they let you compute per-rectangle mean and variance in constant time - variance being mean(squares) − mean². That makes it the right tool for local contrast normalization, per-tile statistics, and texture/region analysis. It's a building block, not an end-user node: you'll rarely drop it into a standard txt2img graph, and when you want the results of such analysis you usually reach for adaptiveThreshold_0 or blur_0 in the same pack.
Inputs and outputs
src- NPARRAY, your image viaImage2Nparray.sdepth- INT, depth for the sum table (4=CV_32Sfor 8-bit sources).sqdepth- INT, depth for the squared-sum table - use5(CV_32F) or6(CV_64F), never integer, or you overflow.sum,sqsum- optional out-parameters, safe to ignore.- Outputs
nparray_0(sum),nparray_1(squared sum).
Installing
Standard for the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
cd opencv-comfyui
pip install -r requirements.txt
or ComfyUI Manager → "opencv-comfyui". No model downloads; requirements.txt is opencv-contrib-python, numpy, torch.
Gotchas
Two things to remember, both from the pack's nature rather than this specific node. First, the two outputs are tables, not images - previewing them via Nparrays2Image gives clipped nonsense because the values run far beyond 255 and nothing rescales them. Second, integral2_1 is not the "advanced" version. The _1 suffix is pure overload numbering; there is nothing this node does that integral2_0 doesn't. Use whichever a workflow references, and keep batch_size == 1 in all cases.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| sdepth | INT | — | |
| sqdepth | INT | — | |
| sumopt | NPARRAY | — | |
| sqsumopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| nparray_0 | NPARRAY | — |
| nparray_1 | NPARRAY | — |