Skip to content

Commit 3a98ce6

Browse files
authored
Merge pull request #1926 from ANTsX/fix_tile_bounds
BUG: Another mask padding bug
2 parents dfadbfe + 37dcb3e commit 3a98ce6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Examples/CreateTiledMosaic.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,8 @@ CreateMosaic(itk::ants::CommandLineParser * parser)
337337
{
338338
if (d != direction)
339339
{
340-
croppedSliceSize[count] = std::min(
341-
size[d] - (itk::Math::abs(lowerBoundVector[count]) + itk::Math::abs(upperBoundVector[count])),
342-
size[d]);
340+
croppedSliceSize[count] =
341+
size[d] - (itk::Math::abs(lowerBoundVector[count]) + itk::Math::abs(upperBoundVector[count]));
343342

344343
croppedSliceIndex[count] = itk::Math::abs(lowerBoundVector[count]);
345344
count++;
@@ -390,6 +389,7 @@ CreateMosaic(itk::ants::CommandLineParser * parser)
390389
{
391390
std::string offsetString = padWidthString.substr(padWidthString.find(std::string("-")) + 1);
392391
offset = parser->Convert<int>(offsetString);
392+
// make offset negative because the minus sign in the string is the delimiter
393393
offset *= -1;
394394
}
395395

@@ -400,7 +400,7 @@ CreateMosaic(itk::ants::CommandLineParser * parser)
400400
if (d != direction)
401401
{
402402
croppedSliceSize[count] = std::min(maskRegion.GetSize()[d] + 2 * offset, size[d]);
403-
croppedSliceIndex[count] = maskRegion.GetIndex()[d] - offset;
403+
croppedSliceIndex[count] = std::max(0, static_cast<int>(maskRegion.GetIndex()[d] - offset));
404404
count++;
405405
}
406406
}

0 commit comments

Comments
 (0)