Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void cv::remap( InputArray _src, OutputArray _dst,
- InputArray _map1, InputArray _map2,
- int interpolation, int borderType, const Scalar& borderValue )
- {
- static RemapNNFunc nn_tab[] =
- {
- remapNearest<uchar>, remapNearest<schar>, remapNearest<ushort>, remapNearest<short>,
- remapNearest<int>, remapNearest<float>, remapNearest<double>, 0
- };
- static RemapFunc linear_tab[] =
- {
- remapBilinear<FixedPtCast<int, uchar, INTER_REMAP_COEF_BITS>, RemapVec_8u, short>, 0,
- remapBilinear<Cast<float, ushort>, RemapNoVec, float>,
- remapBilinear<Cast<float, short>, RemapNoVec, float>, 0,
- remapBilinear<Cast<float, float>, RemapNoVec, float>,
- remapBilinear<Cast<double, double>, RemapNoVec, float>, 0
- };
- static RemapFunc cubic_tab[] =
- {
- remapBicubic<FixedPtCast<int, uchar, INTER_REMAP_COEF_BITS>, short, INTER_REMAP_COEF_SCALE>, 0,
- remapBicubic<Cast<float, ushort>, float, 1>,
- remapBicubic<Cast<float, short>, float, 1>, 0,
- remapBicubic<Cast<float, float>, float, 1>,
- remapBicubic<Cast<double, double>, float, 1>, 0
- };
- static RemapFunc lanczos4_tab[] =
- {
- remapLanczos4<FixedPtCast<int, uchar, INTER_REMAP_COEF_BITS>, short, INTER_REMAP_COEF_SCALE>, 0,
- remapLanczos4<Cast<float, ushort>, float, 1>,
- remapLanczos4<Cast<float, short>, float, 1>, 0,
- remapLanczos4<Cast<float, float>, float, 1>,
- remapLanczos4<Cast<double, double>, float, 1>, 0
- };
- Mat src = _src.getMat(), map1 = _map1.getMat(), map2 = _map2.getMat();
- CV_Assert( map1.size().area() > 0 );
- CV_Assert( !map2.data || (map2.size() == map1.size()));
- _dst.create( map1.size(), src.type() );
- Mat dst = _dst.getMat();
- if( dst.data == src.data )
- src = src.clone();
- int depth = src.depth();
- RemapNNFunc nnfunc = 0;
- RemapFunc ifunc = 0;
- const void* ctab = 0;
- bool fixpt = depth == CV_8U;
- bool planar_input = false;
- if( interpolation == INTER_NEAREST )
- {
- nnfunc = nn_tab[depth];
- CV_Assert( nnfunc != 0 );
- }
- else
- {
- if( interpolation == INTER_AREA )
- interpolation = INTER_LINEAR;
- if( interpolation == INTER_LINEAR )
- ifunc = linear_tab[depth];
- else if( interpolation == INTER_CUBIC )
- ifunc = cubic_tab[depth];
- else if( interpolation == INTER_LANCZOS4 )
- ifunc = lanczos4_tab[depth];
- else
- CV_Error( CV_StsBadArg, "Unknown interpolation method" );
- CV_Assert( ifunc != 0 );
- ctab = initInterTab2D( interpolation, fixpt );
- }
- const Mat *m1 = &map1, *m2 = &map2;
- if( (map1.type() == CV_16SC2 && (map2.type() == CV_16UC1 || map2.type() == CV_16SC1 || !map2.data)) ||
- (map2.type() == CV_16SC2 && (map1.type() == CV_16UC1 || map1.type() == CV_16SC1 || !map1.data)) )
- {
- if( map1.type() != CV_16SC2 )
- std::swap(m1, m2);
- }
- else
- {
- CV_Assert( ((map1.type() == CV_32FC2 || map1.type() == CV_16SC2) && !map2.data) ||
- (map1.type() == CV_32FC1 && map2.type() == CV_32FC1) );
- planar_input = map1.channels() == 1;
- }
- RemapInvoker invoker(src, dst, m1, m2,
- borderType, borderValue, planar_input, nnfunc, ifunc,
- ctab);
- parallel_for_(Range(0, dst.rows), invoker, dst.total()/(double)(1<<16));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement