Commit f15e885b authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #16950 from alalek:fix_16945

parents 9109cb1e dc9ee53f
...@@ -745,7 +745,9 @@ void DpSeamFinder::computeCosts( ...@@ -745,7 +745,9 @@ void DpSeamFinder::computeCosts(
{ {
for (int x = roi.x; x < roi.br().x+1; ++x) for (int x = roi.x; x < roi.br().x+1; ++x)
{ {
if (labels_(y, x) == l && x > 0 && labels_(y, x-1) == l) if (x > 0 && x < labels_.cols &&
labels_(y, x) == l && labels_(y, x-1) == l
)
{ {
float costColor = (diff(image1, y + dy1, x + dx1 - 1, image2, y + dy2, x + dx2) + float costColor = (diff(image1, y + dy1, x + dx1 - 1, image2, y + dy2, x + dx2) +
diff(image1, y + dy1, x + dx1, image2, y + dy2, x + dx2 - 1)) / 2; diff(image1, y + dy1, x + dx1, image2, y + dy2, x + dx2 - 1)) / 2;
...@@ -769,7 +771,9 @@ void DpSeamFinder::computeCosts( ...@@ -769,7 +771,9 @@ void DpSeamFinder::computeCosts(
{ {
for (int x = roi.x; x < roi.br().x; ++x) for (int x = roi.x; x < roi.br().x; ++x)
{ {
if (labels_(y, x) == l && y > 0 && labels_(y-1, x) == l) if (y > 0 && y < labels_.rows &&
labels_(y, x) == l && labels_(y-1, x) == l
)
{ {
float costColor = (diff(image1, y + dy1 - 1, x + dx1, image2, y + dy2, x + dx2) + float costColor = (diff(image1, y + dy1 - 1, x + dx1, image2, y + dy2, x + dx2) +
diff(image1, y + dy1, x + dx1, image2, y + dy2 - 1, x + dx2)) / 2; diff(image1, y + dy1, x + dx1, image2, y + dy2 - 1, x + dx2)) / 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment