|
|
@ -640,43 +640,50 @@ Scalar_ 's. |
|
|
|
CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, |
|
|
|
CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, |
|
|
|
InputArray mask=noArray()); |
|
|
|
InputArray mask=noArray()); |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Calculates an absolute array norm, an absolute difference norm, or a
|
|
|
|
/** @brief Calculates the absolute norm of an array.
|
|
|
|
relative difference norm. |
|
|
|
|
|
|
|
|
|
|
|
This version of cv::norm calculates the absolute norm of src1. The type of norm to calculate is specified using cv::NormTypes. |
|
|
|
The function cv::norm calculates an absolute norm of src1 (when there is no |
|
|
|
|
|
|
|
src2 ): |
|
|
|
As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. |
|
|
|
|
|
|
|
The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ |
|
|
|
\f[norm = \forkthree{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) } |
|
|
|
is calculated as follows |
|
|
|
{ \| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) } |
|
|
|
\f{align*} |
|
|
|
{ \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f] |
|
|
|
\| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
|
|
|
|
|
|
|
|
\| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
|
|
|
|
or an absolute or relative difference norm if src2 is there: |
|
|
|
\| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2 |
|
|
|
|
|
|
|
\f} |
|
|
|
\f[norm = \forkthree{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) } |
|
|
|
and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is |
|
|
|
{ \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) } |
|
|
|
\f{align*} |
|
|
|
{ \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f] |
|
|
|
\| 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} \\
|
|
|
|
or |
|
|
|
\| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5. |
|
|
|
|
|
|
|
\f} |
|
|
|
\f[norm = \forkthree{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_INF}\) } |
|
|
|
The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$. |
|
|
|
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L1}\) } |
|
|
|
It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$. |
|
|
|
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2}\) }\f] |
|
|
|
![Graphs for the different norm functions from the above example](pics/NormTypes_OneArray_1-2-INF.png) |
|
|
|
|
|
|
|
|
|
|
|
The function cv::norm returns the calculated norm. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
When the mask parameter is specified and it is not empty, the norm is |
|
|
|
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. |
|
|
|
calculated only over the region specified by the mask. |
|
|
|
|
|
|
|
|
|
|
|
A multi-channel input arrays are treated as a single-channel, that is, |
|
|
|
Multi-channel input arrays are treated as single-channel arrays, that is, |
|
|
|
the results for all channels are combined. |
|
|
|
the results for all channels are combined. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Hamming norms can only be calculated with CV_8U depth arrays. |
|
|
|
|
|
|
|
|
|
|
|
@param src1 first input array. |
|
|
|
@param src1 first input array. |
|
|
|
@param normType type of the norm (see cv::NormTypes). |
|
|
|
@param normType type of the norm (see cv::NormTypes). |
|
|
|
@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. |
|
|
|
@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray()); |
|
|
|
CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray()); |
|
|
|
|
|
|
|
|
|
|
|
/** @overload
|
|
|
|
/** @brief Calculates an absolute difference norm or a relative difference norm.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This version of cv::norm calculates the absolute difference norm |
|
|
|
|
|
|
|
or the relative difference norm of arrays src1 and src2. |
|
|
|
|
|
|
|
The type of norm to calculate is specified using cv::NormTypes. |
|
|
|
|
|
|
|
|
|
|
|
@param src1 first input array. |
|
|
|
@param src1 first input array. |
|
|
|
@param src2 second input array of the same size and the same type as src1. |
|
|
|
@param src2 second input array of the same size and the same type as src1. |
|
|
|
@param normType type of the norm (cv::NormTypes). |
|
|
|
@param normType type of the norm (cv::NormTypes). |
|
|
|