Skip to content

Commit

Permalink
STYLE: Use std::clamp in itkZeroFluxNeumannPadImageFilterTest
Browse files Browse the repository at this point in the history
Aims to improve code readability.
  • Loading branch information
N-Dekker committed Feb 22, 2024
1 parent 032c779 commit 32c470a
Showing 1 changed file with 3 additions and 8 deletions.
Expand Up @@ -21,6 +21,7 @@
#include "itkZeroFluxNeumannPadImageFilter.h"
#include "itkStreamingImageFilter.h"
#include "itkTestingMacros.h"
#include <algorithm> // For clamp.

using ShortImage = itk::Image<short, 2>;
using FloatImage = itk::Image<float, 2>;
Expand Down Expand Up @@ -57,14 +58,8 @@ VerifyFilterOutput(const ShortImage * inputImage, const FloatImage * outputImage
ShortImage::IndexType borderIdx = idx;
for (unsigned int i = 0; i < ShortImage::ImageDimension; ++i)
{
if (borderIdx[i] < inputIndex[i])
{
borderIdx[i] = inputIndex[i];
}
else if (borderIdx[i] > inputIndex[i] + static_cast<ShortImage::IndexValueType>(inputSize[i]) - 1)
{
borderIdx[i] = inputIndex[i] + inputSize[i] - 1;
}
borderIdx[i] = std::clamp(
borderIdx[i], inputIndex[i], inputIndex[i] + static_cast<ShortImage::IndexValueType>(inputSize[i]) - 1);
}

if (itk::Math::NotAlmostEquals(outputIterator.Get(), inputImage->GetPixel(borderIdx)))
Expand Down

0 comments on commit 32c470a

Please sign in to comment.