diff --git a/modules/imgproc/src/opencl/covardata.cl b/modules/imgproc/src/opencl/covardata.cl index 8aee637da9..f663e525eb 100644 --- a/modules/imgproc/src/opencl/covardata.cl +++ b/modules/imgproc/src/opencl/covardata.cl @@ -16,7 +16,7 @@ //aaaaaa|abcdefgh|hhhhhhh #define EXTRAPOLATE(x, maxV) \ { \ - (x) = max(min((x), (maxV) - 1), 0); \ + (x) = clamp((x), 0, (maxV)-1); \ } #elif defined BORDER_WRAP //cdefgh|abcdefgh|abcdefg @@ -28,13 +28,13 @@ //fedcba|abcdefgh|hgfedcb #define EXTRAPOLATE(x, maxV) \ { \ - (x) = min( mad24((maxV)-1,2,-(x))+1 , max((x),-(x)-1) ); \ + (x) = clamp(min( mad24((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) \ { \ - (x) = min( mad24((maxV)-1,2,-(x)), max((x),-(x)) ); \ + (x) = clamp(min( mad24((maxV)-1,2,-(x)), max((x),-(x)) ), 0, (maxV)-1); \ } #else #error No extrapolation method diff --git a/modules/imgproc/src/opencl/filterSep_singlePass.cl b/modules/imgproc/src/opencl/filterSep_singlePass.cl index 8c14f2d77e..2fbb0ece45 100644 --- a/modules/imgproc/src/opencl/filterSep_singlePass.cl +++ b/modules/imgproc/src/opencl/filterSep_singlePass.cl @@ -50,7 +50,7 @@ // aaaaaa|abcdefgh|hhhhhhh #define EXTRAPOLATE(x, maxV) \ { \ - (x) = max(min((x), (maxV) - 1), 0); \ + (x) = clamp((x), 0, (maxV)-1); \ } #elif defined BORDER_WRAP // cdefgh|abcdefgh|abcdefg @@ -62,13 +62,13 @@ // fedcba|abcdefgh|hgfedcb #define EXTRAPOLATE(x, maxV) \ { \ - (x) = min(((maxV)-1)*2-(x)+1, max((x),-(x)-1) ); \ + (x) = 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) \ { \ - (x) = min(((maxV)-1)*2-(x), max((x),-(x)) ); \ + (x) = clamp(min(((maxV)-1)*2-(x), max((x),-(x)) ), 0, (maxV)-1); \ } #else #error No extrapolation method diff --git a/modules/imgproc/src/opencl/laplacian5.cl b/modules/imgproc/src/opencl/laplacian5.cl index ed6a0d4263..11c318f918 100644 --- a/modules/imgproc/src/opencl/laplacian5.cl +++ b/modules/imgproc/src/opencl/laplacian5.cl @@ -49,7 +49,7 @@ __kernel void sumConvert(__global const uchar * src1ptr, int src1_step, int src1 // aaaaaa|abcdefgh|hhhhhhh #define EXTRAPOLATE(x, maxV) \ { \ - (x) = max(min((x), (maxV) - 1), 0); \ + (x) = clamp((x), 0, (maxV)-1); \ } #elif defined BORDER_WRAP // cdefgh|abcdefgh|abcdefg @@ -61,13 +61,13 @@ __kernel void sumConvert(__global const uchar * src1ptr, int src1_step, int src1 // fedcba|abcdefgh|hgfedcb #define EXTRAPOLATE(x, maxV) \ { \ - (x) = min(((maxV)-1)*2-(x)+1, max((x),-(x)-1) ); \ + (x) = clamp(min(((maxV)-1)*2-(x)+1, max((x),-(x)-1) ), 0, (maxV)-1); \ } #elif defined BORDER_REFLECT_101 // gfedcb|abcdefgh|gfedcba #define EXTRAPOLATE(x, maxV) \ { \ - (x) = min(((maxV)-1)*2-(x), max((x),-(x)) ); \ + (x) = clamp(min(((maxV)-1)*2-(x), max((x),-(x)) ), 0, (maxV)-1); \ } #else #error No extrapolation method