cv::compare

This commit is contained in:
Ilya Lavrenov
2014-03-11 23:41:44 +04:00
parent 2755ae5df9
commit f138b613b7
8 changed files with 52 additions and 27 deletions

View File

@@ -711,8 +711,7 @@ private:
static bool ocl_threshold( InputArray _src, OutputArray _dst, double & thresh, double maxval, int thresh_type )
{
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type),
kercn = cn <= 4 && cn != 3 ? cn : ocl::predictOptimalVectorWidth(_src, _dst),
ktype = CV_MAKE_TYPE(depth, kercn);
kercn = ocl::predictOptimalVectorWidth(_src, _dst), ktype = CV_MAKE_TYPE(depth, kercn);
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
if ( !(thresh_type == THRESH_BINARY || thresh_type == THRESH_BINARY_INV || thresh_type == THRESH_TRUNC ||
@@ -723,8 +722,9 @@ static bool ocl_threshold( InputArray _src, OutputArray _dst, double & thresh, d
const char * const thresholdMap[] = { "THRESH_BINARY", "THRESH_BINARY_INV", "THRESH_TRUNC",
"THRESH_TOZERO", "THRESH_TOZERO_INV" };
ocl::Kernel k("threshold", ocl::imgproc::threshold_oclsrc,
format("-D %s -D T=%s%s", thresholdMap[thresh_type],
ocl::typeToStr(ktype), doubleSupport ? " -D DOUBLE_SUPPORT" : ""));
format("-D %s -D T=%s -D T1=%s%s", thresholdMap[thresh_type],
ocl::typeToStr(ktype), ocl::typeToStr(depth),
doubleSupport ? " -D DOUBLE_SUPPORT" : ""));
if (k.empty())
return false;
@@ -736,8 +736,8 @@ static bool ocl_threshold( InputArray _src, OutputArray _dst, double & thresh, d
thresh = cvFloor(thresh);
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst, cn, kercn),
ocl::KernelArg::Constant(Mat(1, 1, ktype, Scalar::all(thresh))),
ocl::KernelArg::Constant(Mat(1, 1, ktype, Scalar::all(maxval))));
ocl::KernelArg::Constant(Mat(1, 1, depth, Scalar::all(thresh))),
ocl::KernelArg::Constant(Mat(1, 1, depth, Scalar::all(maxval))));
size_t globalsize[2] = { dst.cols * cn / kercn, dst.rows };
return k.run(2, globalsize, NULL, false);