Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images.
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.
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;
};
Note
This class does not allocate memory for a destination image. Usually this class is used inside gpu::FilterEngine_GPU.
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.
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;
};
Note
This class does not allocate memory for a destination image. Usually this class is used inside gpu::FilterEngine_GPU.
Base class for non-separable 2D filters.
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;
};
Note
This class does not allocate memory for a destination image. Usually this class is used inside gpu::FilterEngine_GPU.
Base class for the Filter Engine.
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;
};
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 FilterEngine_GPU instances are returned by various create*Filter_GPU functions (see below), and they are used inside high-level functions such as gpu::filter2D(), gpu::erode(), gpu::Sobel() , and others.
By using FilterEngine_GPU instead of functions you can avoid unnecessary memory allocation for intermediate buffers and get better performance:
while (...)
{
gpu::GpuMat src = getImg();
gpu::GpuMat dst;
// Allocate and release buffers at each iterations
gpu::GaussianBlur(src, dst, ksize, sigma1);
}
// Allocate buffers only once
cv::Ptr<gpu::FilterEngine_GPU> filter =
gpu::createGaussianFilter_GPU(CV_8UC4, ksize, sigma1);
while (...)
{
gpu::GpuMat src = getImg();
gpu::GpuMat dst;
filter->apply(src, dst, cv::Rect(0, 0, src.cols, src.rows));
}
// Release buffers only once
filter.release();
``FilterEngine_GPU`` can process a rectangular sub-region of an image. By default, if ``roi == Rect(0,0,-1,-1)``, ``FilterEngine_GPU`` processes the inner region of an image ( ``Rect(anchor.x, anchor.y, src_size.width - ksize.width, src_size.height - ksize.height)`` ) because some filters do not check whether indices are outside the image for better perfomance. See below to understand which filters support processing the whole image and which do not and identify image type limitations.
Note
The GPU filters do not support the in-place mode.
See also
gpu::BaseRowFilter_GPU, gpu::BaseColumnFilter_GPU, gpu::BaseFilter_GPU, gpu::createFilter2D_GPU(), gpu::createSeparableFilter_GPU(), gpu::createBoxFilter_GPU(), gpu::createMorphologyFilter_GPU(), gpu::createLinearFilter_GPU(), gpu::createSeparableLinearFilter_GPU(), gpu::createDerivFilter_GPU(), gpu::createGaussianFilter_GPU()
Creates a non-separable filter engine with the specified filter.
Parameters: |
|
---|
Usually this function is used inside such high-level functions as gpu::createLinearFilter_GPU(), gpu::createBoxFilter_GPU().
Creates a separable filter engine with the specified filters.
Parameters: |
|
---|
Usually this function is used inside such high-level functions as gpu::createSeparableLinearFilter_GPU().
Creates a horizontal 1D box filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
Creates a vertical 1D box filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
Creates a normalized 2D box filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Smooths the image using the normalized box filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Acts as a synonym for the normalized box filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Creates a 2D morphological filter.
{Morphology operation id. Only MORPH_ERODE and MORPH_DILATE are supported.}
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Erodes an image by using a specific structuring element.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Dilates an image by using a specific structuring element.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Applies an advanced morphological operation to an image.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Creates a non-separable linear filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Applies the non-separable 2D linear filter to an image.
Parameters: |
|
---|
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Applies the Laplacian operator to an image.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
See also
Laplacian(),:ocv:func:gpu::filter2D .
Creates a primitive row filter with the specified kernel.
Parameters: |
|
---|
There are two versions of the algorithm: NPP and OpenCV.
- NPP version is called when srcType == CV_8UC1 or srcType == CV_8UC4 and bufType == srcType . Otherwise, the OpenCV version is called. NPP supports only BORDER_CONSTANT border type and does not check indices outside the image.
- OpenCV version supports only CV_32F buffer depth and BORDER_REFLECT101,``BORDER_REPLICATE``, and BORDER_CONSTANT border types. It checks indices outside the image.
See also
Creates a primitive column filter with the specified kernel.
Parameters: |
|
---|
There are two versions of the algorithm: NPP and OpenCV. * NPP version is called when dstType == CV_8UC1 or dstType == CV_8UC4 and bufType == dstType . Otherwise, the OpenCV version is called. NPP supports only BORDER_CONSTANT border type and does not check indices outside the image. * OpenCV version supports only CV_32F buffer depth and BORDER_REFLECT101, BORDER_REPLICATE, and BORDER_CONSTANT border types. It checks indices outside image.
Creates a separable linear filter engine.
Parameters: |
|
---|
Applies a separable 2D linear filter to an image.
Parameters: |
|
---|
Creates a filter engine for the generalized Sobel operator.
Parameters: |
|
---|
Applies the generalized Sobel operator to an image.
Parameters: |
|
---|
Calculates the first x- or y- image derivative using the Scharr operator.
Parameters: |
|
---|
Creates a Gaussian filter engine.
Parameters: |
|
---|
Smooths an image using the Gaussian filter.
Parameters: |
|
---|
Creates the maximum filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
Creates the minimum filter.
Parameters: |
|
---|
Note
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.