// supports all data types
CV_EXPORTS void divide(double scale, const oclMat &src1, oclMat &dst);
+ //! computes element-wise minimum of the two arrays (dst = min(src1, src2))
+ // supports all data types
+ CV_EXPORTS void min(const oclMat &src1, const oclMat &src2, oclMat &dst);
+
+ //! computes element-wise maximum of the two arrays (dst = max(src1, src2))
+ // supports all data types
+ CV_EXPORTS void max(const oclMat &src1, const oclMat &src2, oclMat &dst);
+
//! compares elements of two arrays (dst = src1 <cmpop> src2)
// supports all data types
CV_EXPORTS void compare(const oclMat &src1, const oclMat &src2, oclMat &dst, int cmpop);
using namespace cv::ocl;
//////////////////////////////////////////////////////////////////////////////
-/////////////////////// add subtract multiply divide /////////////////////////
+/////////////// add subtract multiply divide min max /////////////////////////
//////////////////////////////////////////////////////////////////////////////
-enum { ADD = 0, SUB, MUL, DIV, ABS_DIFF };
+enum { ADD = 0, SUB, MUL, DIV, ABS_DIFF, MIN, MAX };
static void arithmetic_run_generic(const oclMat &src1, const oclMat &src2, const Scalar & scalar, const oclMat & mask,
oclMat &dst, int op_type, bool use_scalar = false)
CV_Assert(src2.empty() || (!src2.empty() && src1.type() == src2.type() && src1.size() == src2.size()));
CV_Assert(mask.empty() || (!mask.empty() && mask.type() == CV_8UC1 && mask.size() == src1.size()));
- CV_Assert(op_type >= ADD && op_type <= ABS_DIFF);
+ CV_Assert(op_type >= ADD && op_type <= MAX);
dst.create(src1.size(), src1.type());
const char * const typeMap[] = { "uchar", "char", "ushort", "short", "int", "float", "double" };
const char * const WTypeMap[] = { "short", "short", "int", "int", "int", "float", "double" };
- const char * const funcMap[] = { "FUNC_ADD", "FUNC_SUB", "FUNC_MUL", "FUNC_DIV", "FUNC_ABS_DIFF" };
+ const char * const funcMap[] = { "FUNC_ADD", "FUNC_SUB", "FUNC_MUL", "FUNC_DIV", "FUNC_ABS_DIFF", "FUNC_MIN", "FUNC_MAX" };
const char * const channelMap[] = { "", "", "2", "4", "4" };
bool haveScalar = use_scalar || src2.empty();
arithmetic_run_generic(src, oclMat(), Scalar::all(scalar), oclMat(), dst, DIV);
}
+void cv::ocl::min(const oclMat &src1, const oclMat &src2, oclMat &dst)
+{
+ arithmetic_run_generic(src1, src2, Scalar::all(0), oclMat(), dst, MIN);
+}
+
+void cv::ocl::max(const oclMat &src1, const oclMat &src2, oclMat &dst)
+{
+ arithmetic_run_generic(src1, src2, Scalar::all(0), oclMat(), dst, MAX);
+}
+
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Absdiff ////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
loopcount = 1;
n_factors = 1;
sizev.push_back(minSize);
- scalev.push_back( min(cvRound(minSize.width / winsize0.width), cvRound(minSize.height / winsize0.height)) );
+ scalev.push_back( std::min(cvRound(minSize.width / winsize0.width), cvRound(minSize.height / winsize0.height)) );
}
detect_piramid_info *scaleinfo = (detect_piramid_info *)malloc(sizeof(detect_piramid_info) * loopcount);
{
loopcount = 1;
sizev.push_back(minSize);
- scalev.push_back( min(cvRound(minSize.width / winSize0.width), cvRound(minSize.height / winSize0.height)) );
+ scalev.push_back( std::min(cvRound(minSize.width / winSize0.width), cvRound(minSize.height / winSize0.height)) );
}
((OclBuffers *)buffers)->pbuffer = openCLCreateBuffer(cv::ocl::Context::getContext(), CL_MEM_READ_ONLY,
dst[dst_index] = convertToT(value);
#endif
+#if defined (FUNC_MIN)
+#define EXPRESSION dst[dst_index] = min( src1[src1_index], src2[src2_index] );
+#endif
+
+#if defined (FUNC_MAX)
+#define EXPRESSION dst[dst_index] = max( src1[src1_index], src2[src2_index] );
+#endif
+
//////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////// ADD ////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Absdiff /////////////////////////////////////////////////
+typedef ArithmTestBase Min;
+
+TEST_P(Min, Mat)
+{
+ for (int j = 0; j < LOOP_TIMES; j++)
+ {
+ random_roi();
+
+ dst1_roi = cv::min(src1_roi, src2_roi);
+ cv::ocl::min(gsrc1, gsrc2, gdst1);
+ Near(0);
+ }
+}
+
+typedef ArithmTestBase Max;
+
+TEST_P(Max, Mat)
+{
+ for (int j = 0; j < LOOP_TIMES; j++)
+ {
+ random_roi();
+
+ dst1_roi = cv::min(src1_roi, src2_roi);
+ cv::ocl::min(gsrc1, gsrc2, gdst1);
+ Near(0);
+ }
+}
+
+//////////////////////////////// Absdiff /////////////////////////////////////////////////
+
typedef ArithmTestBase Absdiff;
TEST_P(Absdiff, Mat)
INSTANTIATE_TEST_CASE_P(Arithm, Sub, Combine(testing::Range(CV_8U, CV_USRTYPE1), testing::Range(1, 5), Bool()));
INSTANTIATE_TEST_CASE_P(Arithm, Mul, Combine(testing::Range(CV_8U, CV_USRTYPE1), testing::Range(1, 5), Bool()));
INSTANTIATE_TEST_CASE_P(Arithm, Div, Combine(testing::Range(CV_8U, CV_USRTYPE1), testing::Range(1, 5), Bool()));
+INSTANTIATE_TEST_CASE_P(Arithm, Min, Combine(testing::Range(CV_8U, CV_USRTYPE1), testing::Range(1, 5), Bool()));
+INSTANTIATE_TEST_CASE_P(Arithm, Max, Combine(testing::Range(CV_8U, CV_USRTYPE1), testing::Range(1, 5), Bool()));
INSTANTIATE_TEST_CASE_P(Arithm, Absdiff, Combine(testing::Range(CV_8U, CV_USRTYPE1), testing::Range(1, 5), Bool()));
INSTANTIATE_TEST_CASE_P(Arithm, CartToPolar, Combine(Values(CV_32F, CV_64F), testing::Range(1, 5), Bool()));
INSTANTIATE_TEST_CASE_P(Arithm, PolarToCart, Combine(Values(CV_32F, CV_64F), testing::Range(1, 5), Bool()));