Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / include / opencv2 / gapi / imgproc.hpp
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.
4 //
5 // Copyright (C) 2018-2019 Intel Corporation
6
7
8 #ifndef OPENCV_GAPI_IMGPROC_HPP
9 #define OPENCV_GAPI_IMGPROC_HPP
10
11 #include "opencv2/imgproc.hpp"
12
13 #include <utility> // std::tuple
14
15 #include "opencv2/gapi/gkernel.hpp"
16 #include "opencv2/gapi/gmat.hpp"
17 #include "opencv2/gapi/gscalar.hpp"
18
19
20 /** \defgroup gapi_imgproc G-API image processing functionality
21 @{
22     @defgroup gapi_filters Graph API: Image filters
23     @defgroup gapi_colorconvert Graph API: Converting image from one color space to another
24 @}
25  */
26
27 namespace cv { namespace gapi {
28
29 namespace imgproc {
30     using GMat3 = std::tuple<GMat,GMat,GMat>; // FIXME: how to avoid this?
31
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);
35         }
36     };
37
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);
41         }
42     };
43
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);
47         }
48     };
49
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) {
52             return in;
53         }
54     };
55
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) {
58             return in;
59         }
60     };
61
62     G_TYPED_KERNEL(GMedianBlur, <GMat(GMat,int)>, "org.opencv.imgproc.filters.medianBlur") {
63         static GMatDesc outMeta(GMatDesc in, int) {
64             return in;
65         }
66     };
67
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) {
70             return in;
71         }
72     };
73
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) {
76             return in;
77         }
78     };
79
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);
83         }
84     };
85
86     G_TYPED_KERNEL(GEqHist, <GMat(GMat)>, "org.opencv.imgproc.equalizeHist"){
87         static GMatDesc outMeta(GMatDesc in) {
88             return in.withType(CV_8U, 1);
89         }
90     };
91
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);
95         }
96     };
97
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;
101         }
102     };
103
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;
107         }
108     };
109
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;
113         }
114     };
115
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;
119         }
120     };
121
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;
125         }
126     };
127
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;
131         }
132     };
133
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;
137         }
138     };
139
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);
143         }
144     };
145
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);
149         }
150     };
151
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);
155         }
156     };
157 }
158
159
160 //! @addtogroup gapi_filters
161 //! @{
162 /** @brief Applies a separable linear filter to a matrix(image).
163
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.
167
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).
172
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:
176
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
181
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
191  */
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));
195
196 /** @brief Convolves an image with the kernel.
197
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.
201
202 The function does actually compute correlation, not the convolution:
203
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]
205
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 -
208 anchor.y - 1)`.
209
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.
213
214 @note Function textual ID is "org.opencv.imgproc.filters.filter2D"
215
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
227 @sa  sepFilter
228  */
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));
231
232
233 /** @brief Blurs an image using the box filter.
234
235 The function smooths an image using the kernel:
236
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]
238
239 where
240
241 \f[\alpha = \fork{\frac{1}{\texttt{ksize.width*ksize.height}}}{when \texttt{normalize=true}}{1}{otherwise}\f]
242
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.
246
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.
250
251 @note Function textual ID is "org.opencv.imgproc.filters.boxfilter"
252
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
262  */
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));
266
267 /** @brief Blurs an image using the normalized box filter.
268
269 The function smooths an image using the kernel:
270
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]
272
273 The call `blur(src, dst, ksize, anchor, borderType)` is equivalent to `boxFilter(src, dst, src.type(),
274 anchor, true, borderType)`.
275
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.
279
280 @note Function textual ID is "org.opencv.imgproc.filters.blur"
281
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
285 center.
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
289  */
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));
292
293
294 //GAPI_EXPORTS_W void blur( InputArray src, OutputArray dst,
295  //                       Size ksize, Point anchor = Point(-1,-1),
296  //                       int borderType = BORDER_DEFAULT );
297
298
299 /** @brief Blurs an image using a Gaussian filter.
300
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.
303
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.
307
308 @note Function textual ID is "org.opencv.imgproc.filters.gaussianBlur"
309
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,
318 sigmaX, and sigmaY.
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
322  */
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));
325
326 /** @brief Blurs an image using the median filter.
327
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
333
334 @note Function textual ID is "org.opencv.imgproc.filters.medianBlur"
335
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
339  */
340 GAPI_EXPORTS GMat medianBlur(const GMat& src, int ksize);
341
342 /** @brief Erodes an image by using a specific structuring element.
343
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:
346
347 \f[\texttt{dst} (x,y) =  \min _{(x',y'):  \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f]
348
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.
353
354 @note Function textual ID is "org.opencv.imgproc.filters.erode"
355
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
364 @sa  dilate
365  */
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());
369
370 /** @brief Erodes an image by using 3 by 3 rectangular structuring element.
371
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.
377
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
382 @sa  erode, dilate3x3
383  */
384 GAPI_EXPORTS GMat erode3x3(const GMat& src, int iterations = 1,
385                            int borderType = BORDER_CONSTANT,
386                            const  Scalar& borderValue = morphologyDefaultBorderValue());
387
388 /** @brief Dilates an image by using a specific structuring element.
389
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]
393
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.
398
399 @note Function textual ID is "org.opencv.imgproc.filters.dilate"
400
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
410  */
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());
414
415 /** @brief Dilates an image by using 3 by 3 rectangular structuring element.
416
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]
420
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.
425
426 @note Function textual ID is "org.opencv.imgproc.filters.dilate"
427
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
432 @sa  dilate, erode3x3
433  */
434
435 GAPI_EXPORTS GMat dilate3x3(const GMat& src, int iterations = 1,
436                             int borderType = BORDER_CONSTANT,
437                             const  Scalar& borderValue = morphologyDefaultBorderValue());
438
439 /** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
440
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.
445
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
448
449 \f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f]
450
451 for the x-derivative, or transposed for the y-derivative.
452
453 The function calculates an image derivative by convolving the image with the appropriate kernel:
454
455 \f[\texttt{dst} =  \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f]
456
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:
461
462 \f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f]
463
464 The second case corresponds to a kernel of:
465
466 \f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f]
467
468 @note Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
469
470 @note Function textual ID is "org.opencv.imgproc.filters.sobel"
471
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
484  */
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));
489
490 /** @brief Finds edges in an image using the Canny algorithm.
491
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>
496
497 @note Function textual ID is "org.opencv.imgproc.filters.canny"
498
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 (
506 L2gradient=false ).
507  */
508 GAPI_EXPORTS GMat Canny(const GMat& image, double threshold1, double threshold2,
509                         int apertureSize = 3, bool L2gradient = false);
510
511 /** @brief Equalizes the histogram of a grayscale image.
512
513 The function equalizes the histogram of the input image using the following algorithm:
514
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$
520
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.
523
524 @note Function textual ID is "org.opencv.imgproc.equalizeHist"
525
526 @param src Source 8-bit single channel image.
527  */
528 GAPI_EXPORTS GMat equalizeHist(const GMat& src);
529
530 //! @} gapi_filters
531
532 //! @addtogroup gapi_colorconvert
533 //! @{
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]
538
539 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2gray"
540
541 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
542 @sa RGB2YUV
543  */
544 GAPI_EXPORTS GMat RGB2Gray(const GMat& src);
545
546 /** @overload
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]
549
550 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2graycustom"
551
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.
556 @sa RGB2YUV
557  */
558 GAPI_EXPORTS GMat RGB2Gray(const GMat& src, float rY, float gY, float bY);
559
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]
564
565 @note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2gray"
566
567 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
568 @sa BGR2LUV
569  */
570 GAPI_EXPORTS GMat BGR2Gray(const GMat& src);
571
572 /** @brief Converts an image from RGB color space to YUV color space.
573
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.
576
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.
581
582 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2yuv"
583
584 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
585 @sa YUV2RGB, RGB2Lab
586 */
587 GAPI_EXPORTS GMat RGB2YUV(const GMat& src);
588
589 /** @brief Converts an image from BGR color space to LUV color space.
590
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.
593
594 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
595
596 @note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2luv"
597
598 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
599 @sa RGB2Lab, RGB2LUV
600 */
601 GAPI_EXPORTS GMat BGR2LUV(const GMat& src);
602
603 /** @brief Converts an image from LUV color space to BGR color space.
604
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.
607
608 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
609
610 @note Function textual ID is "org.opencv.imgproc.colorconvert.luv2bgr"
611
612 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
613 @sa BGR2LUV
614 */
615 GAPI_EXPORTS GMat LUV2BGR(const GMat& src);
616
617 /** @brief Converts an image from YUV color space to BGR color space.
618
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.
621
622 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
623
624 @note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2bgr"
625
626 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
627 @sa BGR2YUV
628 */
629 GAPI_EXPORTS GMat YUV2BGR(const GMat& src);
630
631 /** @brief Converts an image from BGR color space to YUV color space.
632
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.
635
636 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
637
638 @note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2yuv"
639
640 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
641 @sa YUV2BGR
642 */
643 GAPI_EXPORTS GMat BGR2YUV(const GMat& src);
644
645 /** @brief Converts an image from RGB color space to Lab color space.
646
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.
649
650 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC1.
651
652 @note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2lab"
653
654 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1.
655 @sa RGB2YUV, RGB2LUV
656 */
657 GAPI_EXPORTS GMat RGB2Lab(const GMat& src);
658
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.
662
663 Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3.
664
665 @note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2rgb"
666
667 @param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3.
668
669 @sa RGB2Lab, RGB2YUV
670 */
671 GAPI_EXPORTS GMat YUV2RGB(const GMat& src);
672
673 //! @} gapi_colorconvert
674 } //namespace gapi
675 } //namespace cv
676
677 #endif // OPENCV_GAPI_IMGPROC_HPP