From c6f208e1c89f567d4a972b567449fb84d39350ac Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 4 Apr 2014 15:52:13 +0400 Subject: [PATCH] cv::medianBlur --- modules/imgproc/src/imgwarp.cpp | 9 +++++---- modules/imgproc/src/smooth.cpp | 35 ++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index ec9a9b595c..fef02e7fe4 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -4013,8 +4013,9 @@ private: double *M; }; -/* -#if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 IPP_VERSION_MINOR >= 1 + + /* +#if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 && IPP_VERSION_MINOR >= 1 class IPPWarpAffineInvoker : public ParallelLoopBody { @@ -4215,7 +4216,7 @@ void cv::warpAffine( InputArray _src, OutputArray _dst, const int AB_SCALE = 1 << AB_BITS; /* -#if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 IPP_VERSION_MINOR >= 1 +#if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 && IPP_VERSION_MINOR >= 1 int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); if( ( depth == CV_8U || depth == CV_16U || depth == CV_32F ) && ( cn == 1 || cn == 3 || cn == 4 ) && @@ -4380,7 +4381,7 @@ private: Scalar borderValue; }; -/* + /* #if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 && IPP_VERSION_MINOR >= 1 class IPPWarpPerspectiveInvoker : public ParallelLoopBody diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 84570bd2c2..67b3793ad4 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -1948,13 +1948,46 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize ) return; } - CV_OCL_RUN(_src0.dims() <= 2 && _dst.isUMat(), + CV_OCL_RUN(_dst.isUMat(), ocl_medianFilter(_src0,_dst, ksize)) Mat src0 = _src0.getMat(); _dst.create( src0.size(), src0.type() ); Mat dst = _dst.getMat(); +#ifdef HAVE_IPP +#define IPP_FILTER_MEDIAN_BORDER(ippType, ippDataType, flavor) \ + do \ + { \ + if (ippiFilterMedianBorderGetBufferSize(dstRoiSize, maskSize, \ + ippDataType, CV_MAT_CN(type), &bufSize) >= 0) \ + { \ + Ipp8u * buffer = (Ipp8u *)ippMalloc(bufSize); \ + IppStatus status = ippiFilterMedianBorder_##flavor((const ippType *)src0.data, (int)src0.step, \ + (ippType *)dst.data, (int)dst.step, dstRoiSize, maskSize, \ + ippBorderRepl, (ippType)0, buffer); \ + ippiFree(buffer); \ + if (status >= 0) \ + return; \ + } \ + } \ + while ((void)0, 0) + + Ipp32s bufSize; + IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize); + + int type = src0.type(); + if (type == CV_8UC1) + IPP_FILTER_MEDIAN_BORDER(Ipp8u, ipp8u, 8u_C1R); + else if (type == CV_16UC1) + IPP_FILTER_MEDIAN_BORDER(Ipp16u, ipp16u, 16u_C1R); + else if (type == CV_16SC1) + IPP_FILTER_MEDIAN_BORDER(Ipp16s, ipp16s, 16s_C1R); + else if (type == CV_32FC1) + IPP_FILTER_MEDIAN_BORDER(Ipp32f, ipp32f, 32f_C1R); +#undef IPP_FILTER_MEDIAN_BORDER +#endif + #ifdef HAVE_TEGRA_OPTIMIZATION if (tegra::medianBlur(src0, dst, ksize)) return;