From aa5767421aa5758ee015abe0dcf7d2f4229b8aee Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 15 Apr 2014 17:43:06 +0400 Subject: [PATCH] cv::reduce (min/max to single column) --- modules/core/src/matrix.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index d753b97a30..6989d61bd3 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -3245,16 +3245,53 @@ typedef void (*ReduceFunc)( const Mat& src, Mat& dst ); #define reduceSumC32f64f reduceC_ > #define reduceSumC64f64f reduceC_ > +#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY +#define REDUCE_OP(favor, optype, type1, type2) \ +static inline void reduce##optype##C##favor(const cv::Mat& srcmat, cv::Mat& dstmat) \ +{ \ + typedef Ipp##favor IppType; \ + cv::Size size = srcmat.size(); \ + if (srcmat.channels() == 1) \ + { \ + for (int y = 0; y < size.height; ++y) \ + { \ + if (ippi##optype##_##favor##_C1R(srcmat.ptr(y), (int)srcmat.step, \ + ippiSize(size.width, 1), dstmat.ptr(y)) < 0) \ + { \ + cv::Mat dstroi = dstmat.rowRange(y, y + 1); \ + cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat.rowRange(y, y + 1), dstroi); \ + } \ + } \ + return; \ + } \ + cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat, dstmat); \ +} +#endif + +#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY +REDUCE_OP(8u, Max, uchar, uchar) +REDUCE_OP(16u, Max, ushort, ushort) +REDUCE_OP(16s, Max, short, short) +REDUCE_OP(32f, Max, float, float) +#else #define reduceMaxC8u reduceC_ > #define reduceMaxC16u reduceC_ > #define reduceMaxC16s reduceC_ > #define reduceMaxC32f reduceC_ > +#endif #define reduceMaxC64f reduceC_ > +#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY +REDUCE_OP(8u, Min, uchar, uchar) +REDUCE_OP(16u, Min, ushort, ushort) +REDUCE_OP(16s, Min, short, short) +REDUCE_OP(32f, Min, float, float) +#else #define reduceMinC8u reduceC_ > #define reduceMinC16u reduceC_ > #define reduceMinC16s reduceC_ > #define reduceMinC32f reduceC_ > +#endif #define reduceMinC64f reduceC_ > #ifdef HAVE_OPENCL