1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge pull request #25402 from Linaname:4.x

Handle top and left border masked pixels correctly in inpaint method #25402

Fixes #25389

### Pull Request Readiness Checklist

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
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Linaname
2024-04-17 13:26:56 +05:00
committed by GitHub
parent f9dd20eb07
commit 37ca0308a7
2 changed files with 30 additions and 4 deletions
+26
View File
@@ -157,4 +157,30 @@ TEST(Photo_InpaintBorders, regression)
ASSERT_TRUE(countNonZero(diff) == 0);
}
typedef testing::TestWithParam<tuple<perf::MatType>> Photo_InpaintSmallBorders;
TEST_P(Photo_InpaintSmallBorders, regression)
{
int type = get<0>(GetParam());
Mat img(5, 5, type, Scalar::all(128));
Mat expected = img.clone();
Mat mask = Mat::zeros(5, 5, CV_8U);
mask(Rect(1, 1, 3, 3)) = 255;
img.setTo(Scalar::all(0), mask);
Mat inpainted, diff;
inpaint(img, mask, inpainted, 1, INPAINT_TELEA);
cv::absdiff(inpainted, expected, diff);
ASSERT_EQ(countNonZero(diff.reshape(1)), 0);
inpaint(img, mask, inpainted, 1, INPAINT_NS);
cv::absdiff(inpainted, expected, diff);
ASSERT_EQ(countNonZero(diff.reshape(1)), 0);
}
INSTANTIATE_TEST_CASE_P(/*nothing*/, Photo_InpaintSmallBorders, Values(CV_8UC1, CV_8UC3));
}} // namespace