pub fn norm(
src1: &impl ToInputArray,
norm_type: i32,
mask: &impl ToInputArray
) -> Result<f64>
Expand description
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 .
The
and
norm for the sample value
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
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
and
.
It is notable that the
norm forms the upper and the
norm forms the lower border for the example function
.
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.
Parameters
- src1: first input array.
- normType: type of the norm (see #NormTypes).
- mask: optional operation mask; it must have the same size as src1 and CV_8UC1 type.
C++ default parameters
- norm_type: NORM_L2
- mask: noArray()