OpenCV integral3_0
The full triple — sum, squared sum, and tilted
- src
- sum
- sqsum
- tilted
- nparray_0
- nparray_1
- nparray_2
OpenCV integral3_0 is the deluxe version of the integral-image family. Where integral_0 gives you one summed-area table and integral2_0 gives you two, cv2.integral3 gives you three in a single pass: the plain sum table, the squared-sum table, and a tilted table computed along a 45°-rotated grid. The tilted table is the interesting one - it's what lets you sum over rotated (diamond-shaped) regions in O(1), which is exactly what old-school Haar-feature detectors (the ancestors of face-detection cascades) need when features aren't axis-aligned.
In a ComfyUI workflow, be honest with yourself about whether you'll ever use this. It's the most niche of the three integral nodes. The practical consumer-friendly results - adaptive thresholding, box blur, local contrast - all come from adaptiveThreshold_0, blur_0, or threshold_0, which ship in the same pack. integral3 is for when you're building a custom detector or analysis pipeline that genuinely needs rotated-region statistics and you want it computed at C++ speed rather than in a Python scripting loop.
How it works
cv2.integral3(src, sum, sqsum, tilted, sdepth, sqdepth) walks the source once and fills three (H+1, W+1) arrays: sum (standard top-left rectangle sums), sqsum (sums of squares, for variance), and tilted (sums over 45°-rotated rectangles, enabling diamond-region queries). Two of the three outputs are the same data as integral2_0; the tilted table is the addition. As with integral2, the squared sums grow fast, so sqdepth wants to be float (5 = CV_32F or 6 = CV_64F) rather than integer.
Inputs and outputs
src- NPARRAY, your image viaImage2Nparray.sdepth- INT, depth of the sum table (4=CV_32Sfor 8-bit sources).sqdepth- INT, depth of the squared-sum table - keep it float.sum,sqsum,tilted- optional out-parameters; the node returns all three anyway.- Outputs
nparray_0(sum),nparray_1(squared sum),nparray_2(tilted).
Installing
Same pack, one install for all ~635 nodes:
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 models to download; deps are opencv-contrib-python, numpy, torch.
Gotchas
The tables aren't viewable images - sums exceed 255 and Nparrays2Image won't rescale them, so previewing gives clipped garbage; that's expected, not a bug. Keep batch_size == 1. Don't leave sqdepth integer. And integral3_0 vs integral3_1 are identical overload duplicates (MatLike vs UMat in the stubs) - there's no feature difference, so pick whichever and move on.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| sdepth | INT | — | |
| sqdepth | INT | — | |
| sumopt | NPARRAY | — | |
| sqsumopt | NPARRAY | — | |
| tiltedopt | NPARRAY | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| nparray_0 | NPARRAY | — |
| nparray_1 | NPARRAY | — |
| nparray_2 | NPARRAY | — |