Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/photo/src/inpaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ icvTeleaInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQu
gradI.y=0;
}
}
Ia[color] += (float)w * (float)(CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color));
Ia[color] += (float)w * (float)(CV_MAT_3COLOR_ELEM(*out,uchar,k-1,l-1,color));
Jx[color] -= (float)w * (float)(gradI.x*r.x);
Jy[color] -= (float)w * (float)(gradI.y*r.y);
s[color] += w;
Expand Down Expand Up @@ -441,7 +441,7 @@ icvTeleaInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQu
gradI.y=0;
}
}
Ia += (float)w * (float)(CV_MAT_ELEM(*out,data_type,km,lm));
Ia += (float)w * (float)(CV_MAT_ELEM(*out,data_type,k-1,l-1));
Jx -= (float)w * (float)(gradI.x*r.x);
Jy -= (float)w * (float)(gradI.y*r.y);
s += w;
Expand Down Expand Up @@ -544,7 +544,7 @@ icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueue
dir = (float)fabs(VectorScalMult(r,gradI)/sqrt(VectorLength(r)*VectorLength(gradI)));
}
w = dst*dir;
Ia[color] += (float)w * (float)(CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color));
Ia[color] += (float)w * (float)(CV_MAT_3COLOR_ELEM(*out,uchar,k-1,l-1,color));
s[color] += w;
}
}
Expand Down Expand Up @@ -634,7 +634,7 @@ icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueue
dir = (float)fabs(VectorScalMult(r,gradI)/sqrt(VectorLength(r)*VectorLength(gradI)));
}
w = dst*dir;
Ia += (float)w * (float)(CV_MAT_ELEM(*out,data_type,km,lm));
Ia += (float)w * (float)(CV_MAT_ELEM(*out,data_type,k-1,l-1));
s += w;
}
}
Expand Down
26 changes: 26 additions & 0 deletions modules/photo/test/test_inpaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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