Skip to content

Commit 057c10b

Browse files
committed
Merge pull request opencv#8377 from ottogin:interpMultichannelImg
2 parents 7bd3ccd + 84a0a91 commit 057c10b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

modules/imgproc/src/imgwarp.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5019,10 +5019,14 @@ void cv::remap( InputArray _src, OutputArray _dst,
50195019
{
50205020
if( interpolation == INTER_LINEAR )
50215021
ifunc = linear_tab[depth];
5022-
else if( interpolation == INTER_CUBIC )
5022+
else if( interpolation == INTER_CUBIC ){
50235023
ifunc = cubic_tab[depth];
5024-
else if( interpolation == INTER_LANCZOS4 )
5024+
CV_Assert( _src.channels() <= 4 );
5025+
}
5026+
else if( interpolation == INTER_LANCZOS4 ){
50255027
ifunc = lanczos4_tab[depth];
5028+
CV_Assert( _src.channels() <= 4 );
5029+
}
50265030
else
50275031
CV_Error( CV_StsBadArg, "Unknown interpolation method" );
50285032
CV_Assert( ifunc != 0 );
@@ -6003,6 +6007,10 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
60036007
{
60046008
CV_INSTRUMENT_REGION()
60056009

6010+
int interpolation = flags & INTER_MAX;
6011+
CV_Assert( _src.channels() <= 4 || (interpolation != INTER_LANCZOS4 &&
6012+
interpolation != INTER_CUBIC) );
6013+
60066014
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat() &&
60076015
_src.cols() <= SHRT_MAX && _src.rows() <= SHRT_MAX,
60086016
ocl_warpTransform_cols4(_src, _dst, _M0, dsize, flags, borderType,
@@ -6021,7 +6029,6 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
60216029

60226030
double M[6];
60236031
Mat matM(2, 3, CV_64F, M);
6024-
int interpolation = flags & INTER_MAX;
60256032
if( interpolation == INTER_AREA )
60266033
interpolation = INTER_LINEAR;
60276034

modules/imgproc/test/test_imgwarp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,8 @@ TEST(Imgproc_Warp, multichannel)
17031703
int width = rng.uniform(3, 333);
17041704
int height = rng.uniform(3, 333);
17051705
int cn = rng.uniform(1, 15);
1706+
if(inter == INTER_CUBIC || inter == INTER_LANCZOS4)
1707+
cn = rng.uniform(1, 5);
17061708
Mat src(height, width, CV_8UC(cn)), dst;
17071709
//randu(src, 0, 256);
17081710
src.setTo(0.);

0 commit comments

Comments
 (0)