1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
5 // Copyright (C) 2018-2019 Intel Corporation
8 #ifndef OPENCV_GAPI_IMGPROC_HPP
9 #define OPENCV_GAPI_IMGPROC_HPP
11 #include "opencv2/imgproc.hpp"
13 #include <utility> // std::tuple
15 #include "opencv2/gapi/gkernel.hpp"
16 #include "opencv2/gapi/gmat.hpp"
17 #include "opencv2/gapi/gscalar.hpp"
20 /** \defgroup gapi_imgproc G-API image processing functionality
22 @defgroup gapi_filters Graph API: Image filters
23 @defgroup gapi_colorconvert Graph API: Converting image from one color space to another
27 namespace cv { namespace gapi {
30 using GMat3 = std::tuple<GMat,GMat,GMat>; // FIXME: how to avoid this?
32 G_TYPED_KERNEL(GFilter2D, <GMat(GMat,int,Mat,Point,Scalar,int,Scalar)>,"org.opencv.imgproc.filters.filter2D") {
33 static GMatDesc outMeta(GMatDesc in, int ddepth, Mat, Point, Scalar, int, Scalar) {
34 return in.withDepth(ddepth);
38 G_TYPED_KERNEL(GSepFilter, <GMat(GMat,int,Mat,Mat,Point,Scalar,int,Scalar)>, "org.opencv.imgproc.filters.sepfilter") {
39 static GMatDesc outMeta(GMatDesc in, int ddepth, Mat, Mat, Point, Scalar, int, Scalar) {
40 return in.withDepth(ddepth);
44 G_TYPED_KERNEL(GBoxFilter, <GMat(GMat,int,Size,Point,bool,int,Scalar)>, "org.opencv.imgproc.filters.boxfilter") {
45 static GMatDesc outMeta(GMatDesc in, int ddepth, Size, Point, bool, int, Scalar) {
46 return in.withDepth(ddepth);
50 G_TYPED_KERNEL(GBlur, <GMat(GMat,Size,Point,int,Scalar)>, "org.opencv.imgproc.filters.blur"){
51 static GMatDesc outMeta(GMatDesc in, Size, Point, int, Scalar) {
56 G_TYPED_KERNEL(GGaussBlur, <GMat(GMat,Size,double,double,int,Scalar)>, "org.opencv.imgproc.filters.gaussianBlur") {
57 static GMatDesc outMeta(GMatDesc in, Size, double, double, int, Scalar) {
62 G_TYPED_KERNEL(GMedianBlur, <GMat(GMat,int)>, "org.opencv.imgproc.filters.medianBlur") {
63 static GMatDesc outMeta(GMatDesc in, int) {
68 G_TYPED_KERNEL(GErode, <GMat(GMat,Mat,Point,int,int,Scalar)>, "org.opencv.imgproc.filters.erode") {
69 static GMatDesc outMeta(GMatDesc in, Mat, Point, int, int, Scalar) {
74 G_TYPED_KERNEL(GDilate, <GMat(GMat,Mat,Point,int,int,Scalar)>, "org.opencv.imgproc.filters.dilate") {
75 static GMatDesc outMeta(GMatDesc in, Mat, Point, int, int, Scalar) {
80 G_TYPED_KERNEL(GSobel, <GMat(GMat,int,int,int,int,double,double,int,Scalar)>, "org.opencv.imgproc.filters.sobel") {
81 static GMatDesc outMeta(GMatDesc in, int ddepth, int, int, int, double, double, int, Scalar) {
82 return in.withDepth(ddepth);
86 G_TYPED_KERNEL(GEqHist, <GMat(GMat)>, "org.opencv.imgproc.equalizeHist"){
87 static GMatDesc outMeta(GMatDesc in) {
88 return in.withType(CV_8U, 1);
92 G_TYPED_KERNEL(GCanny, <GMat(GMat,double,double,int,bool)>, "org.opencv.imgproc.canny"){
93 static GMatDesc outMeta(GMatDesc in, double, double, int, bool) {
94 return in.withType(CV_8U, 1);
98 G_TYPED_KERNEL(GRGB2YUV, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.rgb2yuv") {
99 static GMatDesc outMeta(GMatDesc in) {
100 return in; // type still remains CV_8UC3;
104 G_TYPED_KERNEL(GYUV2RGB, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.yuv2rgb") {
105 static GMatDesc outMeta(GMatDesc in) {
106 return in; // type still remains CV_8UC3;
110 G_TYPED_KERNEL(GRGB2Lab, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.rgb2lab") {
111 static GMatDesc outMeta(GMatDesc in) {
112 return in; // type still remains CV_8UC3;
116 G_TYPED_KERNEL(GBGR2LUV, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.bgr2luv") {
117 static GMatDesc outMeta(GMatDesc in) {
118 return in; // type still remains CV_8UC3;
122 G_TYPED_KERNEL(GLUV2BGR, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.luv2bgr") {
123 static GMatDesc outMeta(GMatDesc in) {
124 return in; // type still remains CV_8UC3;
128 G_TYPED_KERNEL(GYUV2BGR, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.yuv2bgr") {
129 static GMatDesc outMeta(GMatDesc in) {
130 return in; // type still remains CV_8UC3;
134 G_TYPED_KERNEL(GBGR2YUV, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.bgr2yuv") {
135 static GMatDesc outMeta(GMatDesc in) {
136 return in; // type still remains CV_8UC3;
140 G_TYPED_KERNEL(GRGB2Gray, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.rgb2gray") {
141 static GMatDesc outMeta(GMatDesc in) {
142 return in.withType(CV_8U, 1);
146 G_TYPED_KERNEL(GRGB2GrayCustom, <GMat(GMat,float,float,float)>, "org.opencv.imgproc.colorconvert.rgb2graycustom") {
147 static GMatDesc outMeta(GMatDesc in, float, float, float) {
148 return in.withType(CV_8U, 1);
152 G_TYPED_KERNEL(GBGR2Gray, <GMat(GMat)>, "org.opencv.imgproc.colorconvert.bgr2gray") {
153 static GMatDesc outMeta(GMatDesc in) {
154 return in.withType(CV_8U, 1);
160 //! @addtogroup gapi_filters
162 /** @brief Applies a separable linear filter to a matrix(image).
164 The function applies a separable linear filter to the matrix. That is, first, every row of src is
165 filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D
166 kernel kernelY. The final result is returned.
168 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
169 Output image must have the same type, size, and number of channels as the input image.
170 @note In case of floating-point computation, rounding to nearest even is procedeed
171 if hardware supports it (if not - to nearest value).
173 @note Function textual ID is "org.opencv.imgproc.filters.sepfilter"
174 @param src Source image.
175 @param ddepth desired depth of the destination image (the following combinations of src.depth() and ddepth are supported:
177 src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
178 src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
179 src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
180 src.depth() = CV_64F, ddepth = -1/CV_64F
182 when ddepth=-1, the output image will have the same depth as the source)
183 @param kernelX Coefficients for filtering each row.
184 @param kernelY Coefficients for filtering each column.
185 @param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor
186 is at the kernel center.
187 @param delta Value added to the filtered results before storing them.
188 @param borderType Pixel extrapolation method, see cv::BorderTypes
189 @param borderValue border value in case of constant border type
190 @sa boxFilter, gaussianBlur, medianBlur
192 GAPI_EXPORTS GMat sepFilter(const GMat& src, int ddepth, const Mat& kernelX, const Mat& kernelY, const Point& anchor /*FIXME: = Point(-1,-1)*/,
193 const Scalar& delta /*FIXME = GScalar(0)*/, int borderType = BORDER_DEFAULT,
194 const Scalar& borderValue = Scalar(0));
196 /** @brief Convolves an image with the kernel.
198 The function applies an arbitrary linear filter to an image. When
199 the aperture is partially outside the image, the function interpolates outlier pixel values
200 according to the specified border mode.
202 The function does actually compute correlation, not the convolution:
204 \f[\texttt{dst} (x,y) = \sum _{ \stackrel{0\leq x' < \texttt{kernel.cols},}{0\leq y' < \texttt{kernel.rows}} } \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\f]
206 That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip
207 the kernel using flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows -
210 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
211 Output image must have the same size and number of channels an input image.
212 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
214 @note Function textual ID is "org.opencv.imgproc.filters.filter2D"
216 @param src input image.
217 @param ddepth desired depth of the destination image
218 @param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point
219 matrix; if you want to apply different kernels to different channels, split the image into
220 separate color planes using split and process them individually.
221 @param anchor anchor of the kernel that indicates the relative position of a filtered point within
222 the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor
223 is at the kernel center.
224 @param delta optional value added to the filtered pixels before storing them in dst.
225 @param borderType pixel extrapolation method, see cv::BorderTypes
226 @param borderValue border value in case of constant border type
229 GAPI_EXPORTS GMat filter2D(const GMat& src, int ddepth, const Mat& kernel, const Point& anchor = Point(-1,-1), const Scalar& delta = Scalar(0),
230 int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
233 /** @brief Blurs an image using the box filter.
235 The function smooths an image using the kernel:
237 \f[\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\f]
241 \f[\alpha = \fork{\frac{1}{\texttt{ksize.width*ksize.height}}}{when \texttt{normalize=true}}{1}{otherwise}\f]
243 Unnormalized box filter is useful for computing various integral characteristics over each pixel
244 neighborhood, such as covariance matrices of image derivatives (used in dense optical flow
245 algorithms, and so on). If you need to compute pixel sums over variable-size windows, use cv::integral.
247 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
248 Output image must have the same type, size, and number of channels as the input image.
249 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
251 @note Function textual ID is "org.opencv.imgproc.filters.boxfilter"
253 @param src Source image.
254 @param dtype the output image depth (-1 to set the input image data type).
255 @param ksize blurring kernel size.
256 @param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor
257 is at the kernel center.
258 @param normalize flag, specifying whether the kernel is normalized by its area or not.
259 @param borderType Pixel extrapolation method, see cv::BorderTypes
260 @param borderValue border value in case of constant border type
261 @sa sepFilter, gaussianBlur, medianBlur, integral
263 GAPI_EXPORTS GMat boxFilter(const GMat& src, int dtype, const Size& ksize, const Point& anchor = Point(-1,-1),
264 bool normalize = true, int borderType = BORDER_DEFAULT,
265 const Scalar& borderValue = Scalar(0));
267 /** @brief Blurs an image using the normalized box filter.
269 The function smooths an image using the kernel:
271 \f[\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\f]
273 The call `blur(src, dst, ksize, anchor, borderType)` is equivalent to `boxFilter(src, dst, src.type(),
274 anchor, true, borderType)`.
276 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
277 Output image must have the same type, size, and number of channels as the input image.
278 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
280 @note Function textual ID is "org.opencv.imgproc.filters.blur"
282 @param src Source image.
283 @param ksize blurring kernel size.
284 @param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel
286 @param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes
287 @param borderValue border value in case of constant border type
288 @sa boxFilter, bilateralFilter, GaussianBlur, medianBlur
290 GAPI_EXPORTS GMat blur(const GMat& src, const Size& ksize, const Point& anchor = Point(-1,-1),
291 int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
294 //GAPI_EXPORTS_W void blur( InputArray src, OutputArray dst,
295 // Size ksize, Point anchor = Point(-1,-1),
296 // int borderType = BORDER_DEFAULT );
299 /** @brief Blurs an image using a Gaussian filter.
301 The function filter2Ds the source image with the specified Gaussian kernel.
302 Output image must have the same type and number of channels an input image.
304 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
305 Output image must have the same type, size, and number of channels as the input image.
306 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
308 @note Function textual ID is "org.opencv.imgproc.filters.gaussianBlur"
310 @param src input image;
311 @param ksize Gaussian kernel size. ksize.width and ksize.height can differ but they both must be
312 positive and odd. Or, they can be zero's and then they are computed from sigma.
313 @param sigmaX Gaussian kernel standard deviation in X direction.
314 @param sigmaY Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be
315 equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height,
316 respectively (see cv::getGaussianKernel for details); to fully control the result regardless of
317 possible future modifications of all this semantics, it is recommended to specify all of ksize,
319 @param borderType pixel extrapolation method, see cv::BorderTypes
320 @param borderValue border value in case of constant border type
321 @sa sepFilter, boxFilter, medianBlur
323 GAPI_EXPORTS GMat gaussianBlur(const GMat& src, const Size& ksize, double sigmaX, double sigmaY = 0,
324 int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0));
326 /** @brief Blurs an image using the median filter.
328 The function smoothes an image using the median filter with the \f$\texttt{ksize} \times
329 \texttt{ksize}\f$ aperture. Each channel of a multi-channel image is processed independently.
330 Output image must have the same type, size, and number of channels as the input image.
331 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
332 The median filter uses cv::BORDER_REPLICATE internally to cope with border pixels, see cv::BorderTypes
334 @note Function textual ID is "org.opencv.imgproc.filters.medianBlur"
336 @param src input matrix (image)
337 @param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...
338 @sa boxFilter, gaussianBlur
340 GAPI_EXPORTS GMat medianBlur(const GMat& src, int ksize);
342 /** @brief Erodes an image by using a specific structuring element.
344 The function erodes the source image using the specified structuring element that determines the
345 shape of a pixel neighborhood over which the minimum is taken:
347 \f[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f]
349 Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.
350 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1.
351 Output image must have the same type, size, and number of channels as the input image.
352 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
354 @note Function textual ID is "org.opencv.imgproc.filters.erode"
356 @param src input image
357 @param kernel structuring element used for erosion; if `element=Mat()`, a `3 x 3` rectangular
358 structuring element is used. Kernel can be created using getStructuringElement.
359 @param anchor position of the anchor within the element; default value (-1, -1) means that the
360 anchor is at the element center.
361 @param iterations number of times erosion is applied.
362 @param borderType pixel extrapolation method, see cv::BorderTypes
363 @param borderValue border value in case of a constant border
366 GAPI_EXPORTS GMat erode(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1,
367 int borderType = BORDER_CONSTANT,
368 const Scalar& borderValue = morphologyDefaultBorderValue());
370 /** @brief Erodes an image by using 3 by 3 rectangular structuring element.
372 The function erodes the source image using the rectangular structuring element with rectangle center as an anchor.
373 Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.
374 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1.
375 Output image must have the same type, size, and number of channels as the input image.
376 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
378 @param src input image
379 @param iterations number of times erosion is applied.
380 @param borderType pixel extrapolation method, see cv::BorderTypes
381 @param borderValue border value in case of a constant border
384 GAPI_EXPORTS GMat erode3x3(const GMat& src, int iterations = 1,
385 int borderType = BORDER_CONSTANT,
386 const Scalar& borderValue = morphologyDefaultBorderValue());
388 /** @brief Dilates an image by using a specific structuring element.
390 The function dilates the source image using the specified structuring element that determines the
391 shape of a pixel neighborhood over which the maximum is taken:
392 \f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f]
394 Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.
395 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1.
396 Output image must have the same type, size, and number of channels as the input image.
397 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
399 @note Function textual ID is "org.opencv.imgproc.filters.dilate"
401 @param src input image.
402 @param kernel structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular
403 structuring element is used. Kernel can be created using getStructuringElement
404 @param anchor position of the anchor within the element; default value (-1, -1) means that the
405 anchor is at the element center.
406 @param iterations number of times dilation is applied.
407 @param borderType pixel extrapolation method, see cv::BorderTypes
408 @param borderValue border value in case of a constant border
409 @sa erode, morphologyEx, getStructuringElement
411 GAPI_EXPORTS GMat dilate(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1,
412 int borderType = BORDER_CONSTANT,
413 const Scalar& borderValue = morphologyDefaultBorderValue());
415 /** @brief Dilates an image by using 3 by 3 rectangular structuring element.
417 The function dilates the source image using the specified structuring element that determines the
418 shape of a pixel neighborhood over which the maximum is taken:
419 \f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f]
421 Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently.
422 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1.
423 Output image must have the same type, size, and number of channels as the input image.
424 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
426 @note Function textual ID is "org.opencv.imgproc.filters.dilate"
428 @param src input image.
429 @param iterations number of times dilation is applied.
430 @param borderType pixel extrapolation method, see cv::BorderTypes
431 @param borderValue border value in case of a constant border
435 GAPI_EXPORTS GMat dilate3x3(const GMat& src, int iterations = 1,
436 int borderType = BORDER_CONSTANT,
437 const Scalar& borderValue = morphologyDefaultBorderValue());
439 /** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
441 In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to
442 calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or \f$1 \times 3\f$
443 kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first
444 or the second x- or y- derivatives.
446 There is also the special value `ksize = FILTER_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr
447 filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is
449 \f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f]
451 for the x-derivative, or transposed for the y-derivative.
453 The function calculates an image derivative by convolving the image with the appropriate kernel:
455 \f[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f]
457 The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less
458 resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3)
459 or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first
460 case corresponds to a kernel of:
462 \f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f]
464 The second case corresponds to a kernel of:
466 \f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f]
468 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
470 @note Function textual ID is "org.opencv.imgproc.filters.sobel"
472 @param src input image.
473 @param ddepth output image depth, see @ref filter_depths "combinations"; in the case of
474 8-bit input images it will result in truncated derivatives.
475 @param dx order of the derivative x.
476 @param dy order of the derivative y.
477 @param ksize size of the extended Sobel kernel; it must be odd.
478 @param scale optional scale factor for the computed derivative values; by default, no scaling is
479 applied (see cv::getDerivKernels for details).
480 @param delta optional delta value that is added to the results prior to storing them in dst.
481 @param borderType pixel extrapolation method, see cv::BorderTypes
482 @param borderValue border value in case of constant border type
483 @sa filter2D, gaussianBlur, cartToPolar
485 GAPI_EXPORTS GMat Sobel(const GMat& src, int ddepth, int dx, int dy, int ksize = 3,
486 double scale = 1, double delta = 0,
487 int borderType = BORDER_DEFAULT,
488 const Scalar& borderValue = Scalar(0));
490 /** @brief Finds edges in an image using the Canny algorithm.
492 The function finds edges in the input image and marks them in the output map edges using the
493 Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The
494 largest value is used to find initial segments of strong edges. See
495 <http://en.wikipedia.org/wiki/Canny_edge_detector>
497 @note Function textual ID is "org.opencv.imgproc.filters.canny"
499 @param image 8-bit input image.
500 @param threshold1 first threshold for the hysteresis procedure.
501 @param threshold2 second threshold for the hysteresis procedure.
502 @param apertureSize aperture size for the Sobel operator.
503 @param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm
504 \f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude (
505 L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough (
508 GAPI_EXPORTS GMat Canny(const GMat& image, double threshold1, double threshold2,
509 int apertureSize = 3, bool L2gradient = false);
511 /** @brief Equalizes the histogram of a grayscale image.
513 The function equalizes the histogram of the input image using the following algorithm:
515 - Calculate the histogram \f$H\f$ for src .
516 - Normalize the histogram so that the sum of histogram bins is 255.
517 - Compute the integral of the histogram:
518 \f[H'_i = \sum _{0 \le j < i} H(j)\f]
519 - Transform the image using \f$H'\f$ as a look-up table: \f$\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\f$
521 The algorithm normalizes the brightness and increases the contrast of the image.
522 @note The returned image is of the same size and type as input.
524 @note Function textual ID is "org.opencv.imgproc.equalizeHist"
526 @param src Source 8-bit single channel image.
528 GAPI_EXPORTS GMat equalizeHist(const GMat& src);
532 //! @addtogroup gapi_colorconvert
534 /** @brief Converts an image from RGB color space to gray-scaled.
535 The conventional ranges for R, G, and B channel values are 0 to 255.
536 Resulting gray color value computed as
537 \f[\texttt{dst} (I)= \texttt{0.299} * \texttt{src}(I).R + \texttt{0.587} * \texttt{src}(I).G + \texttt{0.114} * \texttt{src}(I).B \f]
539 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2gray"
541 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
544 GAPI_EXPORTS GMat RGB2Gray(const GMat& src);
547 Resulting gray color value computed as
548 \f[\texttt{dst} (I)= \texttt{rY} * \texttt{src}(I).R + \texttt{gY} * \texttt{src}(I).G + \texttt{bY} * \texttt{src}(I).B \f]
550 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2graycustom"
552 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
553 @param rY float multiplier for R channel.
554 @param gY float multiplier for G channel.
555 @param bY float multiplier for B channel.
558 GAPI_EXPORTS GMat RGB2Gray(const GMat& src, float rY, float gY, float bY);
560 /** @brief Converts an image from BGR color space to gray-scaled.
561 The conventional ranges for B, G, and R channel values are 0 to 255.
562 Resulting gray color value computed as
563 \f[\texttt{dst} (I)= \texttt{0.114} * \texttt{src}(I).B + \texttt{0.587} * \texttt{src}(I).G + \texttt{0.299} * \texttt{src}(I).R \f]
565 @note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2gray"
567 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
570 GAPI_EXPORTS GMat BGR2Gray(const GMat& src);
572 /** @brief Converts an image from RGB color space to YUV color space.
574 The function converts an input image from RGB color space to YUV.
575 The conventional ranges for R, G, and B channel values are 0 to 255.
577 In case of linear transformations, the range does not matter. But in case of a non-linear
578 transformation, an input RGB image should be normalized to the proper value range to get the correct
579 results, like here, at RGB \f$\rightarrow\f$ Y\*u\*v\* transformation.
580 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
582 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2yuv"
584 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
587 GAPI_EXPORTS GMat RGB2YUV(const GMat& src);
589 /** @brief Converts an image from BGR color space to LUV color space.
591 The function converts an input image from BGR color space to LUV.
592 The conventional ranges for B, G, and R channel values are 0 to 255.
594 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
596 @note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2luv"
598 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
601 GAPI_EXPORTS GMat BGR2LUV(const GMat& src);
603 /** @brief Converts an image from LUV color space to BGR color space.
605 The function converts an input image from LUV color space to BGR.
606 The conventional ranges for B, G, and R channel values are 0 to 255.
608 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
610 @note Function textual ID is "org.opencv.imgproc.colorconvert.luv2bgr"
612 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
615 GAPI_EXPORTS GMat LUV2BGR(const GMat& src);
617 /** @brief Converts an image from YUV color space to BGR color space.
619 The function converts an input image from YUV color space to BGR.
620 The conventional ranges for B, G, and R channel values are 0 to 255.
622 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
624 @note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2bgr"
626 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
629 GAPI_EXPORTS GMat YUV2BGR(const GMat& src);
631 /** @brief Converts an image from BGR color space to YUV color space.
633 The function converts an input image from BGR color space to YUV.
634 The conventional ranges for B, G, and R channel values are 0 to 255.
636 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
638 @note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2yuv"
640 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
643 GAPI_EXPORTS GMat BGR2YUV(const GMat& src);
645 /** @brief Converts an image from RGB color space to Lab color space.
647 The function converts an input image from BGR color space to Lab.
648 The conventional ranges for R, G, and B channel values are 0 to 255.
650 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC1.
652 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2lab"
654 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
657 GAPI_EXPORTS GMat RGB2Lab(const GMat& src);
659 /** @brief Converts an image from YUV color space to RGB.
660 The function converts an input image from YUV color space to RGB.
661 The conventional ranges for Y, U, and V channel values are 0 to 255.
663 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
665 @note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2rgb"
667 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
671 GAPI_EXPORTS GMat YUV2RGB(const GMat& src);
673 //! @} gapi_colorconvert
677 #endif // OPENCV_GAPI_IMGPROC_HPP