Commit c6a01f26 authored by Andrey Pavlenko's avatar Andrey Pavlenko Committed by OpenCV Buildbot

Merge pull request #1688 from alalek:ocl_fix_filters

parents ea645891 58be2546
......@@ -133,7 +133,7 @@ Creates a normalized 2D box filter.
.. ocv:function:: Ptr<BaseFilter_GPU> ocl::getBoxFilter_GPU(int srcType, int dstType, const Size &ksize, Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT)
:param srcType: Input image type supporting ``CV_8UC1`` and ``CV_8UC4`` .
:param srcType: Input image type.
:param dstType: Output image type. It supports only the same values as the source type.
......@@ -141,9 +141,7 @@ Creates a normalized 2D box filter.
:param anchor: Anchor point. The default value ``Point(-1, -1)`` means that the anchor is at the kernel center.
:param borderType: Supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101,BORDER_WRAP.
.. 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.
:param borderType: Border type.
.. seealso:: :ocv:func:`boxFilter`
......@@ -153,21 +151,19 @@ Smooths the image using the normalized box filter.
.. ocv:function:: void ocl::boxFilter(const oclMat &src, oclMat &dst, int ddepth, Size ksize, Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT)
:param src: Input image. ``CV_8UC1`` and ``CV_8UC4`` source types are supported.
:param src: Input image.
:param dst: Output image type. The size and type is the same as ``src`` .
:param ddepth: Output image depth. If -1, the output image has the same depth as the input one. The only values allowed here are ``CV_8U`` and -1.
:param ddepth: Desired depth of the destination image. If it is negative, it is the same as ``src.depth()`` . It supports only the same depth as the source image depth.
:param ksize: Kernel size.
:param anchor: Anchor point. The default value ``Point(-1, -1)`` means that the anchor is at the kernel center.
:param borderType: Supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101,BORDER_WRAP.
Smoothes image using box filter.Supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4.
:param borderType: Border type.
.. 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.
Smoothes image using box filter.
ocl::blur
-------------
......@@ -175,7 +171,7 @@ Acts as a synonym for the normalized box filter.
.. ocv:function:: void ocl::blur(const oclMat &src, oclMat &dst, Size ksize, Point anchor = Point(-1, -1), int borderType = BORDER_CONSTANT)
:param src: Input image. ``CV_8UC1`` and ``CV_8UC4`` source types are supported.
:param src: Input image.
:param dst: Output image type with the same size and type as ``src`` .
......@@ -183,9 +179,7 @@ Acts as a synonym for the normalized box filter.
:param anchor: Anchor point. The default value Point(-1, -1) means that the anchor is at the kernel center.
:param borderType: Supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101,BORDER_WRAP.
.. 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.
:param borderType: Border type.
.. seealso:: :ocv:func:`blur`, :ocv:func:`ocl::boxFilter`
......@@ -217,11 +211,11 @@ Creates a non-separable linear filter.
.. ocv:function:: Ptr<FilterEngine_GPU> ocl::createLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, const Point &anchor = Point(-1, -1), int borderType = BORDER_DEFAULT)
:param srcType: Input image type. Supports ``CV_8U`` , ``CV_16U`` and ``CV_32F`` one and four channel image.
:param srcType: Input image type..
:param dstType: Output image type. The same type as ``src`` is supported.
:param kernel: 2D array of filter coefficients. Floating-point coefficients will be converted to fixed-point representation before the actual processing. Supports size up to 16. For larger kernels use :ocv:func:`ocl::convolve`.
:param kernel: 2D array of filter coefficients.
:param anchor: Anchor point. The default value Point(-1, -1) means that the anchor is at the kernel center.
......@@ -234,9 +228,9 @@ ocl::filter2D
-----------------
Applies the non-separable 2D linear filter to an image.
.. ocv:function:: void ocl::filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernel, Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT)
.. ocv:function:: void ocl::filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernel, Point anchor = Point(-1, -1), double delta = 0.0, int borderType = BORDER_DEFAULT)
:param src: Source image. Supports ``CV_8U`` , ``CV_16U`` and ``CV_32F`` one and four channel image.
:param src: Source image.
:param dst: Destination image. The size and the number of channels is the same as ``src`` .
......@@ -246,9 +240,9 @@ Applies the non-separable 2D linear filter to an image.
:param anchor: Anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor resides within the kernel. The special default value (-1,-1) means that the anchor is at the kernel center.
:param borderType: Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate` .
:param delta: optional value added to the filtered pixels before storing them in ``dst``. Value '0' is supported only.
:param stream: Stream for the asynchronous version.
:param borderType: Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate` .
ocl::getLinearRowFilter_GPU
-------------------------------
......@@ -447,7 +441,7 @@ ocl::Laplacian
------------------
Returns void
.. ocv:function:: void ocl::Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize = 1, double scale = 1)
.. ocv:function:: void ocl::Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize = 1, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT)
:param src: The source image
......@@ -459,6 +453,10 @@ Returns void
:param scale: The optional scale factor for the computed Laplacian values (by default, no scaling is applied
:param delta: Optional delta value that is added to the results prior to storing them in ``dst`` . Supported value is 0 only.
:param bordertype: Pixel extrapolation method.
The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator.
ocl::convolve
......
......@@ -718,11 +718,12 @@ namespace cv
CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU( int srcType, int dstType, int dx, int dy, int ksize, int borderType = BORDER_DEFAULT );
//! applies Laplacian operator to the image
// supports only ksize = 1 and ksize = 3 8UC1 8UC4 32FC1 32FC4 data type
CV_EXPORTS void Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize = 1, double scale = 1);
// supports only ksize = 1 and ksize = 3
CV_EXPORTS void Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize = 1, double scale = 1,
double delta=0, int borderType=BORDER_DEFAULT);
//! returns 2D box filter
// supports CV_8UC1 and CV_8UC4 source type, dst type must be the same as source type
// dst type must be the same as source type
CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType,
const Size &ksize, Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
......@@ -731,17 +732,16 @@ namespace cv
const Point &anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
//! returns 2D filter with the specified kernel
// supports CV_8UC1 and CV_8UC4 types
// supports: dst type must be the same as source type
CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, const Size &ksize,
const Point &anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
//! returns the non-separable linear filter engine
// supports: dst type must be the same as source type
CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat &kernel,
const Point &anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
//! smooths the image using the normalized box filter
// supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4
// supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101,BORDER_WRAP
CV_EXPORTS void boxFilter(const oclMat &src, oclMat &dst, int ddepth, Size ksize,
Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
......@@ -757,8 +757,6 @@ namespace cv
const Point &anchor = Point(-1, -1), int iterations = 1);
//! a synonym for normalized box filter
// supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4
// supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101
static inline void blur(const oclMat &src, oclMat &dst, Size ksize, Point anchor = Point(-1, -1),
int borderType = BORDER_CONSTANT)
{
......@@ -766,10 +764,8 @@ namespace cv
}
//! applies non-separable 2D linear filter to the image
// Note, at the moment this function only works when anchor point is in the kernel center
// and kernel size supported is either 3x3 or 5x5; otherwise the function will fail to output valid result
CV_EXPORTS void filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernel,
Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
Point anchor = Point(-1, -1), double delta = 0.0, int borderType = BORDER_DEFAULT);
//! applies separable 2D linear filter to the image
CV_EXPORTS void sepFilter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernelX, const Mat &kernelY,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -72,6 +72,13 @@ double checkNorm(const cv::Mat &m);
double checkNorm(const cv::Mat &m1, const cv::Mat &m2);
double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
inline double checkNormRelative(const Mat &m1, const Mat &m2)
{
return cv::norm(m1, m2, cv::NORM_INF) /
std::max((double)std::numeric_limits<float>::epsilon(),
(double)std::max(cv::norm(m1, cv::NORM_INF), norm(m2, cv::NORM_INF)));
}
#define EXPECT_MAT_NORM(mat, eps) \
{ \
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
......@@ -84,6 +91,13 @@ double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
}
#define EXPECT_MAT_NEAR_RELATIVE(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNormRelative(cv::Mat(mat1), cv::Mat(mat2)), eps); \
}
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment