mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #23754 from dkurt:remap_linear_transparent
Keep inliers for linear remap with BORDER_TRANSPARENT #23754 Address https://github.com/opencv/opencv/issues/23562 ### Pull Request Readiness Checklist resolves https://github.com/opencv/opencv/issues/23562 I do think that this is a bug because with `INTER_CUBIC + BORDER_TRANSPARENT` the last column and row are preserved. So same should be done for `INTER_LINEAR` See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -757,13 +757,6 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
|
||||
}
|
||||
else
|
||||
{
|
||||
if( borderType == BORDER_TRANSPARENT && cn != 3 )
|
||||
{
|
||||
D += (X1 - dx)*cn;
|
||||
dx = X1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( cn == 1 )
|
||||
for( ; dx < X1; dx++, D++ )
|
||||
{
|
||||
@@ -774,6 +767,12 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
|
||||
{
|
||||
D[0] = cval[0];
|
||||
}
|
||||
else if (borderType == BORDER_TRANSPARENT)
|
||||
{
|
||||
if (sx < ssize.width && sx >= 0 &&
|
||||
sy < ssize.height && sy >= 0)
|
||||
D[0] = S0[sy*sstep + sx];
|
||||
}
|
||||
else
|
||||
{
|
||||
int sx0, sx1, sy0, sy1;
|
||||
@@ -815,6 +814,13 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
|
||||
for(int k = 0; k < cn; k++ )
|
||||
D[k] = cval[k];
|
||||
}
|
||||
else if (borderType == BORDER_TRANSPARENT)
|
||||
{
|
||||
if (sx < ssize.width && sx >= 0 &&
|
||||
sy < ssize.height && sy >= 0)
|
||||
for(int k = 0; k < cn; k++ )
|
||||
D[k] = S0[sy*sstep + sx*cn + k];
|
||||
}
|
||||
else
|
||||
{
|
||||
int sx0, sx1, sy0, sy1;
|
||||
|
||||
Reference in New Issue
Block a user