diff --git a/modules/imgproc/src/opencl/medianFilter.cl b/modules/imgproc/src/opencl/medianFilter.cl index fef80e4b8..6aed88ef7 100644 --- a/modules/imgproc/src/opencl/medianFilter.cl +++ b/modules/imgproc/src/opencl/medianFilter.cl @@ -62,7 +62,7 @@ __kernel void medianFilter3(__global const uchar* srcptr, int srcStep, int srcOf r = clamp(dy+dr+9, 0, rows-1); int index9 = mad24(r, srcStep, srcOffset + c*scnbytes); - + __global DATA_TYPE * src = (__global DATA_TYPE *)(srcptr + index1); data[dr][dc] = src[0]; @@ -83,7 +83,7 @@ __kernel void medianFilter3(__global const uchar* srcptr, int srcStep, int srcOf op(p4, p2); op(p6, p4); op(p4, p2); int dst_index = mad24( gy, dstStep, dstOffset + gx * scnbytes); - + if( gy < rows && gx < cols) { __global DATA_TYPE* dst = (__global DATA_TYPE *)(dstptr + dst_index); diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index fe13bed45..c3991212e 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -1668,7 +1668,7 @@ namespace cv int type = _src.type(); int depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - if (!((depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F) && (cn == 1 || cn == 4))) + if (!((depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F) && (cn != 3 || cn <= 4))) return false; const char * kernelName; @@ -1696,7 +1696,7 @@ namespace cv void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize ) { - CV_Assert( ksize % 2 == 1 ); + CV_Assert( (ksize % 2 == 1) && (_src0.dims() <= 2 )); if( ksize <= 1 ) { diff --git a/modules/imgproc/test/ocl/test_medianfilter.cpp b/modules/imgproc/test/ocl/test_medianfilter.cpp index 51d8d6a0a..011619726 100644 --- a/modules/imgproc/test/ocl/test_medianfilter.cpp +++ b/modules/imgproc/test/ocl/test_medianfilter.cpp @@ -102,7 +102,7 @@ OCL_TEST_P(MedianFilter, Mat) OCL_INSTANTIATE_TEST_CASE_P(ImageProc, MedianFilter, Combine( Values(CV_8U, CV_16U, CV_16S, CV_32F), - Values(1, 4), + Values(1, 2, 4), Values(3, 5), Bool()) );