Skip to content

Commit c4ae5c0

Browse files
committed
Added assertios to remap and warpAffine functions
Remap and warpAffine functions do not support more than 4 channels in Bicubic and Lanczos4 interpolation modes. Assertions were added. resolve opencv#8272
1 parent 6f39f9a commit c4ae5c0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-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 );
@@ -5962,6 +5966,10 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
59625966
{
59635967
CV_INSTRUMENT_REGION()
59645968

5969+
int interpolation = flags & INTER_MAX;
5970+
CV_Assert( _src.channels() <= 4 || (interpolation != INTER_LANCZOS4 &&
5971+
interpolation != INTER_CUBIC) );
5972+
59655973
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat() &&
59665974
_src.cols() <= SHRT_MAX && _src.rows() <= SHRT_MAX,
59675975
ocl_warpTransform_cols4(_src, _dst, _M0, dsize, flags, borderType,
@@ -5980,7 +5988,6 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
59805988

59815989
double M[6];
59825990
Mat matM(2, 3, CV_64F, M);
5983-
int interpolation = flags & INTER_MAX;
59845991
if( interpolation == INTER_AREA )
59855992
interpolation = INTER_LINEAR;
59865993

0 commit comments

Comments
 (0)