Skip to content

Commit d9e7008

Browse files
authored
Merge pull request #3157 from danopdev:4.x
#1578
1 parent 2c051d5 commit d9e7008

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

modules/xphoto/src/inpainting.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ namespace xphoto
281281
/** Writing result **/
282282
for (size_t i = 0; i < labelSeq.size(); ++i)
283283
{
284+
if (pPath[i].x >= img.cols || pPath[i].y >= img.rows)
285+
continue;
286+
284287
cv::Vec <float, cn> val = pointSeq[i][labelSeq[i]];
285288
img.template at<cv::Vec <float, cn> >(pPath[i]) = val;
286289
}

modules/xphoto/src/photomontage.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ template <typename Tp> void Photomontage <Tp>::
132132
setWeights(GCGraph <TWeight> &graph, const int idx1, const int idx2,
133133
const int l1, const int l2, const int lx)
134134
{
135+
if ((size_t)idx1 >= pointSeq.size() || (size_t)idx2 >= pointSeq.size()
136+
|| (size_t)l1 >= pointSeq[idx1].size() || (size_t)l1 >= pointSeq[idx2].size()
137+
|| (size_t)l2 >= pointSeq[idx1].size() || (size_t)l2 >= pointSeq[idx2].size()
138+
|| (size_t)lx >= pointSeq[idx1].size() || (size_t)lx >= pointSeq[idx2].size())
139+
return;
140+
135141
if (l1 == l2)
136142
{
137143
/** Link from A to B **/

0 commit comments

Comments
 (0)