提交 dc9ee53f 编写于 作者: A Alexander Alekhin

stitching: fix range check in DpSeamFinder::computeCosts

上级 396f43d6
......@@ -745,7 +745,9 @@ void DpSeamFinder::computeCosts(
{
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) +
diff(image1, y + dy1, x + dx1, image2, y + dy2, x + dx2 - 1)) / 2;
......@@ -769,7 +771,9 @@ void DpSeamFinder::computeCosts(
{
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) +
diff(image1, y + dy1, x + dx1, image2, y + dy2 - 1, x + dx2)) / 2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册