Merge pull request #1263 from abidrahmank:pyCLAHE_24
[profile/ivi/opencv.git] / modules / ocl / doc / image_processing.rst
1 Image Processing
2 =============================
3
4 .. highlight:: cpp
5
6 ocl::cornerHarris
7 ------------------
8 Returns void
9
10 .. ocv:function:: void ocl::cornerHarris(const oclMat &src, oclMat &dst, int blockSize, int ksize, double k, int bordertype = cv::BORDER_DEFAULT)
11
12     :param src: Source image. Only CV_8UC1 and CV_32FC1 images are supported now.
13
14     :param dst: Destination image containing cornerness values. It has the same size as src and CV_32FC1 type.
15
16     :param blockSize: Neighborhood size
17
18     :param ksize: Aperture parameter for the Sobel operator
19
20     :param k: Harris detector free parameter
21
22     :param bordertype: Pixel extrapolation method. Only BORDER_REFLECT101, BORDER_REFLECT, BORDER_CONSTANT and BORDER_REPLICATE are supported now.
23
24 Calculate Harris corner.
25
26 ocl::cornerMinEigenVal
27 ------------------------
28 Returns void
29
30 .. ocv:function:: void ocl::cornerMinEigenVal(const oclMat &src, oclMat &dst, int blockSize, int ksize, int bordertype = cv::BORDER_DEFAULT)
31
32     :param src: Source image. Only CV_8UC1 and CV_32FC1 images are supported now.
33
34     :param dst: Destination image containing cornerness values. It has the same size as src and CV_32FC1 type.
35
36     :param blockSize: Neighborhood size
37
38     :param ksize: Aperture parameter for the Sobel operator
39
40     :param bordertype: Pixel extrapolation method. Only BORDER_REFLECT101, BORDER_REFLECT, BORDER_CONSTANT and BORDER_REPLICATE are supported now.
41
42 Calculate MinEigenVal.
43
44 ocl::calcHist
45 ------------------
46 Returns void
47
48 .. ocv:function:: void ocl::calcHist(const oclMat &mat_src, oclMat &mat_hist)
49
50     :param src: Source arrays. They all should have the same depth, CV 8U, and the same size. Each of them can have an arbitrary number of channels.
51
52     :param dst: The output histogram, a dense or sparse dims-dimensional
53
54 Calculates histogram of one or more arrays. Supports only 8UC1 data type.
55
56 ocl::remap
57 ------------------
58 Returns void
59
60 .. ocv:function:: void ocl::remap(const oclMat &src, oclMat &dst, oclMat &map1, oclMat &map2, int interpolation, int bordertype, const Scalar &value = Scalar())
61
62     :param src: Source image. Only CV_8UC1 and CV_32FC1 images are supported now.
63
64     :param dst: Destination image containing cornerness values. It has the same size as src and CV_32FC1 type.
65
66     :param map1: The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1 , or CV_32FC2 . See covertMaps() for details on converting a floating point representation to fixed-point for speed.
67
68     :param map2: The second map of y values having the type CV_32FC1 , or none (empty map if map1 is (x,y) points), respectively.
69
70     :param interpolation: The interpolation method
71
72     :param bordertype: Pixel extrapolation method. Only BORDER_CONSTANT are supported now.
73
74     :param value: The border value if borderType==BORDER CONSTANT
75
76 The function remap transforms the source image using the specified map: dst (x ,y) = src (map1(x , y) , map2(x , y)) where values of pixels with non-integer coordinates are computed using one of available interpolation methods. map1 and map2 can be encoded as separate floating-point maps in map1 and map2 respectively, or interleaved floating-point maps of (x,y) in map1. Supports CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1 , CV_32FC3 and CV_32FC4 data types.
77
78 ocl::resize
79 ------------------
80 Returns void
81
82 .. ocv:function:: void ocl::resize(const oclMat &src, oclMat &dst, Size dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR)
83
84     :param src: Source image.
85
86     :param dst: Destination image.
87
88     :param dsize: he destination image size. If it is zero, then it is computed as: dsize = Size(round(fx*src.cols), round(fy*src.rows)). Either dsize or both fx or fy must be non-zero.
89
90     :param fx: The scale factor along the horizontal axis. When 0, it is computed as (double)dsize.width/src.cols
91
92     :param fy: The scale factor along the vertical axis. When 0, it is computed as (double)dsize.height/src.rows
93
94     :param interpolation: The interpolation method: INTER NEAREST or INTER LINEAR
95
96 Resizes an image. Supports CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1 , CV_32FC3 and CV_32FC4 data types.
97
98 ocl::warpAffine
99 ------------------
100 Returns void
101
102 .. ocv:function:: void ocl::warpAffine(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags = INTER_LINEAR)
103
104     :param src: Source image.
105
106     :param dst: Destination image.
107
108     :param M: 2times 3 transformation matrix
109
110     :param dsize: Size of the destination image
111
112     :param flags: A combination of interpolation methods, see cv::resize, and the optional flag WARP INVERSE MAP that means that M is the inverse transformation (dst to $src)
113
114 The function warpAffine transforms the source image using the specified matrix. Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC types.
115
116 ocl::warpPerspective
117 ---------------------
118 Returns void
119
120 .. ocv:function:: void ocl::warpPerspective(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags = INTER_LINEAR)
121
122     :param src: Source image.
123
124     :param dst: Destination image.
125
126     :param M: 2times 3 transformation matrix
127
128     :param dsize: Size of the destination image
129
130     :param flags: A combination of interpolation methods, see cv::resize, and the optional flag WARP INVERSE MAP that means that M is the inverse transformation (dst to $src)
131
132 Applies a perspective transformation to an image. Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC types.
133
134 ocl::cvtColor
135 ------------------
136 Returns void
137
138 .. ocv:function:: void ocl::cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0)
139
140     :param src: Source image.
141
142     :param dst: Destination image.
143
144     :param code:The color space conversion code
145
146     :param dcn: The number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from src and the code
147
148 Converts image from one color space to another.For now, only RGB2GRAY is supportted. Supports.CV_8UC1,CV_8UC4,CV_32SC1,CV_32SC4,CV_32FC1,CV_32FC4
149
150 ocl::threshold
151 ------------------
152 Returns Threshold value
153
154 .. ocv:function:: double ocl::threshold(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type = THRESH_TRUNC)
155
156     :param src: The source array
157
158     :param dst: Destination array; will have the same size and the same type as src
159
160     :param thresh: Threshold value
161
162     :param maxVal: Maximum value to use with THRESH BINARY and THRESH BINARY INV thresholding types
163
164     :param type: Thresholding type
165
166 The function applies fixed-level thresholding to a single-channel array. The function is typically used to get a bi-level (binary) image out of a grayscale image or for removing a noise, i.e. filtering out pixels with too small or too large values. There are several types of thresholding that the function supports that are determined by thresholdType. Supports only CV_32FC1 and CV_8UC1 data type.
167
168 ocl::buildWarpPlaneMaps
169 -----------------------
170 Builds plane warping maps.
171
172 .. ocv:function:: void ocl::buildWarpPlaneMaps( Size src_size, Rect dst_roi, const Mat& K, const Mat& R, const Mat& T, float scale, oclMat& map_x, oclMat& map_y )
173
174
175
176 ocl::buildWarpCylindricalMaps
177 -----------------------------
178 Builds cylindrical warping maps.
179
180 .. ocv:function:: void ocl::buildWarpCylindricalMaps( Size src_size, Rect dst_roi, const Mat& K, const Mat& R, float scale, oclMat& map_x, oclMat& map_y )
181
182
183
184
185 ocl::buildWarpSphericalMaps
186 ---------------------------
187 Builds spherical warping maps.
188
189 .. ocv:function:: void ocl::buildWarpSphericalMaps( Size src_size, Rect dst_roi, const Mat& K, const Mat& R, float scale, oclMat& map_x, oclMat& map_y )
190
191
192 ocl::buildWarpPerspectiveMaps
193 -----------------------------
194 Builds transformation maps for perspective transformation.
195
196 .. ocv:function:: void ocl::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, oclMat& xmap, oclMat& ymap)
197
198     :param M: *3x3*  transformation matrix.
199
200     :param inverse: Flag  specifying that  ``M`` is an inverse transformation ( ``dst=>src`` ).
201
202     :param dsize: Size of the destination image.
203
204     :param xmap: X values with  ``CV_32FC1`` type.
205
206     :param ymap: Y values with  ``CV_32FC1`` type.
207
208 .. seealso:: :ocv:func:`ocl::warpPerspective` , :ocv:func:`ocl::remap`
209
210
211 ocl::buildWarpAffineMaps
212 ------------------------
213 Builds transformation maps for affine transformation.
214
215 .. ocv:function:: void ocl::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, oclMat& xmap, oclMat& ymap)
216
217     :param M: *2x3*  transformation matrix.
218
219     :param inverse: Flag  specifying that  ``M`` is an inverse transformation ( ``dst=>src`` ).
220
221     :param dsize: Size of the destination image.
222
223     :param xmap: X values with  ``CV_32FC1`` type.
224
225     :param ymap: Y values with  ``CV_32FC1`` type.
226
227 .. seealso:: :ocv:func:`ocl::warpAffine` , :ocv:func:`ocl::remap`
228
229 ocl::PyrLKOpticalFlow
230 ---------------------
231 .. ocv:class:: ocl::PyrLKOpticalFlow
232
233 Class used for calculating an optical flow. ::
234
235     class PyrLKOpticalFlow
236     {
237     public:
238         PyrLKOpticalFlow();
239
240         void sparse(const oclMat& prevImg, const oclMat& nextImg, const oclMat& prevPts, oclMat& nextPts,
241             oclMat& status, oclMat* err = 0);
242
243         void dense(const oclMat& prevImg, const oclMat& nextImg, oclMat& u, oclMat& v, oclMat* err = 0);
244
245         Size winSize;
246         int maxLevel;
247         int iters;
248         double derivLambda;
249         bool useInitialFlow;
250         float minEigThreshold;
251         bool getMinEigenVals;
252
253         void releaseMemory();
254     };
255
256 The class can calculate an optical flow for a sparse feature set or dense optical flow using the iterative Lucas-Kanade method with pyramids.
257
258 .. seealso:: :ocv:func:`calcOpticalFlowPyrLK`
259
260 .. note::
261
262    (Ocl) An example the Lucas Kanade optical flow pyramid method can be found at opencv_source_code/samples/ocl/pyrlk_optical_flow.cpp
263    (Ocl) An example for square detection can be found at opencv_source_code/samples/ocl/squares.cpp
264
265 ocl::PyrLKOpticalFlow::sparse
266 -----------------------------
267 Calculate an optical flow for a sparse feature set.
268
269 .. ocv:function:: void ocl::PyrLKOpticalFlow::sparse(const oclMat& prevImg, const oclMat& nextImg, const oclMat& prevPts, oclMat& nextPts, oclMat& status, oclMat* err = 0)
270
271     :param prevImg: First 8-bit input image (supports both grayscale and color images).
272
273     :param nextImg: Second input image of the same size and the same type as  ``prevImg`` .
274
275     :param prevPts: Vector of 2D points for which the flow needs to be found. It must be one row matrix with CV_32FC2 type.
276
277     :param nextPts: Output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image. When ``useInitialFlow`` is true, the vector must have the same size as in the input.
278
279     :param status: Output status vector (CV_8UC1 type). Each element of the vector is set to 1 if the flow for the corresponding features has been found. Otherwise, it is set to 0.
280
281     :param err: Output vector (CV_32FC1 type) that contains the difference between patches around the original and moved points or min eigen value if ``getMinEigenVals`` is checked. It can be NULL, if not needed.
282
283 .. seealso:: :ocv:func:`calcOpticalFlowPyrLK`
284
285
286
287 ocl::PyrLKOpticalFlow::dense
288 -----------------------------
289 Calculate dense optical flow.
290
291 .. ocv:function:: void ocl::PyrLKOpticalFlow::dense(const oclMat& prevImg, const oclMat& nextImg, oclMat& u, oclMat& v, oclMat* err = 0)
292
293     :param prevImg: First 8-bit grayscale input image.
294
295     :param nextImg: Second input image of the same size and the same type as  ``prevImg`` .
296
297     :param u: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
298
299     :param v: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
300
301     :param err: Output vector (CV_32FC1 type) that contains the difference between patches around the original and moved points or min eigen value if ``getMinEigenVals`` is checked. It can be NULL, if not needed.
302
303
304
305 ocl::PyrLKOpticalFlow::releaseMemory
306 ------------------------------------
307 Releases inner buffers memory.
308
309 .. ocv:function:: void ocl::PyrLKOpticalFlow::releaseMemory()
310
311
312 ocl::interpolateFrames
313 ----------------------
314 Interpolate frames (images) using provided optical flow (displacement field).
315
316 .. ocv:function:: void ocl::interpolateFrames(const oclMat& frame0, const oclMat& frame1, const oclMat& fu, const oclMat& fv, const oclMat& bu, const oclMat& bv, float pos, oclMat& newFrame, oclMat& buf)
317
318     :param frame0: First frame (32-bit floating point images, single channel).
319
320     :param frame1: Second frame. Must have the same type and size as ``frame0`` .
321
322     :param fu: Forward horizontal displacement.
323
324     :param fv: Forward vertical displacement.
325
326     :param bu: Backward horizontal displacement.
327
328     :param bv: Backward vertical displacement.
329
330     :param pos: New frame position.
331
332     :param newFrame: Output image.
333
334     :param buf: Temporary buffer, will have width x 6*height size, CV_32FC1 type and contain 6 oclMat: occlusion masks for first frame, occlusion masks for second, interpolated forward horizontal flow, interpolated forward vertical flow, interpolated backward horizontal flow, interpolated backward vertical flow.