From e15a2ea95af913ba978a76d13e320d326b10cdc4 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Wed, 10 Nov 2010 21:14:57 +0000 Subject: [PATCH] fixed remap with transparent border (ticket #582) --- modules/core/include/opencv2/core/types_c.h | 1 + modules/imgproc/include/opencv2/imgproc/imgproc.hpp | 7 ++++--- modules/imgproc/src/imgwarp.cpp | 8 ++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index 73bb97c1b5..51e925cc31 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -513,6 +513,7 @@ IplConvKernelFP; /* extra border mode */ #define IPL_BORDER_REFLECT_101 4 +#define IPL_BORDER_TRANSPARENT 5 #define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage)) #define CV_TYPE_NAME_IMAGE "opencv-image" diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp index 0d61a53633..f8d10f2b43 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp @@ -60,9 +60,10 @@ namespace cv //! various border interpolation methods enum { BORDER_REPLICATE=IPL_BORDER_REPLICATE, BORDER_CONSTANT=IPL_BORDER_CONSTANT, - BORDER_REFLECT=IPL_BORDER_REFLECT, BORDER_REFLECT_101=IPL_BORDER_REFLECT_101, - BORDER_REFLECT101=BORDER_REFLECT_101, BORDER_WRAP=IPL_BORDER_WRAP, - BORDER_TRANSPARENT, BORDER_DEFAULT=BORDER_REFLECT_101, BORDER_ISOLATED=16 }; + BORDER_REFLECT=IPL_BORDER_REFLECT, BORDER_WRAP=IPL_BORDER_WRAP, + BORDER_REFLECT_101=IPL_BORDER_REFLECT_101, BORDER_REFLECT101=BORDER_REFLECT_101, + BORDER_TRANSPARENT=IPL_BORDER_TRANSPARENT, + BORDER_DEFAULT=BORDER_REFLECT_101, BORDER_ISOLATED=16 }; //! 1D interpolation function: returns coordinate of the "donor" pixel for the specified location p. CV_EXPORTS_W int borderInterpolate( int p, int len, int borderType ); diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index c263b5ece4..6a688e874d 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -2175,9 +2175,7 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy, else { int x[4], y[4]; - if( borderType == BORDER_TRANSPARENT && - ((unsigned)(sx+1) >= (unsigned)ssize.width || - (unsigned)(sy+1) >= (unsigned)ssize.height) ) + if( borderType == BORDER_TRANSPARENT ) continue; if( borderType == BORDER_CONSTANT && @@ -2277,9 +2275,7 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy, else { int x[8], y[8]; - if( borderType == BORDER_TRANSPARENT && - ((unsigned)(sx+3) >= (unsigned)ssize.width || - (unsigned)(sy+3) >= (unsigned)ssize.height) ) + if( borderType == BORDER_TRANSPARENT ) continue; if( borderType == BORDER_CONSTANT &&