Skip to content

Commit 01ac9f2

Browse files
committed
STYLE: Prefer itk::Math::Absolute over legacy itk::Math::abs alias
itk::Math::abs is a backward-compatibility forwarder to Absolute, removed under ITK_FUTURE_LEGACY_REMOVE. Calling Absolute directly is future-proof and unambiguous; behavior is identical.
1 parent 27004b3 commit 01ac9f2

25 files changed

Lines changed: 69 additions & 65 deletions

Modules/Filtering/BoneEnhancement/include/itkDescoteauxEigenToMeasureImageFilter.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ DescoteauxEigenToMeasureImageFilter<TInputImage, TOutputImage>::ProcessPixel(con
5555
auto a1 = static_cast<double>(pixel[0]);
5656
auto a2 = static_cast<double>(pixel[1]);
5757
auto a3 = static_cast<double>(pixel[2]);
58-
double l1 = itk::Math::abs(a1);
59-
double l2 = itk::Math::abs(a2);
60-
double l3 = itk::Math::abs(a3);
58+
double l1 = itk::Math::Absolute(a1);
59+
double l2 = itk::Math::Absolute(a2);
60+
double l3 = itk::Math::Absolute(a3);
6161

6262
/* Deal with l3 > 0 */
6363
if (m_EnhanceType * a3 < 0)
@@ -73,7 +73,7 @@ DescoteauxEigenToMeasureImageFilter<TInputImage, TOutputImage>::ProcessPixel(con
7373

7474
/* Compute measures */
7575
const double Rsheet = l2 / l3;
76-
const double Rblob = itk::Math::abs(2 * l3 - l2 - l1) / l3;
76+
const double Rblob = itk::Math::Absolute(2 * l3 - l2 - l1) / l3;
7777
const double Rnoise = sqrt(l1 * l1 + l2 * l2 + l3 * l3);
7878

7979
/* Multiply together to get sheetness */

Modules/Filtering/BoneEnhancement/include/itkKrcahEigenToMeasureImageFilter.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ KrcahEigenToMeasureImageFilter<TInputImage, TOutputImage>::ProcessPixel(const In
5656
auto a1 = static_cast<double>(pixel[0]);
5757
auto a2 = static_cast<double>(pixel[1]);
5858
auto a3 = static_cast<double>(pixel[2]);
59-
double l1 = itk::Math::abs(a1);
60-
double l2 = itk::Math::abs(a2);
61-
double l3 = itk::Math::abs(a3);
59+
double l1 = itk::Math::Absolute(a1);
60+
double l2 = itk::Math::Absolute(a2);
61+
double l3 = itk::Math::Absolute(a3);
6262

6363
/* Avoid divisions by zero (or close to zero) */
6464
if (static_cast<double>(l3) < Math::eps || static_cast<double>(l2) < Math::eps)

Modules/Filtering/BoneEnhancement/include/itkKrcahEigenToMeasureParameterEstimationFilter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ KrcahEigenToMeasureParameterEstimationFilter<TInputImage, TOutputImage>::Calcula
181181
RealType trace = 0;
182182
for (unsigned int i = 0; i < pixel.Length; ++i)
183183
{
184-
trace += itk::Math::abs(pixel[i]);
184+
trace += itk::Math::Absolute(pixel[i]);
185185
}
186186
return trace;
187187
}

Modules/Filtering/BoneEnhancement/include/itkMaximumAbsoluteValueImageFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class MaximumAbsoluteValue
6262
inline TOutputPixel
6363
operator()(const TInputPixel1 A, const TInputPixel2 B)
6464
{
65-
return static_cast<TOutputPixel>(itk::Math::abs(A) > itk::Math::abs(B) ? A : B);
65+
return static_cast<TOutputPixel>(itk::Math::Absolute(A) > itk::Math::Absolute(B) ? A : B);
6666
}
6767
}; // end of class
6868
} // namespace Functor

Modules/Filtering/BoneMorphometry/include/itkBoneMorphometryFeaturesImageFilter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ BoneMorphometryFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>::IsIns
208208
bool insideNeighborhood = true;
209209
for (unsigned int i = 0; i < this->m_NeighborhoodRadius.Dimension; ++i)
210210
{
211-
int boundDistance = m_NeighborhoodRadius[i] - itk::Math::abs(iteratedOffset[i]);
211+
int boundDistance = m_NeighborhoodRadius[i] - itk::Math::Absolute(iteratedOffset[i]);
212212
if (boundDistance < 0)
213213
{
214214
insideNeighborhood = false;

Modules/Filtering/Cuberille/include/itkCuberilleImageToMeshFilter.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ CuberilleImageToMeshFilter<TInputImage, TOutputMesh, TInterpolator>::ProjectVert
476476
// Compute which direction moves vertex closer to iso-surface value
477477
value[0] = m_Interpolator->Evaluate(temp[0]);
478478
value[1] = m_Interpolator->Evaluate(temp[1]);
479-
diff[0] = itk::Math::abs(value[0] - m_IsoSurfaceValue);
480-
diff[1] = itk::Math::abs(value[1] - m_IsoSurfaceValue);
479+
diff[0] = itk::Math::Absolute(value[0] - m_IsoSurfaceValue);
480+
diff[1] = itk::Math::Absolute(value[1] - m_IsoSurfaceValue);
481481
i = (diff[0] <= diff[1]) ? 0 : 1;
482482
if (previousi < 0)
483483
{
@@ -537,7 +537,7 @@ CuberilleImageToMeshFilter<TInputImage, TOutputMesh, TInterpolator>::ProjectVert
537537
}
538538
// Compute metric (combination of difference and distance)
539539
value = m_Interpolator->Evaluate(temp);
540-
metric = itk::Math::abs(value - m_IsoSurfaceValue); // Difference
540+
metric = itk::Math::Absolute(value - m_IsoSurfaceValue); // Difference
541541

542542
// Determine if current position is the "best"
543543
if (metric < bestMetric)
@@ -570,7 +570,7 @@ CuberilleImageToMeshFilter<TInputImage, TOutputMesh, TInterpolator>::ProjectVert
570570

571571
// Compute whether vertex is close enough to iso-surface value
572572
value = m_Interpolator->Evaluate(vertex);
573-
done |= itk::Math::abs(value - m_IsoSurfaceValue) < m_ProjectVertexSurfaceDistanceThreshold;
573+
done |= itk::Math::Absolute(value - m_IsoSurfaceValue) < m_ProjectVertexSurfaceDistanceThreshold;
574574
if (done)
575575
{
576576
break;

Modules/Filtering/MinimalPathExtraction/include/itkSingleImageCostFunction.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ SingleImageCostFunction<TImage>::GetDerivative(const ParametersType & parameters
136136
// (indicated by very large values) which may skew the gradient.
137137
// To avoid this skewing effect, we reset gradient values larger
138138
// than a given threshold.
139-
if (itk::Math::abs(derivative[i]) > m_DerivativeThreshold)
139+
if (itk::Math::Absolute(derivative[i]) > m_DerivativeThreshold)
140140
{
141141
derivative[i] = 0.0;
142142
}

Modules/Filtering/MorphologicalContourInterpolation/include/itkMorphologicalContourInterpolator.hxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ MorphologicalContourInterpolator<TImage>::FindMedianImageDilations(typename Bool
371371
{
372372
IdentifierType iS = CardinalSymmetricDifference(seq[x], iMask);
373373
IdentifierType jS = CardinalSymmetricDifference(seq[x], jMask);
374-
IdentifierType xScore = iS >= jS ? iS - jS : jS - iS; // itk::Math::abs(iS-jS)
374+
IdentifierType xScore = iS >= jS ? iS - jS : jS - iS; // itk::Math::Absolute(iS-jS)
375375
if (xScore < min)
376376
{
377377
min = xScore;
@@ -477,9 +477,9 @@ MorphologicalContourInterpolator<TImage>::FindMedianImageDistances(typename Bool
477477
long long bestDiff = LLONG_MAX;
478478
for (unsigned b = 0; b < maxSize; b++)
479479
{
480-
long long iS = itk::Math::abs(iTotal - iSum[b] + jSum[b]);
481-
long long jS = itk::Math::abs(jTotal - jSum[b] + iSum[b]);
482-
long long diff = itk::Math::abs(iS - jS);
480+
long long iS = itk::Math::Absolute(iTotal - iSum[b] + jSum[b]);
481+
long long jS = itk::Math::Absolute(jTotal - jSum[b] + iSum[b]);
482+
long long diff = itk::Math::Absolute(iS - jS);
483483
if (diff < bestDiff)
484484
{
485485
bestDiff = diff;
@@ -758,7 +758,7 @@ MorphologicalContourInterpolator<TImage>::Interpolate1to1(int
758758
} // iterator destroyed here
759759

760760
// recurse if needed
761-
if (itk::Math::abs(i - j) > 2)
761+
if (itk::Math::Absolute(i - j) > 2)
762762
{
763763
PixelList regionIDs;
764764
regionIDs.push_back(1);
@@ -772,8 +772,8 @@ MorphologicalContourInterpolator<TImage>::Interpolate1to1(int
772772
int mReq = mid < reqRegion.GetIndex(axis)
773773
? -1
774774
: (mid > reqRegion.GetIndex(axis) + IndexValueType(reqRegion.GetSize(axis)) ? +1 : 0);
775-
bool first = itk::Math::abs(i - mid) > 1 && itk::Math::abs(iReq + mReq) <= 1; // i-mid?
776-
bool second = itk::Math::abs(j - mid) > 1 && itk::Math::abs(jReq + mReq) <= 1; // j-mid?
775+
bool first = itk::Math::Absolute(i - mid) > 1 && itk::Math::Absolute(iReq + mReq) <= 1; // i-mid?
776+
bool second = itk::Math::Absolute(j - mid) > 1 && itk::Math::Absolute(jReq + mReq) <= 1; // j-mid?
777777

778778
if (first)
779779
{
@@ -1493,9 +1493,9 @@ MorphologicalContourInterpolator<TImage>::InterpolateAlong(int axis,
14931493
? -1
14941494
: (*next > reqRegion.GetIndex(axis) + IndexValueType(reqRegion.GetSize(axis)) ? +1 : 0);
14951495

1496-
if (*prev + 1 < *next // only if they are not adjacent slices
1497-
&& itk::Math::abs(iReq + jReq) <= 1) // and not out of the requested region
1498-
// unless they are on opposite ends
1496+
if (*prev + 1 < *next // only if they are not adjacent slices
1497+
&& itk::Math::Absolute(iReq + jReq) <= 1) // and not out of the requested region
1498+
// unless they are on opposite ends
14991499
{
15001500
SegmentBetweenTwo<TImage> s;
15011501
s.axis = axis;

Modules/Filtering/PolarTransform/test/itkPolarTransformTest.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ itkPolarTransformTest(int, char *[])
5959
tmp = p2c->TransformPoint(p);
6060
for (unsigned int i = 0; i < Dimension; ++i)
6161
{
62-
if (itk::Math::abs(tmp[i] - c[i]) > epsilon)
62+
if (itk::Math::Absolute(tmp[i] - c[i]) > epsilon)
6363
{
6464
return EXIT_FAILURE;
6565
}
@@ -69,7 +69,7 @@ itkPolarTransformTest(int, char *[])
6969
tmp = c2p->TransformPoint(c);
7070
for (unsigned int i = 0; i < Dimension; ++i)
7171
{
72-
if (itk::Math::abs(tmp[i] - p[i]) > epsilon)
72+
if (itk::Math::Absolute(tmp[i] - p[i]) > epsilon)
7373
{
7474
std::cout << "Invalid cartesian to polar computed." << std::endl;
7575
return EXIT_FAILURE;
@@ -80,7 +80,7 @@ itkPolarTransformTest(int, char *[])
8080
tmp = c2p->TransformPoint(p2c->TransformPoint(p));
8181
for (unsigned int i = 0; i < Dimension; ++i)
8282
{
83-
if (itk::Math::abs(tmp[i] - p[i]) > epsilon)
83+
if (itk::Math::Absolute(tmp[i] - p[i]) > epsilon)
8484
{
8585
std::cout << "Invalid polar to cartesian and back computed." << std::endl;
8686
return EXIT_FAILURE;
@@ -91,7 +91,7 @@ itkPolarTransformTest(int, char *[])
9191
tmp = p2c->TransformPoint(c2p->TransformPoint(c));
9292
for (unsigned int i = 0; i < Dimension; ++i)
9393
{
94-
if (itk::Math::abs(tmp[i] - c[i]) > epsilon)
94+
if (itk::Math::Absolute(tmp[i] - c[i]) > epsilon)
9595
{
9696
std::cout << "Invalid cartesian to polar and back computed." << std::endl;
9797
return EXIT_FAILURE;
@@ -147,7 +147,7 @@ itkPolarTransformTest(int, char *[])
147147
tmp = p2cOff->TransformPoint(c2pOff->TransformPoint(c));
148148
for (unsigned int i = 0; i < Dimension; ++i)
149149
{
150-
if (itk::Math::abs(tmp[i] - c[i]) > epsilon)
150+
if (itk::Math::Absolute(tmp[i] - c[i]) > epsilon)
151151
{
152152
std::cout << "Round-trip failed with non-zero center in pass-through dim." << std::endl;
153153
return EXIT_FAILURE;

Modules/Filtering/TextureFeatures/include/itkCoocurrenceTextureFeaturesImageFilter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>::Is
269269
bool insideNeighborhood = true;
270270
for (unsigned int i = 0; i < this->m_NeighborhoodRadius.Dimension; ++i)
271271
{
272-
int boundDistance = m_NeighborhoodRadius[i] - Math::abs(iteratedOffset[i]);
272+
int boundDistance = m_NeighborhoodRadius[i] - Math::Absolute(iteratedOffset[i]);
273273
if (boundDistance < 0)
274274
{
275275
insideNeighborhood = false;

0 commit comments

Comments
 (0)