add ocl::abs

This commit is contained in:
Sebastian Krämer
2013-10-08 15:16:30 +02:00
committed by Sebastian Krmer
parent c844bbdd82
commit 4ffd3fb905
5 changed files with 49 additions and 3 deletions

View File

@@ -60,7 +60,7 @@ using namespace cv::ocl;
/////////////// add subtract multiply divide min max /////////////////////////
//////////////////////////////////////////////////////////////////////////////
enum { ADD = 0, SUB, MUL, DIV, ABS_DIFF, MIN, MAX };
enum { ADD = 0, SUB, MUL, DIV, ABS, 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)
@@ -93,7 +93,7 @@ static void arithmetic_run_generic(const oclMat &src1, const oclMat &src2, const
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", "FUNC_MIN", "FUNC_MAX" };
const char * const funcMap[] = { "FUNC_ADD", "FUNC_SUB", "FUNC_MUL", "FUNC_DIV", "FUNC_ABS", "FUNC_ABS_DIFF", "FUNC_MIN", "FUNC_MAX" };
const char * const channelMap[] = { "", "", "2", "4", "4" };
bool haveScalar = use_scalar || src2.empty();
@@ -216,9 +216,15 @@ void cv::ocl::max(const oclMat &src1, const oclMat &src2, oclMat &dst)
}
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Absdiff ////////////////////////////////////
/////////////////////////////Abs, Absdiff ////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void cv::ocl::abs(const oclMat &src1, oclMat &dst)
{
// explicitly uses use_scalar (even if zero) so that the correct kernel is used
arithmetic_run_generic(src1, oclMat(), Scalar(), oclMat(), dst, ABS, true);
}
void cv::ocl::absdiff(const oclMat &src1, const oclMat &src2, oclMat &dst)
{
arithmetic_run_generic(src1, src2, Scalar(), oclMat(), dst, ABS_DIFF);