gpu_image_filtering.tex 31.6 KB
Newer Older
1 2 3 4 5 6
\section{Image Filtering}

Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images.

See also: \hyperref[section.cpp.cpu.ImageFiltering]{Image Filtering}

7

8
\cvclass{gpu::BaseRowFilter\_GPU}\label{class.gpu.BaseRowFilter}
9
The base class for linear or non-linear filters that processes rows of 2D arrays. Such filters are used for the "horizontal" filtering passes in separable filters.
10 11 12 13 14 15 16 17 18 19 20 21

\begin{lstlisting}
class BaseRowFilter_GPU
{
public:
    BaseRowFilter_GPU(int ksize_, int anchor_);
    virtual ~BaseRowFilter_GPU() {}
    virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
    int ksize, anchor;
};
\end{lstlisting}

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
22 23
\textbf{Please note:} This class doesn't allocate memory for destination image. Usually this class is used inside \hyperref[class.gpu.FilterEngine]{cv::gpu::FilterEngine\_GPU}.

24

25
\cvclass{gpu::BaseColumnFilter\_GPU}\label{class.gpu.BaseColumnFilter}
26
The base class for linear or non-linear filters that processes columns of 2D arrays. Such filters are used for the "vertical" filtering passes in separable filters.
27 28 29 30 31 32 33 34 35 36 37 38

\begin{lstlisting}
class BaseColumnFilter_GPU
{
public:
    BaseColumnFilter_GPU(int ksize_, int anchor_);
    virtual ~BaseColumnFilter_GPU() {}
    virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
    int ksize, anchor;
};
\end{lstlisting}

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
39 40
\textbf{Please note:} This class doesn't allocate memory for destination image. Usually this class is used inside \hyperref[class.gpu.FilterEngine]{cv::gpu::FilterEngine\_GPU}.

41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
\cvclass{gpu::BaseFilter\_GPU}\label{class.gpu.BaseFilter}
The base class for non-separable 2D filters. 

\begin{lstlisting}
class CV_EXPORTS BaseFilter_GPU
{
public:
    BaseFilter_GPU(const Size& ksize_, const Point& anchor_);
    virtual ~BaseFilter_GPU() {}
    virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
    Size ksize;
    Point anchor;
};
\end{lstlisting}

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
57 58
\textbf{Please note:} This class doesn't allocate memory for destination image. Usually this class is used inside \hyperref[class.gpu.FilterEngine]{cv::gpu::FilterEngine\_GPU}.

59

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
\cvclass{gpu::FilterEngine\_GPU}\label{class.gpu.FilterEngine}
The base class for Filter Engine.

\begin{lstlisting}
class CV_EXPORTS FilterEngine_GPU
{
public:
    virtual ~FilterEngine_GPU() {}

    virtual void apply(const GpuMat& src, GpuMat& dst, 
                       Rect roi = Rect(0,0,-1,-1)) = 0;
};
\end{lstlisting}

The class can be used to apply an arbitrary filtering operation to an image. It contains all the necessary intermediate buffers. Pointers to the initialized \texttt{FilterEngine\_GPU} instances are returned by various \texttt{create*Filter\_GPU} functions, see below, and they are used inside high-level functions such as \cvCppCross{gpu::filter2D}, \cvCppCross{gpu::erode}, \cvCppCross{gpu::Sobel} etc.

76
By using \texttt{FilterEngine\_GPU} instead of functions you can avoid unnecessary memory allocation for intermediate buffers and get much better performance:
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

\begin{lstlisting}
while (...)
{
    cv::gpu::GpuMat src = getImg();
    cv::gpu::GpuMat dst;
    // Allocate and release buffers at each iterations
    cv::gpu::GaussianBlur(src, dst, ksize, sigma1);
}

// Allocate buffers only once
cv::Ptr<cv::gpu::FilterEngine_GPU> filter = 
    cv::gpu::createGaussianFilter_GPU(CV_8UC4, ksize, sigma1);
while (...)
{
    cv::gpu::GpuMat src = getImg();
    cv::gpu::GpuMat dst;
    filter->apply(src, dst, cv::Rect(0, 0, src.cols, src.rows));
}
// Release buffers only once
filter.release();
\end{lstlisting}

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
100
\texttt{FilterEngine\_GPU} can process a rectangular sub-region of an image. By default, if \texttt{roi == Rect(0,0,-1,-1)}, \texttt{FilterEngine\_GPU} processes inner region of image (\texttt{Rect(anchor.x, anchor.y, src\_size.width - ksize.width, src\_size.height - ksize.height)}), because some filters doesn't check if indices are outside the image for better perfomace. See below which filters supports processing the whole image and which not and image type limitations.
101

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
102
\textbf{Please note:} The GPU filters doesn't support the in-place mode.
103

104 105 106 107 108
See also: \hyperref[class.gpu.BaseRowFilter]{cv::gpu::BaseRowFilter\_GPU}, \hyperref[class.gpu.BaseColumnFilter]{cv::gpu::BaseColumnFilter\_GPU}, \hyperref[class.gpu.BaseFilter]{cv::gpu::BaseFilter\_GPU}, \hyperref[cppfunc.gpu.createFilter2D]{cv::gpu::createFilter2D\_GPU}, \hyperref[cppfunc.gpu.createSeparableFilter]{cv::gpu::createSeparableFilter\_GPU}, \hyperref[cppfunc.gpu.createBoxFilter]{cv::gpu::createBoxFilter\_GPU}, \hyperref[cppfunc.gpu.createMorphologyFilter]{cv::gpu::createMorphologyFilter\_GPU}, \hyperref[cppfunc.gpu.createLinearFilter]{cv::gpu::createLinearFilter\_GPU}, \hyperref[cppfunc.gpu.createSeparableLinearFilter]{cv::gpu::createSeparableLinearFilter\_GPU}, \hyperref[cppfunc.gpu.createDerivFilter]{cv::gpu::createDerivFilter\_GPU}, \hyperref[cppfunc.gpu.createGaussianFilter]{cv::gpu::createGaussianFilter\_GPU}


\cvfunc{cv::gpu::createFilter2D\_GPU}\label{cppfunc.gpu.createFilter2D}
Creates non-separable filter engine with the specified filter.
109 110 111 112

\cvdefCpp{
Ptr<FilterEngine\_GPU> createFilter2D\_GPU(\par const Ptr<BaseFilter\_GPU>\& filter2D, \par int srcType, int dstType);
}
113

114
\begin{description}
115 116 117
\cvarg{filter2D} {Non-separable 2D filter.}
\cvarg{srcType}{Input image type. It must be supported by \texttt{filter2D}.}
\cvarg{dstType}{Output image type. It must be supported by \texttt{filter2D}.}
118
\end{description}
119

120 121 122 123 124 125
Usually this function is used inside high-level functions, like \hyperref[cppfunc.gpu.createLinearFilter]{cv::gpu::createLinearFilter\_GPU}, \hyperref[cppfunc.gpu.createBoxFilter]{cv::gpu::createBoxFilter\_GPU}.


\cvfunc{cv::gpu::createSeparableFilter\_GPU}\label{cppfunc.gpu.createSeparableFilter}
Creates separable filter engine with the specified filters.

126 127 128
\cvdefCpp{
Ptr<FilterEngine\_GPU> createSeparableFilter\_GPU(\par const Ptr<BaseRowFilter\_GPU>\& rowFilter, \par const Ptr<BaseColumnFilter\_GPU>\& columnFilter, \par int srcType, int bufType, int dstType);
}
129

130
\begin{description}
131 132 133 134 135
\cvarg{rowFilter} {"Horizontal" 1D filter.}
\cvarg{columnFilter} {"Vertical" 1D filter.}
\cvarg{srcType}{Input image type. It must be supported by \texttt{rowFilter}.}
\cvarg{bufType}{Buffer image type. It must be supported by \texttt{rowFilter} and \texttt{columnFilter}.}
\cvarg{dstType}{Output image type. It must be supported by \texttt{columnFilter}.}
136
\end{description}
137

138 139 140 141 142 143
Usually this function is used inside high-level functions, like \hyperref[cppfunc.gpu.createSeparableLinearFilter]{cv::gpu::createSeparableLinearFilter\_GPU}.


\cvfunc{cv::gpu::getRowSumFilter\_GPU}\label{cppfunc.gpu.getRowSumFilter}
Creates horizontal 1D box filter.

144 145 146
\cvdefCpp{
Ptr<BaseRowFilter\_GPU> getRowSumFilter\_GPU(int srcType, int sumType, \par int ksize, int anchor = -1);
}
147

148
\begin{description}
149 150 151 152
\cvarg{srcType}{Input image type. Only \texttt{CV\_8UC1} type is supported for now.}
\cvarg{sumType}{Output image type. Only \texttt{CV\_32FC1} type is supported for now.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value (-1) means that the anchor is at the kernel center.}
153
\end{description}
154

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
155
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it. 
156

157 158 159 160

\cvfunc{cv::gpu::getColumnSumFilter\_GPU}\label{cppfunc.gpu.getColumnSumFilter}
Creates vertical 1D box filter.

161 162 163
\cvdefCpp{
Ptr<BaseColumnFilter\_GPU> getColumnSumFilter\_GPU(int sumType, \par int dstType, int ksize, int anchor = -1);
}
164

165
\begin{description}
166 167 168 169
\cvarg{sumType}{Input image type. Only \texttt{CV\_8UC1} type is supported for now.}
\cvarg{dstType}{Output image type. Only \texttt{CV\_32FC1} type is supported for now.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value (-1) means that the anchor is at the kernel center.}
170
\end{description}
171

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
172
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it. 
173

174 175 176 177

\cvfunc{cv::gpu::createBoxFilter\_GPU}\label{cppfunc.gpu.createBoxFilter}
Creates normalized 2D box filter.

178 179 180 181 182 183
\cvdefCpp{
Ptr<FilterEngine\_GPU> createBoxFilter\_GPU(int srcType, int dstType, \par const Size\& ksize, \par const Point\& anchor = Point(-1,-1));
}
\cvdefCpp{
Ptr<BaseFilter\_GPU> getBoxFilter\_GPU(int srcType, int dstType, \par const Size\& ksize, \par Point anchor = Point(-1, -1));
}
184

185
\begin{description}
186 187 188 189
\cvarg{srcType}{Input image type. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4}.}
\cvarg{dstType}{Output image type. Supports only the same as source type.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value Point(-1, -1) means that the anchor is at the kernel center.}
190
\end{description}
191

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
192
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
193

194
See also: \cvCppCross{boxFilter}.
195

196

197
\cvCppFunc{gpu::boxFilter}
198
Smooths the image using the normalized box filter.
199

200
\cvdefCpp{
201
void boxFilter(const GpuMat\& src, GpuMat\& dst, int ddepth, Size ksize, \par Point anchor = Point(-1,-1));
202
}
203

204
\begin{description}
205 206 207 208 209
\cvarg{src}{Input image. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4} source types.}
\cvarg{dst}{Output image type. Will have the same size and the same type as \texttt{src}.}
\cvarg{ddepth}{Output image depth. Support only the same as source depth (\texttt{CV\_8U}) or -1 what means use source depth.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value Point(-1, -1) means that the anchor is at the kernel center.}
210
\end{description}
211

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
212
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
213 214 215

See also: \cvCppCross{boxFilter}, \hyperref[cppfunc.gpu.createBoxFilter]{cv::gpu::createBoxFilter\_GPU}.

216 217 218

\cvCppFunc{gpu::blur}
A synonym for normalized box filter.
219

220 221 222
\cvdefCpp{
void blur(const GpuMat\& src, GpuMat\& dst, Size ksize, \par Point anchor = Point(-1,-1));
}
223

224
\begin{description}
225 226 227 228
\cvarg{src}{Input image. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4} source type.}
\cvarg{dst}{Output image type. Will have the same size and the same type as \texttt{src}.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value Point(-1, -1) means that the anchor is at the kernel center.}
229
\end{description}
230

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
231
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
232

233
See also: \cvCppCross{blur}, \cvCppCross{gpu::boxFilter}.
234

235 236 237 238

\cvfunc{cv::gpu::createMorphologyFilter\_GPU}\label{cppfunc.gpu.createMorphologyFilter}
Creates 2D morphological filter.

239 240 241 242 243 244
\cvdefCpp{
Ptr<FilterEngine\_GPU> createMorphologyFilter\_GPU(int op, int type, \par const Mat\& kernel, \par const Point\& anchor = Point(-1,-1), \par int iterations = 1);
}
\cvdefCpp{
Ptr<BaseFilter\_GPU> getMorphologyFilter\_GPU(int op, int type, \par const Mat\& kernel, const Size\& ksize, \par Point anchor=Point(-1,-1));
}
245

246
\begin{description}
247 248 249 250 251
\cvarg{op} {Morphology operation id. Only \texttt{MORPH\_ERODE} and \texttt{MORPH\_DILATE} are supported.}
\cvarg{type}{Input/output image type. Only \texttt{CV\_8UC1} and \texttt{CV\_8UC4} are supported.}
\cvarg{kernel}{2D 8-bit structuring element for the morphological operation.}
\cvarg{size}{Horizontal or vertical structuring element size for separable morphological operations.}
\cvarg{anchor}{Anchor position within the structuring element; negative values mean that the anchor is at the center.}
252
\end{description}
253

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
254
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
255

256
See also: \cvCppCross{createMorphologyFilter}.
257

258

259
\cvCppFunc{gpu::erode}
260
Erodes an image by using a specific structuring element.
261

262 263 264
\cvdefCpp{
void erode(const GpuMat\& src, GpuMat\& dst, const Mat\& kernel, \par Point anchor = Point(-1, -1), \par int iterations = 1);
}
265

266
\begin{description}
267 268 269
\cvarg{src}{Source image. Only \texttt{CV\_8UC1} and \texttt{CV\_8UC4} types are supported.}
\cvarg{dst}{Destination image. It will have the same size and the same type as \texttt{src}.}
\cvarg{kernel}{Structuring element used for dilation. If \texttt{kernel=Mat()}, a $3 \times 3$ rectangular structuring element is used.}
270
\cvarg{anchor}{Position of the anchor within the element. The default value $(-1, -1)$ means that the anchor is at the element center.}
271
\cvarg{iterations}{Number of times erosion to be applied.}
272
\end{description}
273

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
274
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
275 276 277

See also: \cvCppCross{erode}, \hyperref[cppfunc.gpu.createMorphologyFilter]{cv::gpu::createMorphologyFilter\_GPU}.

278 279

\cvCppFunc{gpu::dilate}
280
Dilates an image by using a specific structuring element.
281

282 283 284
\cvdefCpp{
void dilate(const GpuMat\& src, GpuMat\& dst, const Mat\& kernel, \par Point anchor = Point(-1, -1), \par int iterations = 1);
}
285

286
\begin{description}
287 288 289
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4} source types.}
\cvarg{dst}{Destination image. It will have the same size and the same type as \texttt{src}.}
\cvarg{kernel}{Structuring element used for dilation. If \texttt{kernel=Mat()}, a $3 \times 3$ rectangular structuring element is used.}
290
\cvarg{anchor}{Position of the anchor within the element. The default value $(-1, -1)$ means that the anchor is at the element center.}
291
\cvarg{iterations}{Number of times dilation to be applied.}
292
\end{description}
293

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
294
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
295 296 297

See also: \cvCppCross{dilate}, \hyperref[cppfunc.gpu.createMorphologyFilter]{cv::gpu::createMorphologyFilter\_GPU}.

298 299

\cvCppFunc{gpu::morphologyEx}
300 301
Applies an advanced morphological operation to image.

302 303 304
\cvdefCpp{
void morphologyEx(const GpuMat\& src, GpuMat\& dst, int op, \par const Mat\& kernel, \par Point anchor = Point(-1, -1), \par int iterations = 1);
}
305

306 307 308 309 310 311 312 313 314 315 316 317 318
\begin{description}
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4} source type.}
\cvarg{dst}{Destination image. It will have the same size and the same type as \texttt{src}}
\cvarg{op}{Type of morphological operation, one of the following:
\begin{description}
\cvarg{MORPH\_OPEN}{opening}
\cvarg{MORPH\_CLOSE}{closing}
\cvarg{MORPH\_GRADIENT}{morphological gradient}
\cvarg{MORPH\_TOPHAT}{"top hat"}
\cvarg{MORPH\_BLACKHAT}{"black hat"}
\end{description}}
\cvarg{kernel}{Structuring element.}
\cvarg{anchor}{Position of the anchor within the element. The default value Point(-1, -1) means that the anchor is at the element center.}
319
\cvarg{iterations}{Number of times erosion and dilation to be applied.}
320
\end{description}
321

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
322
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
323

324
See also: \cvCppCross{morphologyEx}.
325

326 327 328 329

\cvfunc{cv::gpu::createLinearFilter\_GPU}\label{cppfunc.gpu.createLinearFilter}
Creates the non-separable linear filter.

330 331 332 333 334 335
\cvdefCpp{
Ptr<FilterEngine\_GPU> createLinearFilter\_GPU(int srcType, int dstType, \par const Mat\& kernel, \par const Point\& anchor = Point(-1,-1));
}
\cvdefCpp{
Ptr<BaseFilter\_GPU> getLinearFilter\_GPU(int srcType, int dstType, \par const Mat\& kernel, const Size\& ksize, \par Point anchor = Point(-1, -1));
}
336

337
\begin{description}
338 339 340 341 342
\cvarg{srcType}{Input image type. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4}.}
\cvarg{dstType}{Output image type. Supports only the same as source type.}
\cvarg{kernel}{2D array of filter coefficients. This filter works with integers kernels, if \texttt{kernel} has \texttt{float} or \texttt{double} type it will be used fixed point arithmetic.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value Point(-1, -1) means that the anchor is at the kernel center.}
343
\end{description}
344

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
345
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
346

347
See also: \cvCppCross{createLinearFilter}.
348

349

350
\cvCppFunc{gpu::filter2D}
351 352
Applies non-separable 2D linear filter to image.

353 354 355
\cvdefCpp{
void filter2D(const GpuMat\& src, GpuMat\& dst, int ddepth, \par const Mat\& kernel, \par Point anchor=Point(-1,-1));
}
356

357
\begin{description}
358 359 360 361 362
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4} source types.}
\cvarg{dst}{Destination image. It will have the same size and the same number of channels as \texttt{src}.}
\cvarg{ddepth}{The desired depth of the destination image. If it is negative, it will be the same as \texttt{src.depth()}. Supports only the same depth as source image.}
\cvarg{kernel}{2D array of filter coefficients. This filter works with integers kernels, if \texttt{kernel} has \texttt{float} or \texttt{double} type it will use fixed point arithmetic.}
\cvarg{anchor}{Anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor should lie within the kernel. The special default value (-1,-1) means that the anchor is at the kernel center.}
363
\end{description}
364

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
365
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
366 367 368

See also: \cvCppCross{filter2D}, \hyperref[cppfunc.gpu.createLinearFilter]{cv::gpu::createLinearFilter\_GPU}.

369 370

\cvCppFunc{gpu::Laplacian}
371 372
Applies Laplacian operator to image.

373 374 375
\cvdefCpp{
void Laplacian(const GpuMat\& src, GpuMat\& dst, int ddepth, \par int ksize = 1, double scale = 1);
}
376

377
\begin{description}
378
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1} and \texttt{CV\_8UC4} source types.}
379
\cvarg{dst}{Destination image; will have the same size and the same number of channels as \texttt{src}.}
380 381 382
\cvarg{ddepth}{Desired depth of the destination image. Supports only tha same depth as source image depth.}
\cvarg{ksize}{Aperture size used to compute the second-derivative filters, see \cvCppCross{getDerivKernels}. It must be positive and odd. Supports only \texttt{ksize} = 1 and \texttt{ksize} = 3.}
\cvarg{scale}{Optional scale factor for the computed Laplacian values (by default, no scaling is applied, see \cvCppCross{getDerivKernels}).}
383
\end{description}
384

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
385
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
386

387
See also: \cvCppCross{Laplacian}, \cvCppCross{gpu::filter2D}.
388

389 390 391 392

\cvfunc{cv::gpu::getLinearRowFilter\_GPU}\label{cppfunc.gpu.getLinearRowFilter}
Creates primitive row filter with the specified kernel.

393 394 395
\cvdefCpp{
Ptr<BaseRowFilter\_GPU> getLinearRowFilter\_GPU(int srcType, \par int bufType, const Mat\& rowKernel, int anchor = -1, \par int borderType = BORDER\_CONSTANT);
}
396

397
\begin{description}
398 399 400 401 402
\cvarg{srcType}{Source array type. Supports only \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} source types.}
\cvarg{bufType}{Inermediate buffer type; must have as many channels as \texttt{srcType}.}
\cvarg{rowKernel}{Filter coefficients.}
\cvarg{anchor}{Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.}
\cvarg{borderType}{Pixel extrapolation method; see \cvCppCross{borderInterpolate}. About limitation see below.}
403
\end{description}
404

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
405
There are two version of algorithm: NPP and OpenCV. NPP calls when \texttt{srcType == CV\_8UC1} or \texttt{srcType == CV\_8UC4} and \texttt{bufType == srcType}, otherwise calls OpenCV version. NPP supports only \texttt{BORDER\_CONSTANT} border type and doesn't check indices outside image. OpenCV version supports only \texttt{CV\_32F} buffer depth and \texttt{BORDER\_REFLECT101}, \texttt{BORDER\_REPLICATE} and \texttt{BORDER\_CONSTANT} border types and checks indices outside image.
406 407 408 409 410 411 412

See also: \hyperref[cppfunc.gpu.getLinearColumnFilter]{cv::gpu::getLinearColumnFilter\_GPU}, \cvCppCross{createSeparableLinearFilter}.


\cvfunc{cv::gpu::getLinearColumnFilter\_GPU}\label{cppfunc.gpu.getLinearColumnFilter}
Creates the primitive column filter with the specified kernel.

413 414 415
\cvdefCpp{
Ptr<BaseColumnFilter\_GPU> getLinearColumnFilter\_GPU(int bufType, \par int dstType, const Mat\& columnKernel, int anchor = -1, \par int borderType = BORDER\_CONSTANT);
}
416

417
\begin{description}
418 419 420 421 422
\cvarg{bufType}{Inermediate buffer type; must have as many channels as \texttt{dstType}.}
\cvarg{dstType}{Destination array type. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} destination types.}
\cvarg{columnKernel}{Filter coefficients.}
\cvarg{anchor}{Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.}
\cvarg{borderType}{Pixel extrapolation method; see \cvCppCross{borderInterpolate}. About limitation see below.}
423
\end{description}
424

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
425
There are two version of algorithm: NPP and OpenCV. NPP calls when \texttt{dstType == CV\_8UC1} or \texttt{dstType == CV\_8UC4} and \texttt{bufType == dstType}, otherwise calls OpenCV version. NPP supports only \texttt{BORDER\_CONSTANT} border type and doesn't check indices outside image. OpenCV version supports only \texttt{CV\_32F} buffer depth and \texttt{BORDER\_REFLECT101}, \texttt{BORDER\_REPLICATE} and \texttt{BORDER\_CONSTANT} border types and checks indices outside image.\newline
426 427 428 429 430 431 432

See also: \hyperref[cppfunc.gpu.getLinearRowFilter]{cv::gpu::getLinearRowFilter\_GPU}, \cvCppCross{createSeparableLinearFilter}.


\cvfunc{cv::gpu::createSeparableLinearFilter\_GPU}\label{cppfunc.gpu.createSeparableLinearFilter}
Creates the separable linear filter engine.

433 434 435
\cvdefCpp{
Ptr<FilterEngine\_GPU> createSeparableLinearFilter\_GPU(int srcType, \par int dstType, const Mat\& rowKernel, const Mat\& columnKernel, \par const Point\& anchor = Point(-1,-1), \par int rowBorderType = BORDER\_DEFAULT, \par int columnBorderType = -1);
}
436

437
\begin{description}
438 439 440 441 442
\cvarg{srcType}{Source array type. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} source types.}
\cvarg{dstType}{Destination array type. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} destination types.}
\cvarg{rowKernel, columnKernel}{Filter coefficients.}
\cvarg{anchor}{Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.}
\cvarg{rowBorderType, columnBorderType}{Pixel extrapolation method in the horizontal and the vertical directions; see \cvCppCross{borderInterpolate}. About limitation see \hyperref[cppfunc.gpu.getLinearRowFilter]{cv::gpu::getLinearRowFilter\_GPU}, \hyperref[cppfunc.gpu.getLinearColumnFilter]{cv::gpu::getLinearColumnFilter\_GPU}.}
443
\end{description}
444

445 446 447
See also: \hyperref[cppfunc.gpu.getLinearRowFilter]{cv::gpu::getLinearRowFilter\_GPU}, \hyperref[cppfunc.gpu.getLinearColumnFilter]{cv::gpu::getLinearColumnFilter\_GPU}, \cvCppCross{createSeparableLinearFilter}.


448 449
\cvCppFunc{gpu::sepFilter2D}
Applies separable 2D linear filter to the image.
450

451 452 453
\cvdefCpp{
void sepFilter2D(const GpuMat\& src, GpuMat\& dst, int ddepth, \par const Mat\& kernelX, const Mat\& kernelY, \par Point anchor = Point(-1,-1), \par int rowBorderType = BORDER\_DEFAULT, \par int columnBorderType = -1);
}
454

455
\begin{description}
456 457 458 459 460 461
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} source types.}
\cvarg{dst}{Destination image; will have the same size and the same number of channels as \texttt{src}.}
\cvarg{ddepth}{Destination image depth. Supports \texttt{CV\_8U}, \texttt{CV\_16S}, \texttt{CV\_32S} and \texttt{CV\_32F}.}
\cvarg{kernelX, kernelY}{Filter coefficients.}
\cvarg{anchor}{Anchor position within the kernel; The default value $(-1, 1)$ means that the anchor is at the kernel center.}
\cvarg{rowBorderType, columnBorderType}{Pixel extrapolation method; see \cvCppCross{borderInterpolate}.}
462
\end{description}
463

464 465 466 467 468 469
See also: \hyperref[cppfunc.gpu.createSeparableLinearFilter]{cv::gpu::createSeparableLinearFilter\_GPU}, \cvCppCross{sepFilter2D}.


\cvfunc{cv::gpu::createDerivFilter\_GPU}\label{cppfunc.gpu.createDerivFilter}
Creates filter engine for the generalized Sobel operator.

470 471 472
\cvdefCpp{
Ptr<FilterEngine\_GPU> createDerivFilter\_GPU(int srcType, int dstType, \par int dx, int dy, int ksize, \par int rowBorderType = BORDER\_DEFAULT, \par int columnBorderType = -1);
}
473

474
\begin{description}
475 476 477 478 479 480
\cvarg{srcType}{Source image type. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} source types.}
\cvarg{dstType}{Destination image type; must have as many channels as \texttt{srcType}. Supports \texttt{CV\_8U}, \texttt{CV\_16S}, \texttt{CV\_32S} and \texttt{CV\_32F} depths.}
\cvarg{dx}{Derivative order in respect with x.}
\cvarg{dy}{Derivative order in respect with y.}
\cvarg{ksize}{Aperture size; see \cvCppCross{getDerivKernels}.}
\cvarg{rowBorderType, columnBorderType}{Pixel extrapolation method; see \cvCppCross{borderInterpolate}.}
481
\end{description}
482 483 484

See also: \hyperref[cppfunc.gpu.createSeparableLinearFilter]{cv::gpu::createSeparableLinearFilter\_GPU}, \cvCppCross{createDerivFilter}.

485 486 487

\cvCppFunc{gpu::Sobel}
Applies generalized Sobel operator to the image.
488

489 490 491
\cvdefCpp{
void Sobel(const GpuMat\& src, GpuMat\& dst, int ddepth, int dx, int dy, \par int ksize = 3, double scale = 1, \par int rowBorderType = BORDER\_DEFAULT, \par int columnBorderType = -1);
}
492

493
\begin{description}
494 495 496 497 498
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} source types.}
\cvarg{dst}{Destination image. Will have the same size and number of channels as source image.}
\cvarg{ddepth}{Destination image depth. Supports \texttt{CV\_8U}, \texttt{CV\_16S}, \texttt{CV\_32S} and \texttt{CV\_32F}.}
\cvarg{dx}{Derivative order in respect with x.}
\cvarg{dy}{Derivative order in respect with y.}
499
\cvarg{ksize}{Size of the extended Sobel kernel, must be 1, 3, 5 or 7.}
500 501
\cvarg{scale}{Optional scale factor for the computed derivative values (by default, no scaling is applied, see \cvCppCross{getDerivKernels}).}
\cvarg{rowBorderType, columnBorderType}{Pixel extrapolation method; see \cvCppCross{borderInterpolate}.}
502
\end{description}
503 504 505

See also: \hyperref[cppfunc.gpu.createSeparableLinearFilter]{cv::gpu::createSeparableLinearFilter\_GPU}, \cvCppCross{Sobel}.

506 507 508

\cvCppFunc{gpu::Scharr}
Calculates the first x- or y- image derivative using Scharr operator.
509

510 511 512
\cvdefCpp{
void Scharr(const GpuMat\& src, GpuMat\& dst, int ddepth, \par int dx, int dy, double scale = 1, \par int rowBorderType = BORDER\_DEFAULT, \par int columnBorderType = -1);
}
513

514
\begin{description}
515 516 517
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} source types.}
\cvarg{dst}{Destination image; will have the same size and the same number of channels as \texttt{src}.}
\cvarg{ddepth}{Destination image depth. Supports \texttt{CV\_8U}, \texttt{CV\_16S}, \texttt{CV\_32S} and \texttt{CV\_32F}.}
518 519
\cvarg{xorder}{Order of the derivative x.}
\cvarg{yorder}{Order of the derivative y.}
520 521
\cvarg{scale}{Optional scale factor for the computed derivative values (by default, no scaling is applied, see \cvCppCross{getDerivKernels}).}
\cvarg{rowBorderType, columnBorderType}{Pixel extrapolation method, see \cvCppCross{borderInterpolate}}
522
\end{description}
523

524 525 526 527 528 529
See also: \hyperref[cppfunc.gpu.createSeparableLinearFilter]{cv::gpu::createSeparableLinearFilter\_GPU}, \cvCppCross{Scharr}.


\cvfunc{cv::gpu::createGaussianFilter\_GPU}\label{cppfunc.gpu.createGaussianFilter}
Creates Gaussian filter engine.

530
\cvdefCpp{
531
Ptr<FilterEngine\_GPU> createGaussianFilter\_GPU(int type, Size ksize, \par double sigmaX, double sigmaY = 0, \par int rowBorderType = BORDER\_DEFAULT, \par int columnBorderType = -1);
532
}
533

534
\begin{description}
535 536 537 538 539
\cvarg{type}{Source and the destination image type. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1}.}
\cvarg{ksize}{Aperture size; see \cvCppCross{getGaussianKernel}.}
\cvarg{sigmaX}{Gaussian sigma in the horizontal direction; see \cvCppCross{getGaussianKernel}.}
\cvarg{sigmaY}{Gaussian sigma in the vertical direction; if 0, then $\texttt{sigmaY}\leftarrow\texttt{sigmaX}$.}
\cvarg{rowBorderType, columnBorderType}{Which border type to use; see \cvCppCross{borderInterpolate}.}
540
\end{description}
541 542 543

See also: \hyperref[cppfunc.gpu.createSeparableLinearFilter]{cv::gpu::createSeparableLinearFilter\_GPU}, \cvCppCross{createGaussianFilter}.

544 545 546

\cvCppFunc{gpu::GaussianBlur}
Smooths the image using Gaussian filter.
547

548
\cvdefCpp{
549
void GaussianBlur(const GpuMat\& src, GpuMat\& dst, Size ksize, \par double sigmaX, double sigmaY = 0, \par int rowBorderType = BORDER\_DEFAULT, \par int columnBorderType = -1);
550
}
551

552
\begin{description}
553 554 555 556 557
\cvarg{src}{Source image. Supports \texttt{CV\_8UC1}, \texttt{CV\_8UC4}, \texttt{CV\_16SC1}, \texttt{CV\_16SC2}, \texttt{CV\_32SC1}, \texttt{CV\_32FC1} source types.}
\cvarg{dst}{Destination image; will have the same size and the same type as \texttt{src}.}
\cvarg{ksize}{Gaussian kernel size; \texttt{ksize.width} and \texttt{ksize.height} can differ, but they both must be positive and odd. Or, they can be zero's, then they are computed from \texttt{sigmaX} amd \texttt{sigmaY}.}
\cvarg{sigmaX, sigmaY}{Gaussian kernel standard deviations in X and Y direction. If \texttt{sigmaY} is zero, it is set to be equal to \texttt{sigmaX}. If they are both zeros, they are computed from \texttt{ksize.width} and \texttt{ksize.height}, respectively, see \cvCppCross{getGaussianKernel}. To fully control the result regardless of possible future modification of all this semantics, it is recommended to specify all of \texttt{ksize}, \texttt{sigmaX} and \texttt{sigmaY}.}
\cvarg{rowBorderType, columnBorderType}{Pixel extrapolation method; see \cvCppCross{borderInterpolate}.}
558
\end{description}
559

560 561 562 563 564 565
See also: \hyperref[cppfunc.gpu.createGaussianFilter]{cv::gpu::createGaussianFilter\_GPU}, \cvCppCross{GaussianBlur}.


\cvfunc{cv::gpu::getMaxFilter\_GPU}\label{cppfunc.gpu.getMaxFilter}
Creates maximum filter.

566 567 568
\cvdefCpp{
Ptr<BaseFilter\_GPU> getMaxFilter\_GPU(int srcType, int dstType, \par const Size\& ksize, Point anchor = Point(-1,-1));
}
569

570
\begin{description}
571 572 573 574
\cvarg{srcType}{Input image type. Supports only \texttt{CV\_8UC1} and \texttt{CV\_8UC4}.}
\cvarg{dstType}{Output image type. Supports only the same type as source.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value (-1) means that the anchor is at the kernel center.}
575
\end{description}
576

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
577
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it. 
578

579 580 581 582

\cvfunc{cv::gpu::getMinFilter\_GPU}\label{cppfunc.gpu.getMinFilter}
Creates minimum filter.

583 584 585
\cvdefCpp{
Ptr<BaseFilter\_GPU> getMinFilter\_GPU(int srcType, int dstType, \par const Size\& ksize, Point anchor = Point(-1,-1));
}
586

587
\begin{description}
588 589 590 591
\cvarg{srcType}{Input image type. Supports only \texttt{CV\_8UC1} and \texttt{CV\_8UC4}.}
\cvarg{dstType}{Output image type. Supports only the same type as source.}
\cvarg{ksize}{Kernel size.}
\cvarg{anchor}{Anchor point. The default value (-1) means that the anchor is at the kernel center.}
592
\end{description}
593

Vladislav Vinogradov's avatar
Vladislav Vinogradov committed
594
\textbf{Please note:} This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.