提交 ed749c4b 编写于 作者: V Vladislav Vinogradov

added missing arithm operations to gpu module

上级 f947c2eb
......@@ -539,32 +539,41 @@ namespace cv
//////////////////////////// Per-element operations ////////////////////////////////////
//! adds one matrix to another (c = a + b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
//! adds scalar to a matrix (c = a + s)
//! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
//! subtracts one matrix from another (c = a - b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
//! subtracts scalar from a matrix (c = a - s)
//! supports CV_32FC1 and CV_32FC2 type
CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise product of the two arrays (c = a * b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! multiplies matrix to a scalar (c = a * s)
//! supports CV_32FC1 type
CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise quotient of the two arrays (c = a / b)
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise quotient of matrix and scalar (c = a / s)
//! supports CV_32FC1 type
CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
//! computes element-wise weighted product of the two arrays (c = scale * a * b)
CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
//! weighted multiplies matrix to a scalar (c = scale * a * s)
CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
//! computes element-wise weighted quotient of the two arrays (c = a / b)
CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
//! computes element-wise weighted quotient of matrix and scalar (c = a / s)
CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
//! computes element-wise weighted reciprocal of an array (dst = scale/src2)
CV_EXPORTS void divide(double scale, const GpuMat& src2, GpuMat& dst, int dtype = -1, Stream& stream = Stream::Null());
//! computes the weighted sum of two arrays (dst = alpha*src1 + beta*src2 + gamma)
CV_EXPORTS void addWeighted(const GpuMat& src1, double alpha, const GpuMat& src2, double beta, double gamma, GpuMat& dst,
int dtype = -1, Stream& stream = Stream::Null());
//! adds scaled array to another one (dst = alpha*src1 + src2)
static inline void scaleAdd(const GpuMat& src1, double alpha, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
{
addWeighted(src1, alpha, src2, 1.0, 0.0, dst, -1, stream);
}
//! computes element-wise absolute difference of two arrays (c = abs(a - b))
CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise absolute difference of array and scalar (c = abs(a - s))
CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c, Stream& stream = Stream::Null());
//! computes exponent of each matrix element (b = e**a)
//! supports only CV_32FC1 type
......@@ -580,13 +589,6 @@ namespace cv
//! supports only CV_32FC1 type
CV_EXPORTS void log(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
//! computes element-wise absolute difference of two arrays (c = abs(a - b))
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
//! computes element-wise absolute difference of array and scalar (c = abs(a - s))
//! supports only CV_32FC1 type
CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c, Stream& stream = Stream::Null());
//! compares elements of two arrays (c = a <cmpop> b)
//! supports CV_8UC4, CV_32FC1 types
CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop, Stream& stream = Stream::Null());
......@@ -615,10 +617,6 @@ namespace cv
//! computes per-element maximum of array and scalar (dst = max(src1, src2))
CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());
//! computes the weighted sum of two arrays
CV_EXPORTS void addWeighted(const GpuMat& src1, double alpha, const GpuMat& src2, double beta, double gamma, GpuMat& dst,
int dtype = -1, Stream& stream = Stream::Null());
////////////////////////////// Image processing //////////////////////////////
......
......@@ -639,17 +639,17 @@ void cv::gpu::morphologyEx(const GpuMat& src, GpuMat& dst, int op, const Mat& ke
case CV_MOP_GRADIENT:
erode(src, buf2, kernel, buf1, anchor, iterations, stream);
dilate(src, dst, kernel, buf1, anchor, iterations, stream);
subtract(dst, buf2, dst, stream);
subtract(dst, buf2, dst, GpuMat(), -1, stream);
break;
case CV_MOP_TOPHAT:
erode(src, dst, kernel, buf1, anchor, iterations, stream);
dilate(dst, buf2, kernel, buf1, anchor, iterations, stream);
subtract(src, buf2, dst, stream);
subtract(src, buf2, dst, GpuMat(), -1, stream);
break;
case CV_MOP_BLACKHAT:
dilate(src, dst, kernel, buf1, anchor, iterations, stream);
erode(dst, buf2, kernel, buf1, anchor, iterations, stream);
subtract(buf2, src, dst, stream);
subtract(buf2, src, dst, GpuMat(), -1, stream);
break;
default:
CV_Error(CV_StsBadArg, "unknown morphological operation");
......
......@@ -96,7 +96,7 @@ TEST_P(AddArray, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, AddArray, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32SC1, CV_32FC1)));
struct AddScalar : ArithmTest {};
......@@ -130,7 +130,7 @@ TEST_P(AddScalar, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, AddScalar, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_32FC1, CV_32FC2)));
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1, CV_32FC1, CV_32FC2)));
////////////////////////////////////////////////////////////////////////////////
// subtract
......@@ -161,7 +161,7 @@ TEST_P(SubtractArray, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, SubtractArray, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32SC1, CV_32FC1)));
struct SubtractScalar : ArithmTest {};
......@@ -195,7 +195,7 @@ TEST_P(SubtractScalar, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, SubtractScalar, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_32FC1, CV_32FC2)));
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1, CV_32FC1, CV_32FC2)));
////////////////////////////////////////////////////////////////////////////////
// multiply
......@@ -226,7 +226,7 @@ TEST_P(MultiplyArray, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, MultiplyArray, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32SC1, CV_32FC1)));
struct MultiplyScalar : ArithmTest {};
......@@ -260,7 +260,7 @@ TEST_P(MultiplyScalar, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, MultiplyScalar, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_32FC1)));
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1, CV_32FC1)));
////////////////////////////////////////////////////////////////////////////////
// divide
......@@ -291,7 +291,7 @@ TEST_P(DivideArray, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, DivideArray, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32SC1, CV_32FC1)));
struct DivideScalar : ArithmTest {};
......@@ -325,7 +325,7 @@ TEST_P(DivideScalar, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, DivideScalar, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_32FC1)));
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1, CV_32FC1)));
////////////////////////////////////////////////////////////////////////////////
// transpose
......@@ -387,7 +387,7 @@ TEST_P(AbsdiffArray, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, AbsdiffArray, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1)));
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32SC1, CV_32FC1)));
struct AbsdiffScalar : ArithmTest {};
......@@ -421,7 +421,7 @@ TEST_P(AbsdiffScalar, Accuracy)
INSTANTIATE_TEST_CASE_P(Arithm, AbsdiffScalar, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_32FC1)));
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1, CV_32FC1)));
////////////////////////////////////////////////////////////////////////////////
// compare
......@@ -813,7 +813,7 @@ TEST_P(Pow, Accuracy)
/*std::cout << mat << std::endl << std::endl;
std::cout << dst << std::endl << std::endl;
std::cout << dst_gold << std::endl;*/
EXPECT_MAT_NEAR(dst_gold, dst, 1);
EXPECT_MAT_NEAR(dst_gold, dst, 2);
}
INSTANTIATE_TEST_CASE_P(Arithm, Pow, testing::Combine(
......
......@@ -169,8 +169,8 @@ TEST_P(Resize, Accuracy)
gpuRes2.download(dst2);
);
EXPECT_MAT_SIMILAR(dst_gold1, dst1, 0.2);
EXPECT_MAT_SIMILAR(dst_gold2, dst2, 0.2);
EXPECT_MAT_SIMILAR(dst_gold1, dst1, 0.21);
EXPECT_MAT_SIMILAR(dst_gold2, dst2, 0.21);
}
INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册