diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index f8e8321a90e908843d151fc4157eca471de764f6..ae6b103165192d80b4f9af1d8f8a228911c5ba90 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 ); @@ -6003,6 +6007,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, @@ -6021,7 +6029,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; diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 8d7b1f86ea04b50e99c72fd12eed533a881f7226..8200e56d007feab729ce2e70e8cdb7a08d0739c2 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1703,6 +1703,8 @@ TEST(Imgproc_Warp, multichannel) int width = rng.uniform(3, 333); int height = rng.uniform(3, 333); int cn = rng.uniform(1, 15); + if(inter == INTER_CUBIC || inter == INTER_LANCZOS4) + cn = rng.uniform(1, 5); Mat src(height, width, CV_8UC(cn)), dst; //randu(src, 0, 256); src.setTo(0.);