diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 7bcf16a394..6c4da5b5f3 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -5019,10 +5019,14 @@ void cv::remap( InputArray _src, OutputArray _dst, { if( interpolation == INTER_LINEAR ) ifunc = linear_tab[depth]; - else if( interpolation == INTER_CUBIC ) + else if( interpolation == INTER_CUBIC ){ ifunc = cubic_tab[depth]; - else if( interpolation == INTER_LANCZOS4 ) + CV_Assert( _src.channels() <= 4 ); + } + else if( interpolation == INTER_LANCZOS4 ){ ifunc = lanczos4_tab[depth]; + CV_Assert( _src.channels() <= 4 ); + } else CV_Error( CV_StsBadArg, "Unknown interpolation method" ); CV_Assert( ifunc != 0 ); @@ -5962,6 +5966,10 @@ void cv::warpAffine( InputArray _src, OutputArray _dst, { CV_INSTRUMENT_REGION() + int interpolation = flags & INTER_MAX; + CV_Assert( _src.channels() <= 4 || (interpolation != INTER_LANCZOS4 && + interpolation != INTER_CUBIC) ); + CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat() && _src.cols() <= SHRT_MAX && _src.rows() <= SHRT_MAX, ocl_warpTransform_cols4(_src, _dst, _M0, dsize, flags, borderType, @@ -5980,7 +5988,6 @@ void cv::warpAffine( InputArray _src, OutputArray _dst, double M[6]; Mat matM(2, 3, CV_64F, M); - int interpolation = flags & INTER_MAX; if( interpolation == INTER_AREA ) interpolation = INTER_LINEAR;