eb2561ec4d9d315d5e0e42bf2301cb30adf3acda
[profile/ivi/opencv.git] / modules / gpu / doc / image_processing.rst
1 Image Processing
2 ================
3
4 .. highlight:: cpp
5
6
7
8 gpu::meanShiftFiltering
9 ---------------------------
10 Performs mean-shift filtering for each point of the source image.
11
12 .. ocv:function:: void gpu::meanShiftFiltering( const GpuMat& src, GpuMat& dst, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1), Stream& stream=Stream::Null() )
13
14     :param src: Source image. Only  ``CV_8UC4`` images are supported for now.
15
16     :param dst: Destination image containing the color of mapped points. It has the same size and type as  ``src`` .
17
18     :param sp: Spatial window radius.
19
20     :param sr: Color window radius.
21
22     :param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
23
24 It maps each point of the source image into another point. As a result, you have a new color and new position of each point.
25
26
27
28 gpu::meanShiftProc
29 ----------------------
30 Performs a mean-shift procedure and stores information about processed points (their colors and positions) in two images.
31
32 .. ocv:function:: void gpu::meanShiftProc( const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1), Stream& stream=Stream::Null() )
33
34     :param src: Source image. Only  ``CV_8UC4`` images are supported for now.
35
36     :param dstr: Destination image containing the color of mapped points. The size and type is the same as  ``src`` .
37
38     :param dstsp: Destination image containing the position of mapped points. The size is the same as  ``src`` size. The type is  ``CV_16SC2`` .
39
40     :param sp: Spatial window radius.
41
42     :param sr: Color window radius.
43
44     :param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
45
46 .. seealso:: :ocv:func:`gpu::meanShiftFiltering`
47
48
49
50 gpu::meanShiftSegmentation
51 ------------------------------
52 Performs a mean-shift segmentation of the source image and eliminates small segments.
53
54 .. ocv:function:: void gpu::meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1))
55
56     :param src: Source image. Only  ``CV_8UC4`` images are supported for now.
57
58     :param dst: Segmented image with the same size and type as  ``src`` .
59
60     :param sp: Spatial window radius.
61
62     :param sr: Color window radius.
63
64     :param minsize: Minimum segment size. Smaller segments are merged.
65
66     :param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
67
68
69
70 gpu::integral
71 -----------------
72 Computes an integral image.
73
74 .. ocv:function:: void gpu::integral(const GpuMat& src, GpuMat& sum, Stream& stream = Stream::Null())
75
76     :param src: Source image. Only  ``CV_8UC1`` images are supported for now.
77
78     :param sum: Integral image containing 32-bit unsigned integer values packed into  ``CV_32SC1`` .
79
80     :param stream: Stream for the asynchronous version.
81
82 .. seealso:: :ocv:func:`integral`
83
84
85
86 gpu::sqrIntegral
87 --------------------
88 Computes a squared integral image.
89
90 .. ocv:function:: void gpu::sqrIntegral(const GpuMat& src, GpuMat& sqsum, Stream& stream = Stream::Null())
91
92     :param src: Source image. Only  ``CV_8UC1`` images are supported for now.
93
94     :param sqsum: Squared integral image containing 64-bit unsigned integer values packed into  ``CV_64FC1`` .
95
96     :param stream: Stream for the asynchronous version.
97
98
99
100 gpu::columnSum
101 ------------------
102 Computes a vertical (column) sum.
103
104 .. ocv:function:: void gpu::columnSum(const GpuMat& src, GpuMat& sum)
105
106     :param src: Source image. Only  ``CV_32FC1`` images are supported for now.
107
108     :param sum: Destination image of the  ``CV_32FC1`` type.
109
110
111
112 gpu::cornerHarris
113 ---------------------
114 Computes the Harris cornerness criteria at each image pixel.
115
116 .. ocv:function:: void gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101)
117
118     :param src: Source image. Only  ``CV_8UC1`` and  ``CV_32FC1`` images are supported for now.
119
120     :param dst: Destination image containing cornerness values. It has the same size as ``src`` and ``CV_32FC1`` type.
121
122     :param blockSize: Neighborhood size.
123
124     :param ksize: Aperture parameter for the Sobel operator.
125
126     :param k: Harris detector free parameter.
127
128     :param borderType: Pixel extrapolation method. Only  ``BORDER_REFLECT101`` and  ``BORDER_REPLICATE`` are supported for now.
129
130 .. seealso:: :ocv:func:`cornerHarris`
131
132
133
134 gpu::cornerMinEigenVal
135 --------------------------
136 Computes the minimum eigen value of a 2x2 derivative covariation matrix at each pixel (the cornerness criteria).
137
138 .. ocv:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101)
139
140 .. ocv:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, int borderType=BORDER_REFLECT101)
141
142 .. ocv:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, int borderType=BORDER_REFLECT101, Stream& stream = Stream::Null())
143
144     :param src: Source image. Only  ``CV_8UC1`` and  ``CV_32FC1`` images are supported for now.
145
146     :param dst: Destination image containing cornerness values. The size is the same. The type is  ``CV_32FC1`` .
147
148     :param blockSize: Neighborhood size.
149
150     :param ksize: Aperture parameter for the Sobel operator.
151
152     :param borderType: Pixel extrapolation method. Only ``BORDER_REFLECT101`` and ``BORDER_REPLICATE`` are supported for now.
153
154 .. seealso:: :ocv:func:`cornerMinEigenVal`
155
156
157
158 gpu::mulSpectrums
159 ---------------------
160 Performs a per-element multiplication of two Fourier spectrums.
161
162 .. ocv:function:: void gpu::mulSpectrums( const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false, Stream& stream=Stream::Null() )
163
164     :param a: First spectrum.
165
166     :param b: Second spectrum with the same size and type as  ``a`` .
167
168     :param c: Destination spectrum.
169
170     :param flags: Mock parameter used for CPU/GPU interfaces similarity.
171
172     :param conjB: Optional flag to specify if the second spectrum needs to be conjugated before the multiplication.
173
174     Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
175
176 .. seealso:: :ocv:func:`mulSpectrums`
177
178
179
180 gpu::mulAndScaleSpectrums
181 -----------------------------
182 Performs a per-element multiplication of two Fourier spectrums and scales the result.
183
184 .. ocv:function:: void gpu::mulAndScaleSpectrums( const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, float scale, bool conjB=false, Stream& stream=Stream::Null() )
185
186     :param a: First spectrum.
187
188     :param b: Second spectrum with the same size and type as  ``a`` .
189
190     :param c: Destination spectrum.
191
192     :param flags: Mock parameter used for CPU/GPU interfaces similarity.
193
194     :param scale: Scale constant.
195
196     :param conjB: Optional flag to specify if the second spectrum needs to be conjugated before the multiplication.
197
198     Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
199
200 .. seealso:: :ocv:func:`mulSpectrums`
201
202
203
204 gpu::dft
205 ------------
206 Performs a forward or inverse discrete Fourier transform (1D or 2D) of the floating point matrix.
207
208 .. ocv:function:: void gpu::dft( const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0, Stream& stream=Stream::Null() )
209
210     :param src: Source matrix (real or complex).
211
212     :param dst: Destination matrix (real or complex).
213
214     :param dft_size: Size of a discrete Fourier transform.
215
216     :param flags: Optional flags:
217
218         * **DFT_ROWS** transforms each individual row of the source matrix.
219
220         * **DFT_SCALE** scales the result: divide it by the number of elements in the transform (obtained from  ``dft_size`` ).
221
222         * **DFT_INVERSE** inverts DFT. Use for complex-complex cases (real-complex and complex-real cases are always forward and inverse, respectively).
223
224         * **DFT_REAL_OUTPUT** specifies the output as real. The source matrix is the result of real-complex transform, so the destination matrix must be real.
225
226 Use to handle real matrices ( ``CV32FC1`` ) and complex matrices in the interleaved format ( ``CV32FC2`` ).
227
228 The source matrix should be continuous, otherwise reallocation and data copying is performed. The function chooses an operation mode depending on the flags, size, and channel count of the source matrix:
229
230     * If the source matrix is complex and the output is not specified as real, the destination matrix is complex and has the ``dft_size``    size and ``CV_32FC2``    type. The destination matrix contains a full result of the DFT (forward or inverse).
231
232     * If the source matrix is complex and the output is specified as real, the function assumes that its input is the result of the forward transform (see the next item). The destination matrix has the ``dft_size`` size and ``CV_32FC1`` type. It contains the result of the inverse DFT.
233
234     * If the source matrix is real (its type is ``CV_32FC1`` ), forward DFT is performed. The result of the DFT is packed into complex ( ``CV_32FC2`` ) matrix. So, the width of the destination matrix is ``dft_size.width / 2 + 1`` . But if the source is a single column, the height is reduced instead of the width.
235
236 .. seealso:: :ocv:func:`dft`
237
238
239 gpu::ConvolveBuf
240 ----------------
241 .. ocv:struct:: gpu::ConvolveBuf
242
243 Class providing a memory buffer for :ocv:func:`gpu::convolve` function, plus it allows to adjust some specific parameters. ::
244
245     struct CV_EXPORTS ConvolveBuf
246     {
247         Size result_size;
248         Size block_size;
249         Size user_block_size;
250         Size dft_size;
251         int spect_len;
252
253         GpuMat image_spect, templ_spect, result_spect;
254         GpuMat image_block, templ_block, result_data;
255
256         void create(Size image_size, Size templ_size);
257         static Size estimateBlockSize(Size result_size, Size templ_size);
258     };
259
260 You can use field `user_block_size` to set specific block size for :ocv:func:`gpu::convolve` function. If you leave its default value `Size(0,0)` then automatic estimation of block size will be used (which is optimized for speed). By varying `user_block_size` you can reduce memory requirements at the cost of speed.
261
262 gpu::ConvolveBuf::create
263 ------------------------
264 .. ocv:function:: gpu::ConvolveBuf::create(Size image_size, Size templ_size)
265
266 Constructs a buffer for :ocv:func:`gpu::convolve` function with respective arguments.
267
268
269 gpu::convolve
270 -----------------
271 Computes a convolution (or cross-correlation) of two images.
272
273 .. ocv:function:: void gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr=false)
274
275 .. ocv:function:: void gpu::convolve( const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr, ConvolveBuf& buf, Stream& stream=Stream::Null() )
276
277     :param image: Source image. Only  ``CV_32FC1`` images are supported for now.
278
279     :param templ: Template image. The size is not greater than the  ``image`` size. The type is the same as  ``image`` .
280
281     :param result: Result image. If  ``image`` is  *W x H*  and ``templ`` is  *w x h*, then  ``result`` must be *W-w+1 x H-h+1*.
282
283     :param ccorr: Flags to evaluate cross-correlation instead of convolution.
284
285     :param buf: Optional buffer to avoid extra memory allocations and to adjust some specific parameters. See :ocv:struct:`gpu::ConvolveBuf`.
286
287     :param stream: Stream for the asynchronous version.
288
289 .. seealso:: :ocv:func:`gpu::filter2D`
290
291 gpu::MatchTemplateBuf
292 ---------------------
293 .. ocv:struct:: gpu::MatchTemplateBuf
294
295 Class providing memory buffers for :ocv:func:`gpu::matchTemplate` function, plus it allows to adjust some specific parameters. ::
296
297     struct CV_EXPORTS MatchTemplateBuf
298     {
299         Size user_block_size;
300         GpuMat imagef, templf;
301         std::vector<GpuMat> images;
302         std::vector<GpuMat> image_sums;
303         std::vector<GpuMat> image_sqsums;
304     };
305
306 You can use field `user_block_size` to set specific block size for :ocv:func:`gpu::matchTemplate` function. If you leave its default value `Size(0,0)` then automatic estimation of block size will be used (which is optimized for speed). By varying `user_block_size` you can reduce memory requirements at the cost of speed.
307
308 gpu::matchTemplate
309 ----------------------
310 Computes a proximity map for a raster template and an image where the template is searched for.
311
312 .. ocv:function:: void gpu::matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method, Stream &stream = Stream::Null())
313
314 .. ocv:function:: void gpu::matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method, MatchTemplateBuf &buf, Stream& stream = Stream::Null())
315
316     :param image: Source image.  ``CV_32F`` and  ``CV_8U`` depth images (1..4 channels) are supported for now.
317
318     :param templ: Template image with the size and type the same as  ``image`` .
319
320     :param result: Map containing comparison results ( ``CV_32FC1`` ). If  ``image`` is  *W x H*  and ``templ`` is  *w x h*, then  ``result`` must be *W-w+1 x H-h+1*.
321
322     :param method: Specifies the way to compare the template with the image.
323
324     :param buf: Optional buffer to avoid extra memory allocations and to adjust some specific parameters. See :ocv:struct:`gpu::MatchTemplateBuf`.
325
326     :param stream: Stream for the asynchronous version.
327
328     The following methods are supported for the ``CV_8U`` depth images for now:
329
330     * ``CV_TM_SQDIFF``
331     * ``CV_TM_SQDIFF_NORMED``
332     * ``CV_TM_CCORR``
333     * ``CV_TM_CCORR_NORMED``
334     * ``CV_TM_CCOEFF``
335     * ``CV_TM_CCOEFF_NORMED``
336
337     The following methods are supported for the ``CV_32F`` images for now:
338
339     * ``CV_TM_SQDIFF``
340     * ``CV_TM_CCORR``
341
342 .. seealso:: :ocv:func:`matchTemplate`
343
344
345 gpu::remap
346 --------------
347 Applies a generic geometrical transformation to an image.
348
349 .. ocv:function:: void gpu::remap( const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null() )
350
351     :param src: Source image.
352
353     :param dst: Destination image with the size the same as  ``xmap`` and the type the same as  ``src`` .
354
355     :param xmap: X values. Only  ``CV_32FC1`` type is supported.
356
357     :param ymap: Y values. Only  ``CV_32FC1`` type is supported.
358
359     :param interpolation: Interpolation method (see  :ocv:func:`resize` ). ``INTER_NEAREST`` , ``INTER_LINEAR`` and ``INTER_CUBIC`` are supported for now.
360
361     :param borderMode: Pixel extrapolation method (see  :ocv:func:`borderInterpolate` ). ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
362
363     :param borderValue: Value used in case of a constant border. By default, it is 0.
364
365     :param stream: Stream for the asynchronous version.
366
367 The function transforms the source image using the specified map:
368
369 .. math::
370
371     \texttt{dst} (x,y) =  \texttt{src} (xmap(x,y), ymap(x,y))
372
373 Values of pixels with non-integer coordinates are computed using the bilinear interpolation.
374
375 .. seealso:: :ocv:func:`remap`
376
377
378
379 gpu::cvtColor
380 -----------------
381 Converts an image from one color space to another.
382
383 .. ocv:function:: void gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0, Stream& stream = Stream::Null())
384
385     :param src: Source image with  ``CV_8U`` , ``CV_16U`` , or  ``CV_32F`` depth and 1, 3, or 4 channels.
386
387     :param dst: Destination image with the same size and depth as  ``src`` .
388
389     :param code: Color space conversion code. For details, see  :ocv:func:`cvtColor` . Conversion to/from Luv and Bayer color spaces is not supported.
390
391     :param dcn: Number of channels in the destination image. If the parameter is 0, the number of the channels is derived automatically from  ``src`` and the  ``code`` .
392
393     :param stream: Stream for the asynchronous version.
394
395 3-channel color spaces (like ``HSV``, ``XYZ``, and so on) can be stored in a 4-channel image for better performance.
396
397 .. seealso:: :ocv:func:`cvtColor`
398
399
400
401 gpu::swapChannels
402 -----------------
403 Exchanges the color channels of an image in-place.
404
405 .. ocv:function:: void gpu::swapChannels(GpuMat& image, const int dstOrder[4], Stream& stream = Stream::Null())
406
407     :param image: Source image. Supports only ``CV_8UC4`` type.
408
409     :param dstOrder: Integer array describing how channel values are permutated. The n-th entry of the array contains the number of the channel that is stored in the n-th channel of the output image. E.g. Given an RGBA image, aDstOrder = [3,2,1,0] converts this to ABGR channel order.
410
411     :param stream: Stream for the asynchronous version.
412
413 The methods support arbitrary permutations of the original channels, including replication.
414
415
416
417 gpu::threshold
418 ------------------
419 Applies a fixed-level threshold to each array element.
420
421 .. ocv:function:: double gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type, Stream& stream = Stream::Null())
422
423     :param src: Source array (single-channel).
424
425     :param dst: Destination array with the same size and type as  ``src`` .
426
427     :param thresh: Threshold value.
428
429     :param maxval: Maximum value to use with  ``THRESH_BINARY`` and  ``THRESH_BINARY_INV`` threshold types.
430
431     :param type: Threshold type. For details, see  :ocv:func:`threshold` . The ``THRESH_OTSU`` threshold type is not supported.
432
433     :param stream: Stream for the asynchronous version.
434
435 .. seealso:: :ocv:func:`threshold`
436
437
438
439 gpu::resize
440 ---------------
441 Resizes an image.
442
443 .. ocv:function:: void gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null())
444
445     :param src: Source image.
446
447     :param dst: Destination image  with the same type as  ``src`` . The size is ``dsize`` (when it is non-zero) or the size is computed from  ``src.size()`` , ``fx`` , and  ``fy`` .
448
449     :param dsize: Destination image size. If it is zero, it is computed as:
450
451         .. math::
452             \texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}
453
454         Either  ``dsize`` or both  ``fx`` and  ``fy`` must be non-zero.
455
456     :param fx: Scale factor along the horizontal axis. If it is zero, it is computed as:
457
458         .. math::
459
460             \texttt{(double)dsize.width/src.cols}
461
462     :param fy: Scale factor along the vertical axis. If it is zero, it is computed as:
463
464         .. math::
465
466             \texttt{(double)dsize.height/src.rows}
467
468     :param interpolation: Interpolation method. ``INTER_NEAREST`` , ``INTER_LINEAR`` and ``INTER_CUBIC`` are supported for now.
469
470     :param stream: Stream for the asynchronous version.
471
472 .. seealso:: :ocv:func:`resize`
473
474
475
476 gpu::warpAffine
477 -------------------
478 Applies an affine transformation to an image.
479
480 .. ocv:function:: void gpu::warpAffine( const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null() )
481
482     :param src: Source image.  ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or  ``CV_32F`` depth and 1, 3, or 4 channels are supported.
483
484     :param dst: Destination image with the same type as  ``src`` . The size is  ``dsize`` .
485
486     :param M: *2x3*  transformation matrix.
487
488     :param dsize: Size of the destination image.
489
490     :param flags: Combination of interpolation methods (see  :ocv:func:`resize`) and the optional flag  ``WARP_INVERSE_MAP`` specifying that  ``M`` is an inverse transformation ( ``dst=>src`` ). Only ``INTER_NEAREST`` , ``INTER_LINEAR`` , and  ``INTER_CUBIC`` interpolation methods are supported.
491
492     :param stream: Stream for the asynchronous version.
493
494 .. seealso:: :ocv:func:`warpAffine`
495
496
497
498 gpu::buildWarpAffineMaps
499 ------------------------
500 Builds transformation maps for affine transformation.
501
502 .. ocv:function:: void gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null())
503
504     :param M: *2x3*  transformation matrix.
505
506     :param inverse: Flag  specifying that  ``M`` is an inverse transformation ( ``dst=>src`` ).
507
508     :param dsize: Size of the destination image.
509
510     :param xmap: X values with  ``CV_32FC1`` type.
511
512     :param ymap: Y values with  ``CV_32FC1`` type.
513
514     :param stream: Stream for the asynchronous version.
515
516 .. seealso:: :ocv:func:`gpu::warpAffine` , :ocv:func:`gpu::remap`
517
518
519
520 gpu::warpPerspective
521 ------------------------
522 Applies a perspective transformation to an image.
523
524 .. ocv:function:: void gpu::warpPerspective( const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null() )
525
526     :param src: Source image. ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or  ``CV_32F`` depth and 1, 3, or 4 channels are supported.
527
528     :param dst: Destination image with the same type as  ``src`` . The size is  ``dsize`` .
529
530     :param M: *3x3* transformation matrix.
531
532     :param dsize: Size of the destination image.
533
534     :param flags: Combination of interpolation methods (see  :ocv:func:`resize` ) and the optional flag  ``WARP_INVERSE_MAP`` specifying that  ``M`` is the inverse transformation ( ``dst => src`` ). Only  ``INTER_NEAREST`` , ``INTER_LINEAR`` , and  ``INTER_CUBIC`` interpolation methods are supported.
535
536     :param stream: Stream for the asynchronous version.
537
538 .. seealso:: :ocv:func:`warpPerspective`
539
540
541
542 gpu::buildWarpPerspectiveMaps
543 -----------------------------
544 Builds transformation maps for perspective transformation.
545
546 .. ocv:function:: void gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null())
547
548     :param M: *3x3*  transformation matrix.
549
550     :param inverse: Flag  specifying that  ``M`` is an inverse transformation ( ``dst=>src`` ).
551
552     :param dsize: Size of the destination image.
553
554     :param xmap: X values with  ``CV_32FC1`` type.
555
556     :param ymap: Y values with  ``CV_32FC1`` type.
557
558     :param stream: Stream for the asynchronous version.
559
560 .. seealso:: :ocv:func:`gpu::warpPerspective` , :ocv:func:`gpu::remap`
561
562
563
564 gpu::rotate
565 ---------------
566 Rotates an image around the origin (0,0) and then shifts it.
567
568 .. ocv:function:: void gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null())
569
570     :param src: Source image. Supports 1, 3 or 4 channels images with ``CV_8U`` , ``CV_16U`` or ``CV_32F`` depth.
571
572     :param dst: Destination image with the same type as  ``src`` . The size is  ``dsize`` .
573
574     :param dsize: Size of the destination image.
575
576     :param angle: Angle of rotation in degrees.
577
578     :param xShift: Shift along the horizontal axis.
579
580     :param yShift: Shift along the vertical axis.
581
582     :param interpolation: Interpolation method. Only  ``INTER_NEAREST`` , ``INTER_LINEAR`` , and  ``INTER_CUBIC`` are supported.
583
584     :param stream: Stream for the asynchronous version.
585
586 .. seealso:: :ocv:func:`gpu::warpAffine`
587
588
589
590 gpu::copyMakeBorder
591 -----------------------
592 Forms a border around an image.
593
594 .. ocv:function:: void gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, int borderType, const Scalar& value = Scalar(), Stream& stream = Stream::Null())
595
596     :param src: Source image. ``CV_8UC1`` , ``CV_8UC4`` , ``CV_32SC1`` , and  ``CV_32FC1`` types are supported.
597
598     :param dst: Destination image with the same type as  ``src``. The size is  ``Size(src.cols+left+right, src.rows+top+bottom)`` .
599
600     :param top:
601
602     :param bottom:
603
604     :param left:
605
606     :param right: Number of pixels in each direction from the source image rectangle to extrapolate. For example:  ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
607
608     :param borderType: Border type. See  :ocv:func:`borderInterpolate` for details. ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
609
610     :param value: Border value.
611
612     :param stream: Stream for the asynchronous version.
613
614 .. seealso:: :ocv:func:`copyMakeBorder`
615
616
617
618 gpu::rectStdDev
619 -------------------
620 Computes a standard deviation of integral images.
621
622 .. ocv:function:: void gpu::rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect, Stream& stream = Stream::Null())
623
624     :param src: Source image. Only the ``CV_32SC1`` type is supported.
625
626     :param sqr: Squared source image. Only  the ``CV_32FC1`` type is supported.
627
628     :param dst: Destination image with the same type and size as  ``src`` .
629
630     :param rect: Rectangular window.
631
632     :param stream: Stream for the asynchronous version.
633
634
635
636 gpu::evenLevels
637 -------------------
638 Computes levels with even distribution.
639
640 .. ocv:function:: void gpu::evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel)
641
642     :param levels: Destination array.  ``levels`` has 1 row, ``nLevels`` columns, and the ``CV_32SC1`` type.
643
644     :param nLevels: Number of computed levels.  ``nLevels`` must be at least 2.
645
646     :param lowerLevel: Lower boundary value of the lowest level.
647
648     :param upperLevel: Upper boundary value of the greatest level.
649
650
651
652 gpu::histEven
653 -----------------
654 Calculates a histogram with evenly distributed bins.
655
656 .. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null())
657
658 .. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null())
659
660 .. ocv:function:: void gpu::histEven( const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream=Stream::Null() )
661
662 .. ocv:function:: void gpu::histEven( const GpuMat& src, GpuMat hist[4], GpuMat& buf, int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream=Stream::Null() )
663
664     :param src: Source image. ``CV_8U``, ``CV_16U``, or ``CV_16S`` depth and 1 or 4 channels are supported. For a four-channel image, all channels are processed separately.
665
666     :param hist: Destination histogram with one row, ``histSize`` columns, and the ``CV_32S`` type.
667
668     :param histSize: Size of the histogram.
669
670     :param lowerLevel: Lower boundary of lowest-level bin.
671
672     :param upperLevel: Upper boundary of highest-level bin.
673
674     :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
675
676     :param stream: Stream for the asynchronous version.
677
678
679
680 gpu::histRange
681 ------------------
682 Calculates a histogram with bins determined by the ``levels`` array.
683
684 .. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, Stream& stream = Stream::Null())
685
686 .. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, GpuMat& buf, Stream& stream = Stream::Null())
687
688     :param src: Source image. ``CV_8U`` , ``CV_16U`` , or  ``CV_16S`` depth and 1 or 4 channels are supported. For a four-channel image, all channels are processed separately.
689
690     :param hist: Destination histogram with one row, ``(levels.cols-1)`` columns, and the  ``CV_32SC1`` type.
691
692     :param levels: Number of levels in the histogram.
693
694     :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
695
696     :param stream: Stream for the asynchronous version.
697
698
699
700 gpu::calcHist
701 ------------------
702 Calculates histogram for one channel 8-bit image.
703
704 .. ocv:function:: void gpu::calcHist(const GpuMat& src, GpuMat& hist, Stream& stream = Stream::Null())
705
706 .. ocv:function:: void gpu::calcHist(const GpuMat& src, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null())
707
708     :param src: Source image.
709
710     :param hist: Destination histogram with one row, 256 columns, and the  ``CV_32SC1`` type.
711
712     :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
713
714     :param stream: Stream for the asynchronous version.
715
716
717
718 gpu::equalizeHist
719 ------------------
720 Equalizes the histogram of a grayscale image.
721
722 .. ocv:function:: void gpu::equalizeHist(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
723
724 .. ocv:function:: void gpu::equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, Stream& stream = Stream::Null())
725
726 .. ocv:function:: void gpu::equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null())
727
728     :param src: Source image.
729
730     :param dst: Destination image.
731
732     :param hist: Destination histogram with one row, 256 columns, and the  ``CV_32SC1`` type.
733
734     :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
735
736     :param stream: Stream for the asynchronous version.
737
738 .. seealso:: :ocv:func:`equalizeHist`
739
740
741
742 gpu::buildWarpPlaneMaps
743 -----------------------
744 Builds plane warping maps.
745
746 .. ocv:function:: void gpu::buildWarpPlaneMaps( Size src_size, Rect dst_roi, const Mat & K, const Mat& R, const Mat & T, float scale, GpuMat& map_x, GpuMat& map_y, Stream& stream=Stream::Null() )
747
748     :param stream: Stream for the asynchronous version.
749
750
751
752 gpu::buildWarpCylindricalMaps
753 -----------------------------
754 Builds cylindrical warping maps.
755
756 .. ocv:function:: void gpu::buildWarpCylindricalMaps( Size src_size, Rect dst_roi, const Mat & K, const Mat& R, float scale, GpuMat& map_x, GpuMat& map_y, Stream& stream=Stream::Null() )
757
758     :param stream: Stream for the asynchronous version.
759
760
761
762 gpu::buildWarpSphericalMaps
763 ---------------------------
764 Builds spherical warping maps.
765
766 .. ocv:function:: void gpu::buildWarpSphericalMaps( Size src_size, Rect dst_roi, const Mat & K, const Mat& R, float scale, GpuMat& map_x, GpuMat& map_y, Stream& stream=Stream::Null() )
767
768     :param stream: Stream for the asynchronous version.
769
770
771
772 gpu::pyrDown
773 -------------------
774 Smoothes an image and downsamples it.
775
776 .. ocv:function:: void gpu::pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
777
778     :param src: Source image.
779
780     :param dst: Destination image. Will have ``Size((src.cols+1)/2, (src.rows+1)/2)`` size and the same type as ``src`` .
781
782     :param stream: Stream for the asynchronous version.
783
784 .. seealso:: :ocv:func:`pyrDown`
785
786
787
788 gpu::pyrUp
789 -------------------
790 Upsamples an image and then smoothes it.
791
792 .. ocv:function:: void gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
793
794     :param src: Source image.
795
796     :param dst: Destination image. Will have ``Size(src.cols*2, src.rows*2)`` size and the same type as ``src`` .
797
798     :param stream: Stream for the asynchronous version.
799
800 .. seealso:: :ocv:func:`pyrUp`
801
802
803
804 gpu::blendLinear
805 -------------------
806 Performs linear blending of two images.
807
808 .. ocv:function:: void gpu::blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2, GpuMat& result, Stream& stream = Stream::Null())
809
810     :param img1: First image. Supports only ``CV_8U`` and ``CV_32F`` depth.
811
812     :param img2: Second image. Must have the same size and the same type as ``img1`` .
813
814     :param weights1: Weights for first image. Must have tha same size as ``img1`` . Supports only ``CV_32F`` type.
815
816     :param weights2: Weights for second image. Must have tha same size as ``img2`` . Supports only ``CV_32F`` type.
817
818     :param result: Destination image.
819
820     :param stream: Stream for the asynchronous version.
821
822
823
824 gpu::alphaComp
825 -------------------
826 Composites two images using alpha opacity values contained in each image.
827
828 .. ocv:function:: void gpu::alphaComp(const GpuMat& img1, const GpuMat& img2, GpuMat& dst, int alpha_op, Stream& stream = Stream::Null())
829
830     :param img1: First image. Supports ``CV_8UC4`` , ``CV_16UC4`` , ``CV_32SC4`` and ``CV_32FC4`` types.
831
832     :param img2: Second image. Must have the same size and the same type as ``img1`` .
833
834     :param dst: Destination image.
835
836     :param alpha_op: Flag specifying the alpha-blending operation:
837
838             * **ALPHA_OVER**
839             * **ALPHA_IN**
840             * **ALPHA_OUT**
841             * **ALPHA_ATOP**
842             * **ALPHA_XOR**
843             * **ALPHA_PLUS**
844             * **ALPHA_OVER_PREMUL**
845             * **ALPHA_IN_PREMUL**
846             * **ALPHA_OUT_PREMUL**
847             * **ALPHA_ATOP_PREMUL**
848             * **ALPHA_XOR_PREMUL**
849             * **ALPHA_PLUS_PREMUL**
850             * **ALPHA_PREMUL**
851
852     :param stream: Stream for the asynchronous version.
853
854
855
856 gpu::Canny
857 -------------------
858 Finds edges in an image using the [Canny86]_ algorithm.
859
860 .. ocv:function:: void gpu::Canny(const GpuMat& image, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false)
861
862 .. ocv:function:: void gpu::Canny(const GpuMat& image, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false)
863
864 .. ocv:function:: void gpu::Canny(const GpuMat& dx, const GpuMat& dy, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false)
865
866 .. ocv:function:: void gpu::Canny(const GpuMat& dx, const GpuMat& dy, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false)
867
868     :param image: Single-channel 8-bit input image.
869
870     :param dx: First derivative of image in the vertical direction. Support only ``CV_32S`` type.
871
872     :param dy: First derivative of image in the horizontal direction. Support only ``CV_32S`` type.
873
874     :param edges: Output edge map. It has the same size and type as  ``image`` .
875
876     :param low_thresh: First threshold for the hysteresis procedure.
877
878     :param high_thresh: Second threshold for the hysteresis procedure.
879
880     :param apperture_size: Aperture size for the  :ocv:func:`Sobel`  operator.
881
882     :param L2gradient: Flag indicating whether a more accurate  :math:`L_2`  norm  :math:`=\sqrt{(dI/dx)^2 + (dI/dy)^2}`  should be used to compute the image gradient magnitude ( ``L2gradient=true`` ), or a faster default  :math:`L_1`  norm  :math:`=|dI/dx|+|dI/dy|`  is enough ( ``L2gradient=false`` ).
883
884     :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
885
886 .. seealso:: :ocv:func:`Canny`
887
888
889
890 gpu::HoughLines
891 ---------------
892 Finds lines in a binary image using the classical Hough transform.
893
894 .. ocv:function:: void gpu::HoughLines(const GpuMat& src, GpuMat& lines, float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096)
895
896 .. ocv:function:: void gpu::HoughLines(const GpuMat& src, GpuMat& lines, GpuMat& accum, GpuMat& buf, float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096)
897
898     :param src: 8-bit, single-channel binary source image.
899
900     :param lines: Output vector of lines. Each line is represented by a two-element vector  :math:`(\rho, \theta)` .  :math:`\rho`  is the distance from the coordinate origin  :math:`(0,0)`  (top-left corner of the image).  :math:`\theta`  is the line rotation angle in radians ( :math:`0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}` ).
901
902     :param rho: Distance resolution of the accumulator in pixels.
903
904     :param theta: Angle resolution of the accumulator in radians.
905
906     :param threshold: Accumulator threshold parameter. Only those lines are returned that get enough votes ( :math:`>\texttt{threshold}` ).
907
908     :param doSort: Performs lines sort by votes.
909
910     :param maxLines: Maximum number of output lines.
911
912     :param accum: Optional buffer for accumulator to avoid extra memory allocations (for many calls with the same sizes).
913
914     :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
915
916 .. seealso:: :ocv:func:`HoughLines`
917
918
919
920 gpu::HoughLinesTransform
921 ------------------------
922 Performs classical Hough transform for line detection.
923
924 .. ocv:function:: void gpu::HoughLinesTransform(const GpuMat& src, GpuMat& accum, GpuMat& buf, float rho, float theta)
925
926     :param src: 8-bit, single-channel binary source image.
927
928     :param accum: Output accumulator array.
929
930     :param buf: Buffer to avoid extra memory allocations (for many calls with the same sizes).
931
932     :param rho: Distance resolution of the accumulator in pixels.
933
934     :param theta: Angle resolution of the accumulator in radians.
935
936     :param threshold: Accumulator threshold parameter. Only those lines are returned that get enough votes ( :math:`>\texttt{threshold}` ).
937
938 .. seealso:: :ocv:func:`gpu::HoughLines`
939
940
941
942 gpu::HoughLinesGet
943 ------------------
944 Finds lines in Hough space.
945
946 .. ocv:function:: void gpu::HoughLinesGet(const GpuMat& accum, GpuMat& lines, float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096)
947
948     :param accum: Accumulator array.
949
950     :param lines: Output vector of lines. Each line is represented by a two-element vector  :math:`(\rho, \theta)` .  :math:`\rho`  is the distance from the coordinate origin  :math:`(0,0)`  (top-left corner of the image).  :math:`\theta`  is the line rotation angle in radians ( :math:`0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}` ).
951
952     :param rho: Distance resolution of the accumulator in pixels.
953
954     :param theta: Angle resolution of the accumulator in radians.
955
956     :param threshold: Accumulator threshold parameter. Only those lines are returned that get enough votes ( :math:`>\texttt{threshold}` ).
957
958     :param doSort: Performs lines sort by votes.
959
960     :param maxLines: Maximum number of output lines.
961
962 .. seealso:: :ocv:func:`gpu::HoughLines`
963
964
965
966 gpu::HoughLinesDownload
967 -----------------------
968 Downloads results from :ocv:func:`gpu::HoughLines` to host memory.
969
970 .. ocv:function:: void gpu::HoughLinesDownload(const GpuMat& d_lines, OutputArray h_lines, OutputArray h_votes = noArray())
971
972     :param d_lines: Result of :ocv:func:`gpu::HoughLines` .
973
974     :param h_lines: Output host array.
975
976     :param h_votes: Optional output array for line's votes.
977
978 .. seealso:: :ocv:func:`gpu::HoughLines`