OpenCV
4.0.0-beta
Open Source Computer Vision
|
Functions | |
GAPI_EXPORTS GMat | cv::gapi::absDiff (const GMat &src1, const GMat &src2) |
Calculates the per-element absolute difference between two matrices. More... | |
GAPI_EXPORTS GMat | cv::gapi::absDiffC (const GMat &src, const GScalar &c) |
Calculates absolute value of matrix elements. More... | |
GAPI_EXPORTS GMat | cv::gapi::addWeighted (const GMat &src1, double alpha, const GMat &src2, double beta, double gamma, int ddepth=-1) |
Calculates the weighted sum of two matrices. More... | |
GAPI_EXPORTS GMat | cv::gapi::inRange (const GMat &src, const GScalar &threshLow, const GScalar &threshUp) |
Applies a range-level threshold to each matrix element. More... | |
GAPI_EXPORTS std::tuple< GMat, GMat > | cv::gapi::integral (const GMat &src, int sdepth=-1, int sqdepth=-1) |
Calculates the integral of an image. More... | |
GAPI_EXPORTS GMat | cv::gapi::max (const GMat &src1, const GMat &src2) |
Calculates per-element maximum of two matrices. More... | |
GAPI_EXPORTS GMat | cv::gapi::min (const GMat &src1, const GMat &src2) |
Calculates per-element minimum of two matrices. More... | |
GAPI_EXPORTS GScalar | cv::gapi::normInf (const GMat &src) |
Calculates the absolute infinite norm of a matrix. More... | |
GAPI_EXPORTS GScalar | cv::gapi::normL1 (const GMat &src) |
Calculates the absolute L1 norm of a matrix. More... | |
GAPI_EXPORTS GScalar | cv::gapi::normL2 (const GMat &src) |
Calculates the absolute L2 norm of a matrix. More... | |
GAPI_EXPORTS GScalar | cv::gapi::sum (const GMat &src) |
Calculates sum of all matrix elements. More... | |
GAPI_EXPORTS GMat | cv::gapi::threshold (const GMat &src, const GScalar &thresh, const GScalar &maxval, int depth) |
Applies a fixed-level threshold to each matrix element. More... | |
GAPI_EXPORTS std::tuple< GMat, GScalar > | cv::gapi::threshold (const GMat &src, const GScalar &maxval, int depth) |
GAPI_EXPORTS GMat cv::gapi::absDiff | ( | const GMat & | src1, |
const GMat & | src2 | ||
) |
Calculates the per-element absolute difference between two matrices.
The function absDiff calculates absolute difference between two matrices of the same size and depth:
\[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\]
where I is a multi-dimensional index of matrix elements. In case of multi-channel matrices, each channel is processed independently. Output matrix must have the same size and depth as input matrices.
Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src1 | first input matrix. |
src2 | second input matrix. |
GAPI_EXPORTS GMat cv::gapi::absDiffC | ( | const GMat & | src, |
const GScalar & | c | ||
) |
Calculates absolute value of matrix elements.
The function abs calculates absolute difference between matrix elements and given scalar value:
\[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{matC}(I)|)\]
where matC is constructed from given scalar c and has the same sizes and depth as input matrix src.
Output matrix must be of the same size and depth as src.
Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src | input matrix. |
c | scalar to be subtracted. |
GAPI_EXPORTS GMat cv::gapi::addWeighted | ( | const GMat & | src1, |
double | alpha, | ||
const GMat & | src2, | ||
double | beta, | ||
double | gamma, | ||
int | ddepth = -1 |
||
) |
Calculates the weighted sum of two matrices.
The function addWeighted calculates the weighted sum of two matrices as follows:
\[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\]
where I is a multi-dimensional index of array elements. In case of multi-channel matrices, each channel is processed independently.
The function can be replaced with a matrix expression:
\[\texttt{dst}(I) = \texttt{alpha} * \texttt{src1}(I) - \texttt{beta} * \texttt{src2}(I) + \texttt{gamma} \]
Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src1 | first input matrix. |
alpha | weight of the first matrix elements. |
src2 | second input matrix of the same size and channel number as src1. |
beta | weight of the second matrix elements. |
gamma | scalar added to each sum. |
ddepth | optional depth of the output matrix. |
GAPI_EXPORTS GMat cv::gapi::inRange | ( | const GMat & | src, |
const GScalar & | threshLow, | ||
const GScalar & | threshUp | ||
) |
Applies a range-level threshold to each matrix element.
The function applies range-level thresholding to a single- or multiple-channel matrix. It sets output pixel value to OxFF if the corresponding pixel value of input matrix is in specified range,or 0 otherwise.
Input and output matrices must be CV_8UC1.
src | input matrix (CV_8UC1). |
threshLow | lower boundary value. |
threshUp | upper boundary value. |
GAPI_EXPORTS std::tuple<GMat, GMat> cv::gapi::integral | ( | const GMat & | src, |
int | sdepth = -1 , |
||
int | sqdepth = -1 |
||
) |
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\]
The function return integral image as \((W+1)\times (H+1)\) , 32-bit integer or floating-point (32f or 64f) and integral image for squared pixel values; it is \((W+1)\times (H+)\), double-precision floating-point (64f) array.
src | input image. |
sdepth | desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F. |
sqdepth | desired depth of the integral image of squared pixel values, CV_32F or CV_64F. |
GAPI_EXPORTS GMat cv::gapi::max | ( | const GMat & | src1, |
const GMat & | src2 | ||
) |
Calculates per-element maximum of two matrices.
The function max calculates the per-element maximum of two matrices of the same size, number of channels and depth:
\[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\]
where I is a multi-dimensional index of matrix elements. In case of multi-channel matrices, each channel is processed independently. Output matrix must be of the same size and depth as src1.
Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src1 | first input matrix. |
src2 | second input matrix of the same size and depth as src1. |
GAPI_EXPORTS GMat cv::gapi::min | ( | const GMat & | src1, |
const GMat & | src2 | ||
) |
Calculates per-element minimum of two matrices.
The function min calculates the per-element minimum of two matrices of the same size, number of channels and depth:
\[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\]
where I is a multi-dimensional index of matrix elements. In case of multi-channel matrices, each channel is processed independently. Output matrix must be of the same size and depth as src1.
Supported input matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src1 | first input matrix. |
src2 | second input matrix of the same size and depth as src1. |
GAPI_EXPORTS GScalar cv::gapi::normInf | ( | const GMat & | src | ) |
Calculates the absolute infinite norm of a matrix.
This version of normInf calculates the absolute infinite norm of src.
As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\). The \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\) is calculated as follows
\begin{align*} \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2 \end{align*}
and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
\begin{align*} \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5. \end{align*}
Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src | input matrix. |
GAPI_EXPORTS GScalar cv::gapi::normL1 | ( | const GMat & | src | ) |
Calculates the absolute L1 norm of a matrix.
This version of normL1 calculates the absolute L1 norm of src.
As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\). The \( L_{1} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\) is calculated as follows
\begin{align*} \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\ \end{align*}
and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
\begin{align*} \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\ \end{align*}
Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src | input matrix. |
GAPI_EXPORTS GScalar cv::gapi::normL2 | ( | const GMat & | src | ) |
Calculates the absolute L2 norm of a matrix.
This version of normL2 calculates the absolute L2 norm of src.
As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\). The \( L_{2} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\) is calculated as follows
\begin{align*} \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\ \end{align*}
and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
\begin{align*} \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\ \end{align*}
Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.
src | input matrix. |
GAPI_EXPORTS GScalar cv::gapi::sum | ( | const GMat & | src | ) |
GAPI_EXPORTS GMat cv::gapi::threshold | ( | const GMat & | src, |
const GScalar & | thresh, | ||
const GScalar & | maxval, | ||
int | depth | ||
) |
Applies a fixed-level threshold to each matrix element.
The function applies fixed-level thresholding to a single- or multiple-channel matrix. The function is typically used to get a bi-level (binary) image out of a grayscale image ( cmp funtions could be also used for this purpose) or for removing a noise, that is, filtering out pixels with too small or too large values. There are several depths of thresholding supported by the function. They are determined by depth parameter.
Also, the special values cv::THRESH_OTSU or cv::THRESH_TRIANGLE may be combined with one of the above values. In these cases, the function determines the optimal threshold value using the Otsu's or Triangle algorithm and uses it instead of the specified thresh . The function returns the computed threshold value in addititon to thresholded matrix. The Otsu's and Triangle methods are implemented only for 8-bit matrices.
Input image should be single channel only in case of cv::THRESH_OTSU or cv::THRESH_TRIANGLE flags. Output matrix must be of the same size and depth as src.
src | input matrix (CV_8UC1, CV_8UC3, or CV_32FC1). |
thresh | threshold value. |
maxval | maximum value to use with the cv::THRESH_BINARY and cv::THRESH_BINARY_INV thresholding depths. |
depth | thresholding depth (see the cv::ThresholdTypes). |
GAPI_EXPORTS std::tuple<GMat, GScalar> cv::gapi::threshold | ( | const GMat & | src, |
const GScalar & | maxval, | ||
int | depth | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function appicable for all threshold depths except CV_THRESH_OTSU and CV_THRESH_TRIANGLE