norm
import { norm } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Calculates the absolute norm of an array.
This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
As example for one array consider the function r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1].
The L_{1}, L_{2} and L_{\infty} norm for the sample value r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}
is calculated as follows
f:{align*}
| r(-1) |{L_1} &= |-1| + |2| = 3 \
| r(-1) |{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \
| r(-1) |{L\infty} &= \max(|-1|,|2|) = 2
f:}
and for r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix} the calculation is
f:{align*}
| r(0.5) |{L_1} &= |0.5| + |0.5| = 1 \
| r(0.5) |{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \
| r(0.5) |{L\infty} &= \max(|0.5|,|0.5|) = 0.5.
f:}
The following graphic shows all values for the three norm functions \| r(x) \|_{L_1}, \| r(x) \|_{L_2} and \| r(x) \|_{L_\infty}.
It is notable that the L_{1} norm forms the upper and the L_{\infty} norm forms the lower border for the example function r(x).

When the mask parameter is specified and it is not empty, the norm is
If normType is not specified, #NORM_L2 is used. calculated only over the region specified by the mask.
Multi-channel input arrays are treated as single-channel arrays, that is, the results for all channels are combined.
Hamming norms can only be calculated with CV_8U depth arrays.
norm(src1: Mat, normType: number, mask: Mat): number;3 available overloads
norm(src1: Mat): number;norm(src1: Mat, normType: number): number;norm(src1: Mat, normType: number, mask: Mat): number;src1first input array.
normTypetype of the norm (see #NormTypes).
maskoptional operation mask; it must have the same size as src1 and type CV_8UC1, CV_8SC1 or CV_BoolC1.
The number result.
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.