integral3
import { integral3 } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
imgproc_transform
Calculates the integral of an image.
The function calculates one or more integral images for the source image as follows:
\texttt{sum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)
\texttt{sqsum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)^2
\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)
Using these integral images, you can calculate sum, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:
\sum _{x_1 \leq x < x_2, \, y_1 \leq y < y_2} \texttt{image} (x,y) = \texttt{sum} (x_2,y_2)- \texttt{sum} (x_1,y_2)- \texttt{sum} (x_2,y_1)+ \texttt{sum} (x_1,y_1)
It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently.
As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(4,4,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted .

integral3(src: Mat, sum: Mat, sqsum: Mat, tilted: Mat, sdepth: number, sqdepth: number): void;3 available overloads
integral3(src: Mat, sum: Mat, sqsum: Mat, tilted: Mat): void;integral3(src: Mat, sum: Mat, sqsum: Mat, tilted: Mat, sdepth: number): void;integral3(src: Mat, sum: Mat, sqsum: Mat, tilted: Mat, sdepth: number, sqdepth: number): void;srcinput image as
W \times H, 8-bit or floating-point (32f or 64f).sumOutput destination, filled by the native operation. integral image as
(W+1)\times (H+1), 32-bit integer or floating-point (32f or 64f).sqsumOutput destination, filled by the native operation. integral image for squared pixel values; it is
(W+1)\times (H+1), double-precision floating-point (64f) array.tiltedOutput destination, filled by the native operation. integral for the image rotated by 45 degrees; it is
(W+1)\times (H+1)array with the same data type as sum.sdepthdesired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F.
sqdepthdesired depth of the integral image of squared pixel values, CV_32F or CV_64F.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.