pyramidBorderType.patch

The patch - Leszek Swirski, 2011-04-19 06:31 pm

Download (4.8 kB)

 
opencv/modules/imgproc/include/opencv2/imgproc/imgproc.hpp (working copy)
605 605

  
606 606
//! smooths and downsamples the image
607 607
CV_EXPORTS_W void pyrDown( const InputArray& src, OutputArray dst,
608
                           const Size& dstsize=Size());
608
                           const Size& dstsize=Size(), int borderType=BORDER_DEFAULT);
609 609
//! upsamples and smoothes the image
610 610
CV_EXPORTS_W void pyrUp( const InputArray& src, OutputArray dst,
611
                         const Size& dstsize=Size());
611
                         const Size& dstsize=Size(), int borderType=BORDER_DEFAULT);
612 612

  
613 613
//! builds the gaussian pyramid using pyrDown() as a basic operation
614
CV_EXPORTS void buildPyramid( const InputArray& src, OutputArrayOfArrays dst, int maxlevel );
614
CV_EXPORTS void buildPyramid( const InputArray& src, OutputArrayOfArrays dst,
615
                              int maxlevel, int borderType=BORDER_DEFAULT );
615 616

  
616 617
//! corrects lens distortion for the given camera matrix and distortion coefficients
617 618
CV_EXPORTS_W void undistort( const InputArray& src, OutputArray dst,
opencv/modules/imgproc/src/pyramids.cpp (working copy)
185 185
#endif
186 186

  
187 187
template<class CastOp, class VecOp> void
188
pyrDown_( const Mat& _src, Mat& _dst )
188
pyrDown_( const Mat& _src, Mat& _dst, int borderType )
189 189
{
190 190
    const int PD_SZ = 5;
191 191
    typedef typename CastOp::type1 WT;
......
209 209

  
210 210
    for( x = 0; x <= PD_SZ+1; x++ )
211 211
    {
212
        int sx0 = borderInterpolate(x - PD_SZ/2, ssize.width, BORDER_REFLECT_101)*cn;
213
        int sx1 = borderInterpolate(x + width0*2 - PD_SZ/2, ssize.width, BORDER_REFLECT_101)*cn;
212
        int sx0 = borderInterpolate(x - PD_SZ/2, ssize.width, borderType)*cn;
213
        int sx1 = borderInterpolate(x + width0*2 - PD_SZ/2, ssize.width, borderType)*cn;
214 214
        for( k = 0; k < cn; k++ )
215 215
        {
216 216
            tabL[x*cn + k] = sx0 + k;
......
234 234
        for( ; sy <= y*2 + 2; sy++ )
235 235
        {
236 236
            WT* row = buf + ((sy - sy0) % PD_SZ)*bufstep;
237
            int _sy = borderInterpolate(sy, ssize.height, BORDER_REFLECT_101);
237
            int _sy = borderInterpolate(sy, ssize.height, borderType);
238 238
            const T* src = (const T*)(_src.data + _src.step*_sy);
239 239
            int limit = cn;
240 240
            const int* tab = tabL;
......
308 308

  
309 309

  
310 310
template<class CastOp, class VecOp> void
311
pyrUp_( const Mat& _src, Mat& _dst )
311
pyrUp_( const Mat& _src, Mat& _dst, int borderType )
312 312
{
313 313
    const int PU_SZ = 3;
314 314
    typedef typename CastOp::type1 WT;
......
349 349
        for( ; sy <= y + 1; sy++ )
350 350
        {
351 351
            WT* row = buf + ((sy - sy0) % PU_SZ)*bufstep;
352
            int _sy = borderInterpolate(sy, ssize.height, BORDER_REFLECT_101);
352
            int _sy = borderInterpolate(sy, ssize.height, borderType);
353 353
            const T* src = (const T*)(_src.data + _src.step*_sy);
354 354

  
355 355
            if( ssize.width == cn )
......
397 397
    }
398 398
}
399 399

  
400
typedef void (*PyrFunc)(const Mat&, Mat&);
400
typedef void (*PyrFunc)(const Mat&, Mat&, int);
401 401

  
402 402
}
403 403
    
404
void cv::pyrDown( const InputArray& _src, OutputArray _dst, const Size& _dsz )
404
void cv::pyrDown( const InputArray& _src, OutputArray _dst,
405
                  const Size& _dsz, int borderType )
405 406
{
406 407
    Mat src = _src.getMat();
407 408
    Size dsz = _dsz == Size() ? Size((src.cols + 1)/2, (src.rows + 1)/2) : _dsz;
......
420 421
    else
421 422
        CV_Error( CV_StsUnsupportedFormat, "" );
422 423

  
423
    func( src, dst );
424
    func( src, dst, borderType );
424 425
}
425 426

  
426
void cv::pyrUp( const InputArray& _src, OutputArray _dst, const Size& _dsz )
427
void cv::pyrUp( const InputArray& _src, OutputArray _dst,
428
                const Size& _dsz, int borderType )
427 429
{
428 430
    Mat src = _src.getMat();
429 431
    Size dsz = _dsz == Size() ? Size(src.cols*2, src.rows*2) : _dsz;
......
442 444
    else
443 445
        CV_Error( CV_StsUnsupportedFormat, "" );
444 446

  
445
    func( src, dst );
447
    func( src, dst, borderType );
446 448
}
447 449

  
448
void cv::buildPyramid( const InputArray& _src, OutputArrayOfArrays _dst, int maxlevel )
450
void cv::buildPyramid( const InputArray& _src, OutputArrayOfArrays _dst,
451
                       int maxlevel, int borderType )
449 452
{
450 453
    Mat src = _src.getMat();
451 454
    _dst.create( maxlevel + 1, 1, 0 );
452 455
    _dst.getMatRef(0) = src;
453 456
    for( int i = 1; i <= maxlevel; i++ )
454
        pyrDown( _dst.getMatRef(i-1), _dst.getMatRef(i) );
457
        pyrDown( _dst.getMatRef(i-1), _dst.getMatRef(i), Size(), borderType );
455 458
}
456 459

  
457 460
CV_IMPL void cvPyrDown( const void* srcarr, void* dstarr, int _filter )