Skip to content

Commit 5f5e0bf

Browse files
authored
Merge pull request #5768 from N-Dekker/Future-default-not-using-legacy-SobelOperatorCoordinates
2 parents 224cad4 + ce1c203 commit 5f5e0bf

5 files changed

Lines changed: 34 additions & 3 deletions

File tree

Modules/Core/Common/include/itkSobelOperator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ class ITK_TEMPLATE_EXPORT SobelOperator : public NeighborhoodOperator<TPixel, VD
158158
Fill(const CoefficientVector & coeff) override;
159159

160160
private:
161+
#ifdef ITK_FUTURE_LEGACY_REMOVE
162+
bool m_UseLegacyCoefficients{ false };
163+
#else
161164
bool m_UseLegacyCoefficients{ true };
165+
#endif
162166
};
163167
} // namespace itk
164168

Modules/Core/Common/test/itkSobelOperatorGTest.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ TEST(SobelOperator, ExerciseBasicObjectMethods)
7373
}
7474

7575

76+
// Checks that the operator uses legacy coefficients by default, unless ITK_FUTURE_LEGACY_REMOVE is enabled.
77+
TEST(SobelOperator, IsUsingLegacyCoefficientsByDefaultUnlessFutureLegacyRemove)
78+
{
79+
itk::SobelOperator<float, 2> sobelOperator;
80+
#ifdef ITK_FUTURE_LEGACY_REMOVE
81+
EXPECT_FALSE(sobelOperator.IsUsingLegacyCoefficients());
82+
#else
83+
EXPECT_TRUE(sobelOperator.IsUsingLegacyCoefficients());
84+
#endif
85+
}
86+
87+
7688
// Checks that the coordinates of the kernels have the expected values.
7789
TEST(SobelOperator, CheckKernelCoordinates)
7890
{

Modules/Filtering/ImageFeature/include/itkSobelEdgeDetectionImageFilter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ class ITK_TEMPLATE_EXPORT SobelEdgeDetectionImageFilter : public ImageToImageFil
135135
}
136136

137137
private:
138+
#ifdef ITK_FUTURE_LEGACY_REMOVE
139+
bool m_UseLegacyOperatorCoefficients{ false };
140+
#else
138141
bool m_UseLegacyOperatorCoefficients{ true };
142+
#endif
139143
};
140144
} // end namespace itk
141145

Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterGTest.cxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@
2929
#include <vector>
3030

3131

32-
// Checks that the filter uses legacy Sobel operator coefficients by default.
33-
TEST(SobelEdgeDetectionImageFilter, UseLegacyOperatorCoefficientsByDefault)
32+
// Checks that the filter uses legacy Sobel operator coefficients by default, unless ITK_FUTURE_LEGACY_REMOVE is
33+
// enabled.
34+
TEST(SobelEdgeDetectionImageFilter, UseLegacyOperatorCoefficientsByDefaultUnlessFutureLegacyRemove)
3435
{
3536
const auto filter = itk::SobelEdgeDetectionImageFilter<itk::Image<int>, itk::Image<double>>::New();
37+
#ifdef ITK_FUTURE_LEGACY_REMOVE
38+
EXPECT_FALSE(filter->GetUseLegacyOperatorCoefficients());
39+
#else
3640
EXPECT_TRUE(filter->GetUseLegacyOperatorCoefficients());
41+
#endif
3742
}
3843

3944

Modules/Registration/Common/test/itkGradientDifferenceImageToImageMetricGTest.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,17 @@ TEST(GradientDifferenceImageToImageMetric, Test)
137137
}
138138

139139

140-
TEST(GradientDifferenceImageToImageMetric, IsUsingLegacySobelOperatorCoordinatesByDefault)
140+
// Checks that the metric uses legacy Sobel operator coefficients by default, unless ITK_FUTURE_LEGACY_REMOVE is
141+
// enabled.
142+
TEST(GradientDifferenceImageToImageMetric, IsUsingLegacySobelOperatorCoordinatesByDefaultUnlessFutureLegacyRemove)
141143
{
142144
using ImageType = itk::Image<double>;
143145
const auto metric = itk::GradientDifferenceImageToImageMetric<ImageType, ImageType>::New();
146+
#ifdef ITK_FUTURE_LEGACY_REMOVE
147+
EXPECT_FALSE(metric->IsUsingLegacySobelOperatorCoordinates());
148+
#else
144149
EXPECT_TRUE(metric->IsUsingLegacySobelOperatorCoordinates());
150+
#endif
145151
}
146152

147153

0 commit comments

Comments
 (0)