Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / include / opencv2 / gapi / core.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_CORE_HPP
9 #define OPENCV_GAPI_CORE_HPP
10
11 #include <utility> // std::tuple
12
13 #include <opencv2/imgproc.hpp>
14
15 #include "opencv2/gapi/gmat.hpp"
16 #include "opencv2/gapi/gscalar.hpp"
17 #include "opencv2/gapi/gkernel.hpp"
18
19 /** \defgroup gapi_core G-API core (basic) functionality
20 @{
21     @defgroup gapi_math Graph API: Math operations
22     @defgroup gapi_pixelwise Graph API: Pixelwise operations
23     @defgroup gapi_matrixop Graph API: Operations on matrices
24     @defgroup gapi_transform Graph API: Geometric, depth and LUT-like image transformations
25 @}
26  */
27 namespace cv { namespace gapi {
28 namespace core {
29     using GMat2 = std::tuple<GMat,GMat>;
30     using GMat3 = std::tuple<GMat,GMat,GMat>; // FIXME: how to avoid this?
31     using GMat4 = std::tuple<GMat,GMat,GMat,GMat>;
32     using GMatScalar = std::tuple<GMat, GScalar>;
33
34     G_TYPED_KERNEL(GAdd, <GMat(GMat, GMat, int)>, "org.opencv.core.math.add") {
35         static GMatDesc outMeta(GMatDesc a, GMatDesc b, int ddepth) {
36             if (ddepth == -1)
37             {
38                 // OpenCV: When the input arrays in add/subtract/multiply/divide
39                 // functions have different depths, the output array depth must be
40                 // explicitly specified!
41                 // See artim_op() @ arithm.cpp
42                 GAPI_Assert(a.chan == b.chan);
43                 GAPI_Assert(a.depth == b.depth);
44                 return a;
45             }
46             return a.withDepth(ddepth);
47         }
48     };
49
50     G_TYPED_KERNEL(GAddC, <GMat(GMat, GScalar, int)>, "org.opencv.core.math.addC") {
51         static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) {
52             return a.withDepth(ddepth);
53         }
54     };
55
56     G_TYPED_KERNEL(GSub, <GMat(GMat, GMat, int)>, "org.opencv.core.math.sub") {
57         static GMatDesc outMeta(GMatDesc a, GMatDesc b, int ddepth) {
58             if (ddepth == -1)
59             {
60                 // This macro should select a larger data depth from a and b
61                 // considering the number of channels in the same
62                 // FIXME!!! Clarify if it is valid for sub()
63                 GAPI_Assert(a.chan == b.chan);
64                 ddepth = std::max(a.depth, b.depth);
65             }
66             return a.withDepth(ddepth);
67         }
68     };
69
70     G_TYPED_KERNEL(GSubC, <GMat(GMat, GScalar, int)>, "org.opencv.core.math.subC") {
71         static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) {
72             return a.withDepth(ddepth);
73         }
74     };
75
76     G_TYPED_KERNEL(GSubRC,<GMat(GScalar, GMat, int)>, "org.opencv.core.math.subRC") {
77         static GMatDesc outMeta(GScalarDesc, GMatDesc b, int ddepth) {
78             return b.withDepth(ddepth);
79         }
80     };
81
82     G_TYPED_KERNEL(GMul, <GMat(GMat, GMat, double, int)>, "org.opencv.core.math.mul") {
83         static GMatDesc outMeta(GMatDesc a, GMatDesc, double, int ddepth) {
84             return a.withDepth(ddepth);
85         }
86     };
87
88     G_TYPED_KERNEL(GMulCOld, <GMat(GMat, double, int)>, "org.opencv.core.math.mulCOld") {
89         static GMatDesc outMeta(GMatDesc a, double, int ddepth) {
90             return a.withDepth(ddepth);
91         }
92     };
93
94     G_TYPED_KERNEL(GMulC, <GMat(GMat, GScalar, int)>, "org.opencv.core.math.mulC"){
95         static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) {
96             return a.withDepth(ddepth);
97         }
98     };
99
100     G_TYPED_KERNEL(GMulS, <GMat(GMat, GScalar)>, "org.opencv.core.math.muls") {
101         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
102             return a;
103         }
104     }; // FIXME: Merge with MulC
105
106     G_TYPED_KERNEL(GDiv, <GMat(GMat, GMat, double, int)>, "org.opencv.core.math.div") {
107         static GMatDesc outMeta(GMatDesc a, GMatDesc b, double, int ddepth) {
108             if (ddepth == -1)
109             {
110                 GAPI_Assert(a.depth == b.depth);
111                 return b;
112             }
113             return a.withDepth(ddepth);
114         }
115     };
116
117     G_TYPED_KERNEL(GDivC, <GMat(GMat, GScalar, double, int)>, "org.opencv.core.math.divC") {
118         static GMatDesc outMeta(GMatDesc a, GScalarDesc, double, int ddepth) {
119             return a.withDepth(ddepth);
120         }
121     };
122
123     G_TYPED_KERNEL(GDivRC, <GMat(GScalar, GMat, double, int)>, "org.opencv.core.math.divRC") {
124         static GMatDesc outMeta(GScalarDesc, GMatDesc b, double, int ddepth) {
125             return b.withDepth(ddepth);
126         }
127     };
128
129     G_TYPED_KERNEL(GMean, <GScalar(GMat)>, "org.opencv.core.math.mean") {
130         static GScalarDesc outMeta(GMatDesc) {
131             return empty_scalar_desc();
132         }
133     };
134
135     G_TYPED_KERNEL_M(GPolarToCart, <GMat2(GMat, GMat, bool)>, "org.opencv.core.math.polarToCart") {
136         static std::tuple<GMatDesc, GMatDesc> outMeta(GMatDesc, GMatDesc a, bool) {
137             return std::make_tuple(a, a);
138         }
139     };
140
141     G_TYPED_KERNEL_M(GCartToPolar, <GMat2(GMat, GMat, bool)>, "org.opencv.core.math.cartToPolar") {
142         static std::tuple<GMatDesc, GMatDesc> outMeta(GMatDesc x, GMatDesc, bool) {
143             return std::make_tuple(x, x);
144         }
145     };
146
147     G_TYPED_KERNEL(GPhase, <GMat(GMat, GMat, bool)>, "org.opencv.core.math.phase") {
148         static GMatDesc outMeta(const GMatDesc &inx, const GMatDesc &, bool) {
149             return inx;
150         }
151     };
152
153     G_TYPED_KERNEL(GMask, <GMat(GMat,GMat)>, "org.opencv.core.pixelwise.mask") {
154         static GMatDesc outMeta(GMatDesc in, GMatDesc) {
155             return in;
156         }
157     };
158
159     G_TYPED_KERNEL(GCmpGT, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.compare.cmpGT") {
160         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
161             return a.withDepth(CV_8U);
162         }
163     };
164
165     G_TYPED_KERNEL(GCmpGE, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.compare.cmpGE") {
166         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
167             return a.withDepth(CV_8U);
168         }
169     };
170
171     G_TYPED_KERNEL(GCmpLE, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.compare.cmpLE") {
172         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
173             return a.withDepth(CV_8U);
174         }
175     };
176
177     G_TYPED_KERNEL(GCmpLT, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.compare.cmpLT") {
178         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
179             return a.withDepth(CV_8U);
180         }
181     };
182
183     G_TYPED_KERNEL(GCmpEQ, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.compare.cmpEQ") {
184         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
185             return a.withDepth(CV_8U);
186         }
187     };
188
189     G_TYPED_KERNEL(GCmpNE, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.compare.cmpNE") {
190         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
191             return a.withDepth(CV_8U);
192         }
193     };
194
195     G_TYPED_KERNEL(GCmpGTScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpGTScalar"){
196         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
197             return a.withDepth(CV_8U);
198         }
199     };
200
201     G_TYPED_KERNEL(GCmpGEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpGEScalar"){
202         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
203             return a.withDepth(CV_8U);
204         }
205     };
206
207     G_TYPED_KERNEL(GCmpLEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpLEScalar"){
208         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
209             return a.withDepth(CV_8U);
210         }
211     };
212
213     G_TYPED_KERNEL(GCmpLTScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpLTScalar"){
214     static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
215             return a.withDepth(CV_8U);
216         }
217     };
218
219     G_TYPED_KERNEL(GCmpEQScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpEQScalar"){
220         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
221             return a.withDepth(CV_8U);
222         }
223     };
224
225     G_TYPED_KERNEL(GCmpNEScalar, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.compare.cmpNEScalar"){
226         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
227             return a.withDepth(CV_8U);
228         }
229     };
230
231     G_TYPED_KERNEL(GAnd, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.bitwise_and") {
232         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
233             return a;
234         }
235     };
236
237     G_TYPED_KERNEL(GAndS, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.bitwise_andS") {
238         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
239             return a;
240         }
241     };
242
243     G_TYPED_KERNEL(GOr, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.bitwise_or") {
244         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
245             return a;
246         }
247     };
248
249     G_TYPED_KERNEL(GOrS, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.bitwise_orS") {
250         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
251             return a;
252         }
253     };
254
255     G_TYPED_KERNEL(GXor, <GMat(GMat, GMat)>, "org.opencv.core.pixelwise.bitwise_xor") {
256         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
257             return a;
258         }
259     };
260
261     G_TYPED_KERNEL(GXorS, <GMat(GMat, GScalar)>, "org.opencv.core.pixelwise.bitwise_xorS") {
262         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
263             return a;
264         }
265     };
266
267     G_TYPED_KERNEL(GNot, <GMat(GMat)>, "org.opencv.core.pixelwise.bitwise_not") {
268         static GMatDesc outMeta(GMatDesc a) {
269             return a;
270         }
271     };
272
273     G_TYPED_KERNEL(GSelect, <GMat(GMat, GMat, GMat)>, "org.opencv.core.pixelwise.select") {
274         static GMatDesc outMeta(GMatDesc a, GMatDesc, GMatDesc) {
275             return a;
276         }
277     };
278
279     G_TYPED_KERNEL(GMin, <GMat(GMat, GMat)>, "org.opencv.core.matrixop.min") {
280         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
281             return a;
282         }
283     };
284
285     G_TYPED_KERNEL(GMax, <GMat(GMat, GMat)>, "org.opencv.core.matrixop.max") {
286         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
287             return a;
288         }
289     };
290
291     G_TYPED_KERNEL(GAbsDiff, <GMat(GMat, GMat)>, "org.opencv.core.matrixop.absdiff") {
292         static GMatDesc outMeta(GMatDesc a, GMatDesc) {
293             return a;
294         }
295     };
296
297     G_TYPED_KERNEL(GAbsDiffC, <GMat(GMat, GScalar)>, "org.opencv.core.matrixop.absdiffC") {
298         static GMatDesc outMeta(GMatDesc a, GScalarDesc) {
299             return a;
300         }
301     };
302
303     G_TYPED_KERNEL(GSum, <GScalar(GMat)>, "org.opencv.core.matrixop.sum") {
304         static GScalarDesc outMeta(GMatDesc) {
305             return empty_scalar_desc();
306         }
307     };
308
309     G_TYPED_KERNEL(GAddW, <GMat(GMat, double, GMat, double, double, int)>, "org.opencv.core.matrixop.addweighted") {
310         static GMatDesc outMeta(GMatDesc a, double, GMatDesc b, double, double, int ddepth) {
311             if (ddepth == -1)
312             {
313                 // OpenCV: When the input arrays in add/subtract/multiply/divide
314                 // functions have different depths, the output array depth must be
315                 // explicitly specified!
316                 // See artim_op() @ arithm.cpp
317                 GAPI_Assert(a.chan == b.chan);
318                 GAPI_Assert(a.depth == b.depth);
319                 return a;
320             }
321             return a.withDepth(ddepth);
322         }
323     };
324
325     G_TYPED_KERNEL(GNormL1, <GScalar(GMat)>, "org.opencv.core.matrixop.norml1") {
326         static GScalarDesc outMeta(GMatDesc) {
327             return empty_scalar_desc();
328         }
329     };
330
331     G_TYPED_KERNEL(GNormL2, <GScalar(GMat)>, "org.opencv.core.matrixop.norml2") {
332         static GScalarDesc outMeta(GMatDesc) {
333             return empty_scalar_desc();
334         }
335     };
336
337     G_TYPED_KERNEL(GNormInf, <GScalar(GMat)>, "org.opencv.core.matrixop.norminf") {
338         static GScalarDesc outMeta(GMatDesc) {
339             return empty_scalar_desc();
340         }
341     };
342
343     G_TYPED_KERNEL_M(GIntegral, <GMat2(GMat, int, int)>, "org.opencv.core.matrixop.integral") {
344         static std::tuple<GMatDesc, GMatDesc> outMeta(GMatDesc in, int sd, int sqd) {
345             return std::make_tuple(in.withSizeDelta(1,1).withDepth(sd),
346                                    in.withSizeDelta(1,1).withDepth(sqd));
347         }
348     };
349
350     G_TYPED_KERNEL(GThreshold, <GMat(GMat, GScalar, GScalar, int)>, "org.opencv.core.matrixop.threshold") {
351         static GMatDesc outMeta(GMatDesc in, GScalarDesc, GScalarDesc, int) {
352             return in;
353         }
354     };
355
356
357     G_TYPED_KERNEL_M(GThresholdOT, <GMatScalar(GMat, GScalar, int)>, "org.opencv.core.matrixop.thresholdOT") {
358         static std::tuple<GMatDesc,GScalarDesc> outMeta(GMatDesc in, GScalarDesc, int) {
359             return std::make_tuple(in, empty_scalar_desc());
360         }
361     };
362
363     G_TYPED_KERNEL(GInRange, <GMat(GMat, GScalar, GScalar)>, "org.opencv.core.matrixop.inrange") {
364         static GMatDesc outMeta(GMatDesc in, GScalarDesc, GScalarDesc) {
365             return in.withType(CV_8U, 1);
366         }
367     };
368
369     G_TYPED_KERNEL_M(GSplit3, <GMat3(GMat)>, "org.opencv.core.transform.split3") {
370         static std::tuple<GMatDesc, GMatDesc, GMatDesc> outMeta(GMatDesc in) {
371             const auto out_depth = in.depth;
372             const auto out_desc  = in.withType(out_depth, 1);
373             return std::make_tuple(out_desc, out_desc, out_desc);
374         }
375     };
376
377     G_TYPED_KERNEL_M(GSplit4, <GMat4(GMat)>,"org.opencv.core.transform.split4") {
378         static std::tuple<GMatDesc, GMatDesc, GMatDesc, GMatDesc> outMeta(GMatDesc in) {
379             const auto out_depth = in.depth;
380             const auto out_desc = in.withType(out_depth, 1);
381             return std::make_tuple(out_desc, out_desc, out_desc, out_desc);
382         }
383     };
384
385     G_TYPED_KERNEL(GResize, <GMat(GMat,Size,double,double,int)>, "org.opencv.core.transform.resize") {
386         static GMatDesc outMeta(GMatDesc in, Size sz, double fx, double fy, int) {
387             if (sz.width != 0 && sz.height != 0)
388             {
389                 return in.withSize(sz);
390             }
391             else
392             {
393                 GAPI_Assert(fx != 0. && fy != 0.);
394                 return in.withSize
395                     (Size(static_cast<int>(std::round(in.size.width  * fx)),
396                           static_cast<int>(std::round(in.size.height * fy))));
397             }
398         }
399     };
400
401     G_TYPED_KERNEL(GMerge3, <GMat(GMat,GMat,GMat)>, "org.opencv.core.transform.merge3") {
402         static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc) {
403             // Preserve depth and add channel component
404             return in.withType(in.depth, 3);
405         }
406     };
407
408     G_TYPED_KERNEL(GMerge4, <GMat(GMat,GMat,GMat,GMat)>, "org.opencv.core.transform.merge4") {
409         static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc, GMatDesc) {
410             // Preserve depth and add channel component
411             return in.withType(in.depth, 4);
412         }
413     };
414
415     G_TYPED_KERNEL(GRemap, <GMat(GMat, Mat, Mat, int, int, Scalar)>, "org.opencv.core.transform.remap") {
416         static GMatDesc outMeta(GMatDesc in, Mat m1, Mat, int, int, Scalar) {
417             return in.withSize(m1.size());
418         }
419     };
420
421     G_TYPED_KERNEL(GFlip, <GMat(GMat, int)>, "org.opencv.core.transform.flip") {
422         static GMatDesc outMeta(GMatDesc in, int) {
423             return in;
424         }
425     };
426
427     G_TYPED_KERNEL(GCrop, <GMat(GMat, Rect)>, "org.opencv.core.transform.crop") {
428         static GMatDesc outMeta(GMatDesc in, Rect rc) {
429             return in.withSize(Size(rc.width, rc.height));
430         }
431     };
432
433     G_TYPED_KERNEL(GConcatHor, <GMat(GMat, GMat)>, "org.opencv.imgproc.transform.concatHor") {
434         static GMatDesc outMeta(GMatDesc l, GMatDesc r) {
435             return l.withSizeDelta(+r.size.width, 0);
436         }
437     };
438
439     G_TYPED_KERNEL(GConcatVert, <GMat(GMat, GMat)>, "org.opencv.imgproc.transform.concatVert") {
440         static GMatDesc outMeta(GMatDesc t, GMatDesc b) {
441             return t.withSizeDelta(0, +b.size.height);
442         }
443     };
444
445     G_TYPED_KERNEL(GLUT, <GMat(GMat, Mat)>, "org.opencv.core.transform.LUT") {
446         static GMatDesc outMeta(GMatDesc in, Mat) {
447             return in;
448         }
449     };
450
451     G_TYPED_KERNEL(GConvertTo, <GMat(GMat, int, double, double)>, "org.opencv.core.transform.convertTo") {
452         static GMatDesc outMeta(GMatDesc in, int rdepth, double, double) {
453             return rdepth < 0 ? in : in.withDepth(rdepth);
454         }
455     };
456
457     G_TYPED_KERNEL(GSqrt, <GMat(GMat)>, "org.opencv.core.math.sqrt") {
458         static GMatDesc outMeta(GMatDesc in) {
459             return in;
460         }
461     };
462 }
463
464 //! @addtogroup gapi_math
465 //! @{
466
467 /** @brief Calculates the per-element sum of two matrices.
468
469 The function add calculates sum of two matrices of the same size and the same number of channels:
470 \f[\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) +  \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f]
471
472 The function can be replaced with matrix expressions:
473     \f[\texttt{dst} =  \texttt{src1} + \texttt{src2}\f]
474
475 The input matrices and the output matrix can all have the same or different depths. For example, you
476 can add a 16-bit unsigned matrix to a 8-bit signed matrix and store the sum as a 32-bit
477 floating-point matrix. Depth of the output matrix is determined by the ddepth parameter.
478 If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have
479 the same depth as the input matrices.
480
481 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
482
483 @note Function textual ID is "org.opencv.core.math.add"
484 @param src1 first input matrix.
485 @param src2 second input matrix.
486 @param ddepth optional depth of the output matrix.
487 @sa sub, addWeighted
488 */
489 GAPI_EXPORTS GMat add(const GMat& src1, const GMat& src2, int ddepth = -1);
490
491 /** @brief Calculates the per-element sum of matrix and given scalar.
492
493 The function addC adds a given scalar value to each element of given matrix.
494 The function can be replaced with matrix expressions:
495
496     \f[\texttt{dst} =  \texttt{src1} + \texttt{c}\f]
497
498 Depth of the output matrix is determined by the ddepth parameter.
499 If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix.
500 The matrices can be single or multi channel. Output matrix must have the same size and number of channels as the input matrix.
501
502 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
503
504 @note Function textual ID is "org.opencv.core.math.addC"
505 @param src1 first input matrix.
506 @param c scalar value to be added.
507 @param ddepth optional depth of the output matrix.
508 @sa sub, addWeighted
509 */
510 GAPI_EXPORTS GMat addC(const GMat& src1, const GScalar& c, int ddepth = -1);
511 //! @overload
512 GAPI_EXPORTS GMat addC(const GScalar& c, const GMat& src1, int ddepth = -1);
513
514 /** @brief Calculates the per-element difference between two matrices.
515
516 The function sub calculates difference between two matrices, when both matrices have the same size and the same number of
517 channels:
518     \f[\texttt{dst}(I) =   \texttt{src1}(I) -  \texttt{src2}(I)\f]
519
520 The function can be replaced with matrix expressions:
521 \f[\texttt{dst} =   \texttt{src1} -  \texttt{src2}\f]
522
523 The input matrices and the output matrix can all have the same or different depths. For example, you
524 can subtract two 8-bit unsigned matrices store the result as a 16-bit signed matrix.
525 Depth of the output matrix is determined by the ddepth parameter.
526 If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have
527 the same depth as the input matrices. The matrices can be single or multi channel.
528
529 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
530
531 @note Function textual ID is "org.opencv.core.math.sub"
532 @param src1 first input matrix.
533 @param src2 second input matrix.
534 @param ddepth optional depth of the output matrix.
535 @sa  add, addC
536   */
537 GAPI_EXPORTS GMat sub(const GMat& src1, const GMat& src2, int ddepth = -1);
538
539 /** @brief Calculates the per-element difference between matrix and given scalar.
540
541 The function can be replaced with matrix expressions:
542     \f[\texttt{dst} =  \texttt{src} - \texttt{c}\f]
543
544 Depth of the output matrix is determined by the ddepth parameter.
545 If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix.
546 The matrices can be single or multi channel. Output matrix must have the same size as src.
547
548 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
549
550 @note Function textual ID is "org.opencv.core.math.subC"
551 @param src first input matrix.
552 @param c scalar value to subtracted.
553 @param ddepth optional depth of the output matrix.
554 @sa  add, addC, subRC
555   */
556 GAPI_EXPORTS GMat subC(const GMat& src, const GScalar& c, int ddepth = -1);
557
558 /** @brief Calculates the per-element difference between given scalar and the matrix.
559
560 The function can be replaced with matrix expressions:
561     \f[\texttt{dst} =  \texttt{val} - \texttt{src}\f]
562
563 Depth of the output matrix is determined by the ddepth parameter.
564 If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix.
565 The matrices can be single or multi channel. Output matrix must have the same size as src.
566
567 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
568
569 @note Function textual ID is "org.opencv.core.math.subRC"
570 @param c scalar value to subtract from.
571 @param src input matrix to be subtracted.
572 @param ddepth optional depth of the output matrix.
573 @sa  add, addC, subC
574   */
575 GAPI_EXPORTS GMat subRC(const GScalar& c, const GMat& src, int ddepth = -1);
576
577 /** @brief Calculates the per-element scaled product of two matrices.
578
579 The function mul calculates the per-element product of two matrices:
580
581 \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I)  \cdot \texttt{src2} (I))\f]
582
583 If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have
584 the same depth as the input matrices. The matrices can be single or multi channel.
585 Output matrix must have the same size as input matrices.
586
587 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
588
589 @note Function textual ID is "org.opencv.core.math.mul"
590 @param src1 first input matrix.
591 @param src2 second input matrix of the same size and the same depth as src1.
592 @param scale optional scale factor.
593 @param ddepth optional depth of the output matrix.
594 @sa add, sub, div, addWeighted
595 */
596 GAPI_EXPORTS GMat mul(const GMat& src1, const GMat& src2, double scale = 1.0, int ddepth = -1);
597
598 /** @brief Multiplies matrix by scalar.
599
600 The function mulC multiplies each element of matrix src by given scalar value:
601
602 \f[\texttt{dst} (I)= \texttt{saturate} (  \texttt{src1} (I)  \cdot \texttt{multiplier} )\f]
603
604 The matrices can be single or multi channel. Output matrix must have the same size as src.
605
606 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
607
608 @note Function textual ID is "org.opencv.core.math.mulC"
609 @param src input matrix.
610 @param multiplier factor to be multiplied.
611 @param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth.
612 @sa add, sub, div, addWeighted
613 */
614 GAPI_EXPORTS GMat mulC(const GMat& src, double multiplier, int ddepth = -1);
615 //! @overload
616 GAPI_EXPORTS GMat mulC(const GMat& src, const GScalar& multiplier, int ddepth = -1);   // FIXME: merge with mulc
617 //! @overload
618 GAPI_EXPORTS GMat mulC(const GScalar& multiplier, const GMat& src, int ddepth = -1);   // FIXME: merge with mulc
619
620 /** @brief Performs per-element division of two matrices.
621
622 The function divides one matrix by another:
623 \f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f]
624
625 When src2(I) is zero, dst(I) will also be zero. Different channels of
626 multi-channel matrices are processed independently.
627 The matrices can be single or multi channel. Output matrix must have the same size and depth as src.
628
629 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
630
631 @note Function textual ID is "org.opencv.core.math.div"
632 @param src1 first input matrix.
633 @param src2 second input matrix of the same size and depth as src1.
634 @param scale scalar factor.
635 @param ddepth optional depth of the output matrix; you can only pass -1 when src1.depth() == src2.depth().
636 @sa  mul, add, sub
637 */
638 GAPI_EXPORTS GMat div(const GMat& src1, const GMat& src2, double scale, int ddepth = -1);
639
640 /** @brief Divides matrix by scalar.
641
642 The function divC divides each element of matrix src by given scalar value:
643
644 \f[\texttt{dst(I) = saturate(src(I)*scale/divisor)}\f]
645
646 When divisor is zero, dst(I) will also be zero. Different channels of
647 multi-channel matrices are processed independently.
648 The matrices can be single or multi channel. Output matrix must have the same size and depth as src.
649
650 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
651
652 @note Function textual ID is "org.opencv.core.math.divC"
653 @param src input matrix.
654 @param divisor number to be divided by.
655 @param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth.
656 @param scale scale factor.
657 @sa add, sub, div, addWeighted
658 */
659 GAPI_EXPORTS GMat divC(const GMat& src, const GScalar& divisor, double scale, int ddepth = -1);
660
661 /** @brief Divides scalar by matrix.
662
663 The function divRC divides given scalar by each element of matrix src and keep the division result in new matrix of the same size and type as src:
664
665 \f[\texttt{dst(I) = saturate(divident*scale/src(I))}\f]
666
667 When src(I) is zero, dst(I) will also be zero. Different channels of
668 multi-channel matrices are processed independently.
669 The matrices can be single or multi channel. Output matrix must have the same size and depth as src.
670
671 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
672
673 @note Function textual ID is "org.opencv.core.math.divRC"
674 @param src input matrix.
675 @param divident number to be divided.
676 @param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth.
677 @param scale scale factor
678 @sa add, sub, div, addWeighted
679 */
680 GAPI_EXPORTS GMat divRC(const GScalar& divident, const GMat& src, double scale, int ddepth = -1);
681
682 /** @brief Applies a mask to a matrix.
683
684 The function mask set value from given matrix if the corresponding pixel value in mask matrix set to true,
685 and set the matrix value to 0 overwise.
686
687 Supported src matrix data types are @ref CV_8UC1, @ref CV_16SC1, @ref CV_16UC1. Supported mask data type is @ref CV_8UC1.
688
689 @note Function textual ID is "org.opencv.core.math.mask"
690 @param src input matrix.
691 @param mask input mask matrix.
692 */
693 GAPI_EXPORTS GMat mask(const GMat& src, const GMat& mask);
694
695 /** @brief Calculates an average (mean) of matrix elements.
696
697 The function mean calculates the mean value M of matrix elements,
698 independently for each channel, and return it.
699
700 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
701
702 @note Function textual ID is "org.opencv.core.math.mean"
703 @param src input matrix.
704 */
705 GAPI_EXPORTS GScalar mean(const GMat& src);
706
707 /** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle.
708
709 The function polarToCart calculates the Cartesian coordinates of each 2D
710 vector represented by the corresponding elements of magnitude and angle:
711 \f[\begin{array}{l} \texttt{x} (I) =  \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) =  \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\f]
712
713 The relative accuracy of the estimated coordinates is about 1e-6.
714
715 First output is a matrix of x-coordinates of 2D vectors.
716 Second output is a matrix of y-coordinates of 2D vectors.
717 Both output must have the same size and depth as input matrices.
718
719 @note Function textual ID is "org.opencv.core.math.polarToCart"
720
721 @param magnitude input floating-point @ref CV_32FC1 matrix (1xN) of magnitudes of 2D vectors;
722 @param angle input floating-point @ref CV_32FC1 matrix (1xN) of angles of 2D vectors.
723 @param angleInDegrees when true, the input angles are measured in
724 degrees, otherwise, they are measured in radians.
725 @sa cartToPolar, exp, log, pow, sqrt
726 */
727 GAPI_EXPORTS std::tuple<GMat, GMat> polarToCart(const GMat& magnitude, const GMat& angle,
728                                               bool angleInDegrees = false);
729
730 /** @brief Calculates the magnitude and angle of 2D vectors.
731
732 The function cartToPolar calculates either the magnitude, angle, or both
733 for every 2D vector (x(I),y(I)):
734 \f[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f]
735
736 The angles are calculated with accuracy about 0.3 degrees. For the point
737 (0,0), the angle is set to 0.
738
739 First output is a matrix of magnitudes of the same size and depth as input x.
740 Second output is a matrix of angles that has the same size and depth as
741 x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
742
743 @note Function textual ID is "org.opencv.core.math.cartToPolar"
744
745 @param x matrix of @ref CV_32FC1 x-coordinates.
746 @param y array of @ref CV_32FC1 y-coordinates.
747 @param angleInDegrees a flag, indicating whether the angles are measured
748 in radians (which is by default), or in degrees.
749 @sa polarToCart
750 */
751 GAPI_EXPORTS std::tuple<GMat, GMat> cartToPolar(const GMat& x, const GMat& y,
752                                               bool angleInDegrees = false);
753
754 /** @brief Calculates the rotation angle of 2D vectors.
755
756 The function cv::phase calculates the rotation angle of each 2D vector that
757 is formed from the corresponding elements of x and y :
758 \f[\texttt{angle} (I) =  \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f]
759
760 The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
761 the corresponding angle(I) is set to 0.
762 @param x input floating-point array of x-coordinates of 2D vectors.
763 @param y input array of y-coordinates of 2D vectors; it must have the
764 same size and the same type as x.
765 @param angleInDegrees when true, the function calculates the angle in
766 degrees, otherwise, they are measured in radians.
767 @return array of vector angles; it has the same size and same type as x.
768 */
769 GAPI_EXPORTS GMat phase(const GMat& x, const GMat &y, bool angleInDegrees = false);
770
771 /** @brief Calculates a square root of array elements.
772
773 The function cv::gapi::sqrt calculates a square root of each input array element.
774 In case of multi-channel arrays, each channel is processed
775 independently. The accuracy is approximately the same as of the built-in
776 std::sqrt .
777 @param src input floating-point array.
778 @return output array of the same size and type as src.
779 */
780 GAPI_EXPORTS GMat sqrt(const GMat &src);
781
782 //! @} gapi_math
783 //!
784 //! @addtogroup gapi_pixelwise
785 //! @{
786
787 /** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are greater compare to elements in second.
788
789 The function compares elements of two matrices src1 and src2 of the same size:
790     \f[\texttt{dst} (I) =  \texttt{src1} (I)  > \texttt{src2} (I)\f]
791
792 When the comparison result is true, the corresponding element of output
793 array is set to 255. The comparison operations can be replaced with the
794 equivalent matrix expressions:
795 \f[\texttt{dst} =   \texttt{src1} > \texttt{src2}\f]
796
797 Output matrix of depth @ref CV_8U must have the same size and the same number of channels as
798     the input matrices/matrix.
799
800 Supported input matrix data types are @ref CV_8UC1, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
801
802 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGT"
803 @param src1 first input matrix.
804 @param src2 second input matrix/scalar of the same depth as first input matrix.
805 @sa min, max, threshold, cmpLE, cmpGE, cmpLS
806 */
807 GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GMat& src2);
808 /** @overload
809 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGTScalar"
810 */
811 GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GScalar& src2);
812
813 /** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less than elements in second.
814
815 The function compares elements of two matrices src1 and src2 of the same size:
816     \f[\texttt{dst} (I) =  \texttt{src1} (I)  < \texttt{src2} (I)\f]
817
818 When the comparison result is true, the corresponding element of output
819 array is set to 255. The comparison operations can be replaced with the
820 equivalent matrix expressions:
821     \f[\texttt{dst} =   \texttt{src1} < \texttt{src2}\f]
822
823 Output matrix of depth @ref CV_8U must have the same size and the same number of channels as
824     the input matrices/matrix.
825
826 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
827
828 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLT"
829 @param src1 first input matrix.
830 @param src2 second input matrix/scalar of the same depth as first input matrix.
831 @sa min, max, threshold, cmpLE, cmpGE, cmpGT
832 */
833 GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GMat& src2);
834 /** @overload
835 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLTScalar"
836 */
837 GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GScalar& src2);
838
839 /** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are greater or equal compare to elements in second.
840
841 The function compares elements of two matrices src1 and src2 of the same size:
842     \f[\texttt{dst} (I) =  \texttt{src1} (I)  >= \texttt{src2} (I)\f]
843
844 When the comparison result is true, the corresponding element of output
845 array is set to 255. The comparison operations can be replaced with the
846 equivalent matrix expressions:
847     \f[\texttt{dst} =   \texttt{src1} >= \texttt{src2}\f]
848
849 Output matrix of depth @ref CV_8U must have the same size and the same number of channels as
850     the input matrices.
851
852 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
853
854 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGE"
855 @param src1 first input matrix.
856 @param src2 second input matrix/scalar of the same depth as first input matrix.
857 @sa min, max, threshold, cmpLE, cmpGT, cmpLS
858 */
859 GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GMat& src2);
860 /** @overload
861 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLGEcalar"
862 */
863 GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GScalar& src2);
864
865 /** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less or equal compare to elements in second.
866
867 The function compares elements of two matrices src1 and src2 of the same size:
868     \f[\texttt{dst} (I) =  \texttt{src1} (I)  <=  \texttt{src2} (I)\f]
869
870 When the comparison result is true, the corresponding element of output
871 array is set to 255. The comparison operations can be replaced with the
872 equivalent matrix expressions:
873     \f[\texttt{dst} =   \texttt{src1} <= \texttt{src2}\f]
874
875 Output matrix of depth @ref CV_8U must have the same size and the same number of channels as
876     the input matrices.
877
878 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
879
880 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLE"
881 @param src1 first input matrix.
882 @param src2 second input matrix/scalar of the same depth as first input matrix.
883 @sa min, max, threshold, cmpGT, cmpGE, cmpLS
884 */
885 GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GMat& src2);
886 /** @overload
887 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLEScalar"
888 */
889 GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GScalar& src2);
890
891 /** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are equal to elements in second.
892
893 The function compares elements of two matrices src1 and src2 of the same size:
894     \f[\texttt{dst} (I) =  \texttt{src1} (I)  ==  \texttt{src2} (I)\f]
895
896 When the comparison result is true, the corresponding element of output
897 array is set to 255. The comparison operations can be replaced with the
898 equivalent matrix expressions:
899     \f[\texttt{dst} =   \texttt{src1} == \texttt{src2}\f]
900
901 Output matrix of depth @ref CV_8U must have the same size and the same number of channels as
902     the input matrices.
903
904 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
905
906 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpEQ"
907 @param src1 first input matrix.
908 @param src2 second input matrix/scalar of the same depth as first input matrix.
909 @sa min, max, threshold, cmpNE
910 */
911 GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GMat& src2);
912 /** @overload
913 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpEQScalar"
914 */
915 GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GScalar& src2);
916
917 /** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are not equal to elements in second.
918
919 The function compares elements of two matrices src1 and src2 of the same size:
920     \f[\texttt{dst} (I) =  \texttt{src1} (I)  !=  \texttt{src2} (I)\f]
921
922 When the comparison result is true, the corresponding element of output
923 array is set to 255. The comparison operations can be replaced with the
924 equivalent matrix expressions:
925     \f[\texttt{dst} =   \texttt{src1} != \texttt{src2}\f]
926
927 Output matrix of depth @ref CV_8U must have the same size and the same number of channels as
928     the input matrices.
929
930 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
931
932 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpNE"
933 @param src1 first input matrix.
934 @param src2 second input matrix/scalar of the same depth as first input matrix.
935 @sa min, max, threshold, cmpEQ
936 */
937 GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GMat& src2);
938 /** @overload
939 @note Function textual ID is "org.opencv.core.pixelwise.compare.cmpNEScalar"
940 */
941 GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GScalar& src2);
942
943 /** @brief computes bitwise conjunction of the two matrixes (src1 & src2)
944 Calculates the per-element bit-wise logical conjunction of two matrices of the same size.
945
946 In case of floating-point matrices, their machine-specific bit
947 representations (usually IEEE754-compliant) are used for the operation.
948 In case of multi-channel matrices, each channel is processed
949 independently. Output matrix must have the same size and depth as the input
950 matrices.
951
952 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
953
954 @note Function textual ID is "org.opencv.core.pixelwise.bitwise_and"
955
956 @param src1 first input matrix.
957 @param src2 second input matrix.
958 */
959 GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GMat& src2);
960 /** @overload
961 @note Function textual ID is "org.opencv.core.pixelwise.compare.bitwise_andS"
962 @param src1 first input matrix.
963 @param src2 scalar, which will be per-lemenetly conjuncted with elements of src1.
964 */
965 GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GScalar& src2);
966
967 /** @brief computes bitwise disjunction of the two matrixes (src1 | src2)
968 Calculates the per-element bit-wise logical disjunction of two matrices of the same size.
969
970 In case of floating-point matrices, their machine-specific bit
971 representations (usually IEEE754-compliant) are used for the operation.
972 In case of multi-channel matrices, each channel is processed
973 independently. Output matrix must have the same size and depth as the input
974 matrices.
975
976 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
977
978 @note Function textual ID is "org.opencv.core.pixelwise.bitwise_or"
979
980 @param src1 first input matrix.
981 @param src2 second input matrix.
982 */
983 GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GMat& src2);
984 /** @overload
985 @note Function textual ID is "org.opencv.core.pixelwise.compare.bitwise_orS"
986 @param src1 first input matrix.
987 @param src2 scalar, which will be per-lemenetly disjuncted with elements of src1.
988 */
989 GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GScalar& src2);
990
991
992 /** @brief computes bitwise logical "exclusive or" of the two matrixes (src1 ^ src2)
993 Calculates the per-element bit-wise logical "exclusive or" of two matrices of the same size.
994
995 In case of floating-point matrices, their machine-specific bit
996 representations (usually IEEE754-compliant) are used for the operation.
997 In case of multi-channel matrices, each channel is processed
998 independently. Output matrix must have the same size and depth as the input
999 matrices.
1000
1001 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1002
1003 @note Function textual ID is "org.opencv.core.pixelwise.bitwise_xor"
1004
1005 @param src1 first input matrix.
1006 @param src2 second input matrix.
1007 */
1008 GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GMat& src2);
1009 /** @overload
1010 @note Function textual ID is "org.opencv.core.pixelwise.compare.bitwise_xorS"
1011 @param src1 first input matrix.
1012 @param src2 scalar, for which per-lemenet "logical or" operation on elements of src1 will be performed.
1013 */
1014 GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GScalar& src2);
1015
1016
1017 /** @brief Inverts every bit of an array.
1018 The function bitwise_not calculates per-element bit-wise inversion of the input
1019 matrix:
1020 \f[\texttt{dst} (I) =  \neg \texttt{src} (I)\f]
1021
1022 In case of floating-point matrices, their machine-specific bit
1023 representations (usually IEEE754-compliant) are used for the operation.
1024 In case of multi-channel matrices, each channel is processed
1025 independently. Output matrix must have the same size and depth as the input
1026 matrix.
1027
1028 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1029
1030 @note Function textual ID is "org.opencv.core.pixelwise.bitwise_not"
1031
1032 @param src input matrix.
1033 */
1034 GAPI_EXPORTS GMat bitwise_not(const GMat& src);
1035
1036 /** @brief Select values from either first or second of input matrices by given mask.
1037 The function set to the output matrix either the value from the first input matrix if corresponding value of mask matrix is 255,
1038  or value from the second input matrix (if value of mask matrix set to 0).
1039
1040 Input mask matrix must be of @ref CV_8UC1 type, two other inout matrices and output matrix should be of the same type. The size should
1041 be the same for all input and output matrices.
1042 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1043
1044 @note Function textual ID is "org.opencv.core.pixelwise.select"
1045
1046 @param src1 first input matrix.
1047 @param src2 second input matrix.
1048 @param mask mask input matrix.
1049 */
1050 GAPI_EXPORTS GMat select(const GMat& src1, const GMat& src2, const GMat& mask);
1051
1052 //! @} gapi_pixelwise
1053
1054
1055 //! @addtogroup gapi_matrixop
1056 //! @{
1057 /** @brief Calculates per-element minimum of two matrices.
1058
1059 The function min calculates the per-element minimum of two matrices of the same size, number of channels and depth:
1060 \f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f]
1061     where I is a multi-dimensional index of matrix elements. In case of
1062     multi-channel matrices, each channel is processed independently.
1063 Output matrix must be of the same size and depth as src1.
1064
1065 Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1066
1067 @note Function textual ID is "org.opencv.core.matrixop.min"
1068 @param src1 first input matrix.
1069 @param src2 second input matrix of the same size and depth as src1.
1070 @sa max, compareEqual, compareLess, compareLessEqual
1071 */
1072 GAPI_EXPORTS GMat min(const GMat& src1, const GMat& src2);
1073
1074 /** @brief Calculates per-element maximum of two matrices.
1075
1076 The function max calculates the per-element maximum of two matrices of the same size, number of channels and depth:
1077 \f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f]
1078     where I is a multi-dimensional index of matrix elements. In case of
1079     multi-channel matrices, each channel is processed independently.
1080 Output matrix must be of the same size and depth as src1.
1081
1082 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1083
1084 @note Function textual ID is "org.opencv.core.matrixop.max"
1085 @param src1 first input matrix.
1086 @param src2 second input matrix of the same size and depth as src1.
1087 @sa min, compare, compareEqual, compareGreater, compareGreaterEqual
1088 */
1089 GAPI_EXPORTS GMat max(const GMat& src1, const GMat& src2);
1090
1091 /** @brief Calculates the per-element absolute difference between two matrices.
1092
1093 The function absDiff calculates absolute difference between two matrices of the same size and depth:
1094     \f[\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1}(I) -  \texttt{src2}(I)|)\f]
1095     where I is a multi-dimensional index of matrix elements. In case of
1096     multi-channel matrices, each channel is processed independently.
1097 Output matrix must have the same size and depth as input matrices.
1098
1099 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1100
1101 @note Function textual ID is "org.opencv.core.matrixop.absdiff"
1102 @param src1 first input matrix.
1103 @param src2 second input matrix.
1104 @sa abs
1105 */
1106 GAPI_EXPORTS GMat absDiff(const GMat& src1, const GMat& src2);
1107
1108 /** @brief Calculates absolute value of matrix elements.
1109
1110 The function abs calculates absolute difference between matrix elements and given scalar value:
1111     \f[\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1}(I) -  \texttt{matC}(I)|)\f]
1112     where matC is constructed from given scalar c and has the same sizes and depth as input matrix src.
1113
1114 Output matrix must be of the same size and depth as src.
1115
1116 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1117
1118 @note Function textual ID is "org.opencv.core.matrixop.absdiffC"
1119 @param src input matrix.
1120 @param c scalar to be subtracted.
1121 @sa min, max
1122 */
1123 GAPI_EXPORTS GMat absDiffC(const GMat& src, const GScalar& c);
1124
1125 /** @brief Calculates sum of all matrix elements.
1126
1127 The function sum calculates sum of all matrix elements, independently for each channel.
1128
1129 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1130
1131 @note Function textual ID is "org.opencv.core.matrixop.sum"
1132 @param src input matrix.
1133 @sa min, max
1134 */
1135 GAPI_EXPORTS GScalar sum(const GMat& src);
1136
1137 /** @brief Calculates the weighted sum of two matrices.
1138
1139 The function addWeighted calculates the weighted sum of two matrices as follows:
1140 \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} +  \texttt{src2} (I)* \texttt{beta} +  \texttt{gamma} )\f]
1141 where I is a multi-dimensional index of array elements. In case of multi-channel matrices, each
1142 channel is processed independently.
1143
1144 The function can be replaced with a matrix expression:
1145     \f[\texttt{dst}(I) =  \texttt{alpha} * \texttt{src1}(I) - \texttt{beta} * \texttt{src2}(I) + \texttt{gamma} \f]
1146
1147 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1148
1149 @note Function textual ID is "org.opencv.core.matrixop.addweighted"
1150 @param src1 first input matrix.
1151 @param alpha weight of the first matrix elements.
1152 @param src2 second input matrix of the same size and channel number as src1.
1153 @param beta weight of the second matrix elements.
1154 @param gamma scalar added to each sum.
1155 @param ddepth optional depth of the output matrix.
1156 @sa  add, sub
1157 */
1158 GAPI_EXPORTS GMat addWeighted(const GMat& src1, double alpha, const GMat& src2, double beta, double gamma, int ddepth = -1);
1159
1160 /** @brief Calculates the  absolute L1 norm of a matrix.
1161
1162 This version of normL1 calculates the absolute L1 norm of src.
1163
1164 As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
1165 The \f$ L_{1} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
1166 is calculated as follows
1167 \f{align*}
1168     \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
1169 \f}
1170 and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
1171 \f{align*}
1172     \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
1173 \f}
1174
1175 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1176
1177 @note Function textual ID is "org.opencv.core.matrixop.norml1"
1178 @param src input matrix.
1179 @sa normL2, normInf
1180 */
1181 GAPI_EXPORTS GScalar normL1(const GMat& src);
1182
1183 /** @brief Calculates the absolute L2 norm of a matrix.
1184
1185 This version of normL2 calculates the absolute L2 norm of src.
1186
1187 As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
1188 The \f$ L_{2} \f$  norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
1189 is calculated as follows
1190 \f{align*}
1191     \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
1192 \f}
1193 and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
1194 \f{align*}
1195     \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
1196 \f}
1197
1198 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1199 @note Function textual ID is "org.opencv.core.matrixop.norml2"
1200 @param src input matrix.
1201 @sa normL1, normInf
1202 */
1203 GAPI_EXPORTS GScalar normL2(const GMat& src);
1204
1205 /** @brief Calculates the absolute infinite norm of a matrix.
1206
1207 This version of normInf calculates the absolute infinite norm of src.
1208
1209 As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
1210 The \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
1211 is calculated as follows
1212 \f{align*}
1213     \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
1214 \f}
1215 and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
1216 \f{align*}
1217     \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
1218 \f}
1219
1220 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1221
1222 @note Function textual ID is "org.opencv.core.matrixop.norminf"
1223 @param src input matrix.
1224 @sa normL1, normL2
1225 */
1226 GAPI_EXPORTS GScalar normInf(const GMat& src);
1227
1228 /** @brief Calculates the integral of an image.
1229
1230 The function calculates one or more integral images for the source image as follows:
1231
1232 \f[\texttt{sum} (X,Y) =  \sum _{x<X,y<Y}  \texttt{image} (x,y)\f]
1233
1234 \f[\texttt{sqsum} (X,Y) =  \sum _{x<X,y<Y}  \texttt{image} (x,y)^2\f]
1235
1236 The function return integral image as \f$(W+1)\times (H+1)\f$ , 32-bit integer or floating-point (32f or 64f) and
1237  integral image for squared pixel values; it is \f$(W+1)\times (H+)\f$, double-precision floating-point (64f) array.
1238
1239 @note Function textual ID is "org.opencv.core.matrixop.integral"
1240
1241 @param src input image.
1242 @param sdepth desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or
1243 CV_64F.
1244 @param sqdepth desired depth of the integral image of squared pixel values, CV_32F or CV_64F.
1245  */
1246 GAPI_EXPORTS std::tuple<GMat, GMat> integral(const GMat& src, int sdepth = -1, int sqdepth = -1);
1247
1248 /** @brief Applies a fixed-level threshold to each matrix element.
1249
1250 The function applies fixed-level thresholding to a single- or multiple-channel matrix.
1251 The function is typically used to get a bi-level (binary) image out of a grayscale image ( cmp funtions could be also used for
1252 this purpose) or for removing a noise, that is, filtering out pixels with too small or too large
1253 values. There are several depths of thresholding supported by the function. They are determined by
1254 depth parameter.
1255
1256 Also, the special values cv::THRESH_OTSU or cv::THRESH_TRIANGLE may be combined with one of the
1257 above values. In these cases, the function determines the optimal threshold value using the Otsu's
1258 or Triangle algorithm and uses it instead of the specified thresh . The function returns the
1259 computed threshold value in addititon to thresholded matrix.
1260 The Otsu's and Triangle methods are implemented only for 8-bit matrices.
1261
1262 Input image should be single channel only in case of cv::THRESH_OTSU or cv::THRESH_TRIANGLE flags.
1263 Output matrix must be of the same size and depth as src.
1264
1265 @note Function textual ID is "org.opencv.core.matrixop.threshold"
1266
1267 @param src input matrix (@ref CV_8UC1, @ref CV_8UC3, or @ref CV_32FC1).
1268 @param thresh threshold value.
1269 @param maxval maximum value to use with the cv::THRESH_BINARY and cv::THRESH_BINARY_INV thresholding
1270 depths.
1271 @param depth thresholding depth (see the cv::ThresholdTypes).
1272
1273 @sa min, max, cmpGT, cmpLE, cmpGE, cmpLS
1274  */
1275 GAPI_EXPORTS GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int depth);
1276 /** @overload
1277 This function appicable for all threshold depths except CV_THRESH_OTSU and CV_THRESH_TRIANGLE
1278 @note Function textual ID is "org.opencv.core.matrixop.thresholdOT"
1279 */
1280 GAPI_EXPORTS std::tuple<GMat, GScalar> threshold(const GMat& src, const GScalar& maxval, int depth);
1281
1282 /** @brief Applies a range-level threshold to each matrix element.
1283
1284 The function applies range-level thresholding to a single- or multiple-channel matrix.
1285 It sets output pixel value to OxFF if the corresponding pixel value of input matrix is in specified range,or 0 otherwise.
1286
1287 Input and output matrices must be CV_8UC1.
1288
1289 @note Function textual ID is "org.opencv.core.matrixop.inRange"
1290
1291 @param src input matrix (CV_8UC1).
1292 @param threshLow lower boundary value.
1293 @param threshUp upper boundary value.
1294
1295 @sa threshold
1296  */
1297 GAPI_EXPORTS GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp);
1298
1299 //! @} gapi_matrixop
1300
1301 //! @addtogroup gapi_transform
1302 //! @{
1303 /** @brief Resizes an image.
1304
1305 The function resizes the image src down to or up to the specified size.
1306
1307 Output image size will have the size dsize (when dsize is non-zero) or the size computed from
1308 src.size(), fx, and fy; the depth of output is the same as of src.
1309
1310 If you want to resize src so that it fits the pre-created dst,
1311 you may call the function as follows:
1312 @code
1313     // explicitly specify dsize=dst.size(); fx and fy will be computed from that.
1314     resize(src, dst, dst.size(), 0, 0, interpolation);
1315 @endcode
1316 If you want to decimate the image by factor of 2 in each direction, you can call the function this
1317 way:
1318 @code
1319     // specify fx and fy and let the function compute the destination image size.
1320     resize(src, dst, Size(), 0.5, 0.5, interpolation);
1321 @endcode
1322 To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to
1323 enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR
1324 (faster but still looks OK).
1325
1326 @note Function textual ID is "org.opencv.core.transform.resize"
1327
1328 @param src input image.
1329 @param dsize output image size; if it equals zero, it is computed as:
1330  \f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f]
1331  Either dsize or both fx and fy must be non-zero.
1332 @param fx scale factor along the horizontal axis; when it equals 0, it is computed as
1333 \f[\texttt{(double)dsize.width/src.cols}\f]
1334 @param fy scale factor along the vertical axis; when it equals 0, it is computed as
1335 \f[\texttt{(double)dsize.height/src.rows}\f]
1336 @param interpolation interpolation method, see cv::InterpolationFlags
1337
1338 @sa  warpAffine, warpPerspective, remap
1339  */
1340 GAPI_EXPORTS GMat resize(const GMat& src, const Size& dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR);
1341
1342 /** @brief Creates one 3-channel (4-channel) matrix out of 3(4) single-channel ones.
1343
1344 The function merges several matrices to make a single multi-channel matrix. That is, each
1345 element of the output matrix will be a concatenation of the elements of the input matrices, where
1346 elements of i-th input matrix are treated as mv[i].channels()-element vectors.
1347 Input matrix must be of @ref CV_8UC3 (@ref CV_8UC4) type.
1348
1349 The function split3/split4 does the reverse operation.
1350
1351 @note Function textual ID for merge3 is "org.opencv.core.transform.merge3"
1352 @note Function textual ID for merge4 is "org.opencv.core.transform.merge4"
1353
1354 @param src1 first input matrix to be merged
1355 @param src2 second input matrix to be merged
1356 @param src3 third input matrix to be merged
1357 @param src4 fourth input matrix to be merged
1358 @sa  split4, split3
1359 */
1360 GAPI_EXPORTS GMat merge4(const GMat& src1, const GMat& src2, const GMat& src3, const GMat& src4);
1361 GAPI_EXPORTS GMat merge3(const GMat& src1, const GMat& src2, const GMat& src3);
1362
1363 /** @brief Divides a 3-channel (4-channel) matrix into 3(4) single-channel matrices.
1364
1365 The function splits a 3-channel (4-channel) matrix into 3(4) single-channel matrices:
1366 \f[\texttt{mv} [c](I) =  \texttt{src} (I)_c\f]
1367
1368 All output matrices must be in @ref CV_8UC1.
1369
1370 @note Function textual for split3 ID is "org.opencv.core.transform.split3"
1371 @note Function textual for split4 ID is "org.opencv.core.transform.split4"
1372
1373 @param src input @ref CV_8UC4 (@ref CV_8UC3) matrix.
1374 @sa merge3, merge4
1375 */
1376 GAPI_EXPORTS std::tuple<GMat, GMat, GMat,GMat> split4(const GMat& src);
1377 GAPI_EXPORTS std::tuple<GMat, GMat, GMat> split3(const GMat& src);
1378
1379 /** @brief Applies a generic geometrical transformation to an image.
1380
1381 The function remap transforms the source image using the specified map:
1382
1383 \f[\texttt{dst} (x,y) =  \texttt{src} (map_x(x,y),map_y(x,y))\f]
1384
1385 where values of pixels with non-integer coordinates are computed using one of available
1386 interpolation methods. \f$map_x\f$ and \f$map_y\f$ can be encoded as separate floating-point maps
1387 in \f$map_1\f$ and \f$map_2\f$ respectively, or interleaved floating-point maps of \f$(x,y)\f$ in
1388 \f$map_1\f$, or fixed-point maps created by using convertMaps. The reason you might want to
1389 convert from floating to fixed-point representations of a map is that they can yield much faster
1390 (\~2x) remapping operations. In the converted case, \f$map_1\f$ contains pairs (cvFloor(x),
1391 cvFloor(y)) and \f$map_2\f$ contains indices in a table of interpolation coefficients.
1392 Output image must be of the same size and depth as input one.
1393
1394 @note Function textual ID is "org.opencv.core.transform.remap"
1395
1396 @param src Source image.
1397 @param map1 The first map of either (x,y) points or just x values having the type CV_16SC2,
1398 CV_32FC1, or CV_32FC2.
1399 @param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map
1400 if map1 is (x,y) points), respectively.
1401 @param interpolation Interpolation method (see cv::InterpolationFlags). The method INTER_AREA is
1402 not supported by this function.
1403 @param borderMode Pixel extrapolation method (see cv::BorderTypes). When
1404 borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that
1405 corresponds to the "outliers" in the source image are not modified by the function.
1406 @param borderValue Value used in case of a constant border. By default, it is 0.
1407 @note
1408 Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
1409  */
1410 GAPI_EXPORTS GMat remap(const GMat& src, const Mat& map1, const Mat& map2,
1411                       int interpolation, int borderMode = BORDER_CONSTANT,
1412                       const Scalar& borderValue = Scalar());
1413
1414 /** @brief Flips a 2D matrix around vertical, horizontal, or both axes.
1415
1416 The function flips the matrix in one of three different ways (row
1417 and column indices are 0-based):
1418 \f[\texttt{dst} _{ij} =
1419 \left\{
1420 \begin{array}{l l}
1421 \texttt{src} _{\texttt{src.rows}-i-1,j} & if\;  \texttt{flipCode} = 0 \\
1422 \texttt{src} _{i, \texttt{src.cols} -j-1} & if\;  \texttt{flipCode} > 0 \\
1423 \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\
1424 \end{array}
1425 \right.\f]
1426 The example scenarios of using the function are the following:
1427 *   Vertical flipping of the image (flipCode == 0) to switch between
1428     top-left and bottom-left image origin. This is a typical operation
1429     in video processing on Microsoft Windows\* OS.
1430 *   Horizontal flipping of the image with the subsequent horizontal
1431     shift and absolute difference calculation to check for a
1432     vertical-axis symmetry (flipCode \> 0).
1433 *   Simultaneous horizontal and vertical flipping of the image with
1434     the subsequent shift and absolute difference calculation to check
1435     for a central symmetry (flipCode \< 0).
1436 *   Reversing the order of point arrays (flipCode \> 0 or
1437     flipCode == 0).
1438 Output image must be of the same depth as input one, size should be correct for given flipCode.
1439
1440 @note Function textual ID is "org.opencv.core.transform.flip"
1441
1442 @param src input matrix.
1443 @param flipCode a flag to specify how to flip the array; 0 means
1444 flipping around the x-axis and positive value (for example, 1) means
1445 flipping around y-axis. Negative value (for example, -1) means flipping
1446 around both axes.
1447 @sa remap
1448 */
1449 GAPI_EXPORTS GMat flip(const GMat& src, int flipCode);
1450
1451 /** @brief Crops a 2D matrix.
1452
1453 The function crops the matrix by given cv::Rect.
1454
1455 Output matrix must be of the same depth as input one, size is specified by given rect size.
1456
1457 @note Function textual ID is "org.opencv.core.transform.crop"
1458
1459 @param src input matrix.
1460 @param rect a rect to crop a matrix to
1461 @sa resize
1462 */
1463 GAPI_EXPORTS GMat crop(const GMat& src, const Rect& rect);
1464
1465 /** @brief Applies horizontal concatenation to given matrices.
1466
1467 The function horizontally concatenates two GMat matrices (with the same number of rows).
1468 @code{.cpp}
1469     GMat A = { 1, 4,
1470                2, 5,
1471                3, 6 };
1472     GMat B = { 7, 10,
1473                8, 11,
1474                9, 12 };
1475
1476     GMat C = gapi::concatHor(A, B);
1477     //C:
1478     //[1, 4, 7, 10;
1479     // 2, 5, 8, 11;
1480     // 3, 6, 9, 12]
1481 @endcode
1482 Output matrix must the same number of rows and depth as the src1 and src2, and the sum of cols of the src1 and src2.
1483 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1484
1485 @note Function textual ID is "org.opencv.imgproc.transform.concatHor"
1486
1487 @param src1 first input matrix to be considered for horizontal concatenation.
1488 @param src2 second input matrix to be considered for horizontal concatenation.
1489 @sa concatVert
1490 */
1491 GAPI_EXPORTS GMat concatHor(const GMat& src1, const GMat& src2);
1492
1493 /** @overload
1494 The function horizontally concatenates given number of GMat matrices (with the same number of columns).
1495 Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices.
1496
1497 @param v vector of input matrices to be concatenated horizontally.
1498 */
1499 GAPI_EXPORTS GMat concatHor(const std::vector<GMat> &v);
1500
1501 /** @brief Applies vertical concatenation to given matrices.
1502
1503 The function vertically concatenates two GMat matrices (with the same number of cols).
1504  @code{.cpp}
1505     GMat A = { 1, 7,
1506                2, 8,
1507                3, 9 };
1508     GMat B = { 4, 10,
1509                5, 11,
1510                6, 12 };
1511
1512     GMat C = gapi::concatVert(A, B);
1513     //C:
1514     //[1, 7;
1515     // 2, 8;
1516     // 3, 9;
1517     // 4, 10;
1518     // 5, 11;
1519     // 6, 12]
1520  @endcode
1521
1522 Output matrix must the same number of cols and depth as the src1 and src2, and the sum of rows of the src1 and src2.
1523 Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1.
1524
1525 @note Function textual ID is "org.opencv.imgproc.transform.concatVert"
1526
1527 @param src1 first input matrix to be considered for vertical concatenation.
1528 @param src2 second input matrix to be considered for vertical concatenation.
1529 @sa concatHor
1530 */
1531 GAPI_EXPORTS GMat concatVert(const GMat& src1, const GMat& src2);
1532
1533 /** @overload
1534 The function vertically concatenates given number of GMat matrices (with the same number of columns).
1535 Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices.
1536
1537 @param v vector of input matrices to be concatenated vertically.
1538 */
1539 GAPI_EXPORTS GMat concatVert(const std::vector<GMat> &v);
1540
1541
1542 /** @brief Performs a look-up table transform of a matrix.
1543
1544 The function LUT fills the output matrix with values from the look-up table. Indices of the entries
1545 are taken from the input matrix. That is, the function processes each element of src as follows:
1546 \f[\texttt{dst} (I)  \leftarrow \texttt{lut(src(I))}\f]
1547
1548 Supported matrix data types are @ref CV_8UC1.
1549 Output is a matrix of the same size and number of channels as src, and the same depth as lut.
1550
1551 @note Function textual ID is "org.opencv.core.transform.LUT"
1552
1553 @param src input matrix of 8-bit elements.
1554 @param lut look-up table of 256 elements; in case of multi-channel input array, the table should
1555 either have a single channel (in this case the same table is used for all channels) or the same
1556 number of channels as in the input matrix.
1557 */
1558 GAPI_EXPORTS GMat LUT(const GMat& src, const Mat& lut);
1559
1560 /** @brief Performs a 3D look-up table transform of a multi-channel matrix.
1561
1562 The function LUT3D fills the output matrix with values from the look-up table. Indices of the entries
1563 are taken from the input matrix. Interpolation is applied for mapping 0-255 range values to 0-16 range of 3DLUT table.
1564 The function processes each element of src as follows:
1565 @code{.cpp}
1566     dst[i][j][k] = lut3D[~src_r][~src_g][~src_b];
1567 @endcode
1568 where ~ means approximation.
1569 Output is a matrix of of @ref CV_8UC3.
1570
1571 @note Function textual ID is "org.opencv.core.transform.LUT3D"
1572
1573 @param src input matrix of @ref CV_8UC3.
1574 @param lut3D look-up table 17x17x17 3-channel elements.
1575 @param interpolation The depth of interpoolation to be used.
1576 */
1577 GAPI_EXPORTS GMat LUT3D(const GMat& src, const GMat& lut3D, int interpolation = INTER_NEAREST);
1578
1579 /** @brief Converts a matrix to another data depth with optional scaling.
1580
1581 The method converts source pixel values to the target data depth. saturate_cast\<\> is applied at
1582 the end to avoid possible overflows:
1583
1584 \f[m(x,y) = saturate \_ cast<rType>( \alpha (*this)(x,y) +  \beta )\f]
1585 Output matrix must be of the same size as input one.
1586
1587 @note Function textual ID is "org.opencv.core.transform.convertTo"
1588 @param src input matrix to be converted from.
1589 @param rdepth desired output matrix depth or, rather, the depth since the number of channels are the
1590 same as the input has; if rdepth is negative, the output matrix will have the same depth as the input.
1591 @param alpha optional scale factor.
1592 @param beta optional delta added to the scaled values.
1593  */
1594 GAPI_EXPORTS GMat convertTo(const GMat& src, int rdepth, double alpha=1, double beta=0);
1595 //! @} gapi_transform
1596
1597 } //namespace gapi
1598 } //namespace cv
1599
1600 #endif //OPENCV_GAPI_CORE_HPP