diff --git a/modules/imgproc/src/opencl/pyr_down.cl b/modules/imgproc/src/opencl/pyr_down.cl index 4db1a8d811..b6927fa879 100644 --- a/modules/imgproc/src/opencl/pyr_down.cl +++ b/modules/imgproc/src/opencl/pyr_down.cl @@ -53,16 +53,16 @@ #if defined BORDER_REPLICATE // aaaaaa|abcdefgh|hhhhhhh -#define EXTRAPOLATE(x, maxV) clamp(x, 0, maxV-1) +#define EXTRAPOLATE(x, maxV) clamp((x), 0, (maxV)-1) #elif defined BORDER_WRAP // cdefgh|abcdefgh|abcdefg #define EXTRAPOLATE(x, maxV) ( (x) + (maxV) ) % (maxV) #elif defined BORDER_REFLECT // fedcba|abcdefgh|hgfedcb -#define EXTRAPOLATE(x, maxV) min(((maxV)-1)*2-(x)+1, max((x),-(x)-1) ) +#define EXTRAPOLATE(x, maxV) clamp(min(((maxV)-1)*2-(x)+1, max((x),-(x)-1) ), 0, (maxV)-1) #elif defined BORDER_REFLECT_101 || defined BORDER_REFLECT101 // gfedcb|abcdefgh|gfedcba -#define EXTRAPOLATE(x, maxV) min(((maxV)-1)*2-(x), max((x),-(x)) ) +#define EXTRAPOLATE(x, maxV) clamp(min(((maxV)-1)*2-(x), max((x),-(x)) ), 0, (maxV)-1) #else #error No extrapolation method #endif diff --git a/modules/imgproc/test/ocl/test_pyramids.cpp b/modules/imgproc/test/ocl/test_pyramids.cpp index beff48591e..a129c7f771 100644 --- a/modules/imgproc/test/ocl/test_pyramids.cpp +++ b/modules/imgproc/test/ocl/test_pyramids.cpp @@ -94,8 +94,7 @@ OCL_TEST_P(PyrDown, Mat) { for (int j = 0; j < test_loop_times; j++) { - // minimal src size is set to 4 since size<4 doesn't make sense - Size src_roiSize = randomSize(4, MAX_VALUE); + Size src_roiSize = randomSize(1, MAX_VALUE); Size dst_roiSize = Size(randomInt((src_roiSize.width - 1) / 2, (src_roiSize.width + 3) / 2), randomInt((src_roiSize.height - 1) / 2, (src_roiSize.height + 3) / 2)); dst_roiSize = dst_roiSize.area() == 0 ? Size((src_roiSize.width + 1) / 2, (src_roiSize.height + 1) / 2) : dst_roiSize;