1818
1919#include " itkRandomImageSource.h"
2020#include " itkThresholdImageFilter.h"
21+ #include " itkTestingMacros.h"
2122#include " itkTextOutput.h"
2223
2324#include < sstream>
@@ -53,6 +54,9 @@ itkThresholdImageFilterTest(int, char *[])
5354 {
5455 itk::ThresholdImageFilter<FloatImage2DType>::Pointer threshold;
5556 threshold = itk::ThresholdImageFilter<FloatImage2DType>::New ();
57+
58+ ITK_EXERCISE_BASIC_OBJECT_METHODS (threshold, ThresholdImageFilter, InPlaceImageFilter);
59+
5660 threshold->SetInput (random->GetOutput ());
5761
5862 // Exercise threshold setting functions
@@ -140,7 +144,9 @@ itkThresholdImageFilterTest(int, char *[])
140144 // Test #4, threshold values
141145 itk::OutputWindow::GetInstance ()->DisplayText (" Test #4: threshold values -----------------" );
142146 {
143- using IntImage1DType = itk::Image<int , 1 >;
147+ using PixelType = int ;
148+
149+ using IntImage1DType = itk::Image<PixelType, 1 >;
144150 IntImage1DType::Pointer input = IntImage1DType::New ();
145151 IntImage1DType::SpacingValueType inputSpacing[1 ] = { 0.7 };
146152 input->SetSpacing (inputSpacing);
@@ -152,18 +158,28 @@ itkThresholdImageFilterTest(int, char *[])
152158 input->SetRegions (inputRegion);
153159 input->Allocate ();
154160 // The inputValue can be any random value.
155- int inputValue = 9 ;
161+ PixelType inputValue = 9 ;
156162 input->FillBuffer (inputValue);
157163
158164 itk::ThresholdImageFilter<IntImage1DType>::Pointer threshold;
159165 threshold = itk::ThresholdImageFilter<IntImage1DType>::New ();
166+
160167 threshold->SetInput (input);
161- int outsideValue = 99 ;
168+ PixelType outsideValue = 99 ;
162169 threshold->SetOutsideValue (outsideValue);
170+ ITK_TEST_SET_GET_VALUE (outsideValue, threshold->GetOutsideValue ());
163171 IntImage1DType::IndexType index;
164172 index.Fill (0 );
165173
166- int outputValue;
174+ PixelType lower = itk::NumericTraits<PixelType>::NonpositiveMin ();
175+ threshold->SetLower (lower);
176+ ITK_TEST_SET_GET_VALUE (lower, threshold->GetLower ());
177+
178+ PixelType upper = itk::NumericTraits<PixelType>::max ();
179+ threshold->SetUpper (upper);
180+ ITK_TEST_SET_GET_VALUE (upper, threshold->GetUpper ());
181+
182+ PixelType outputValue;
167183 // Above inputValue-1
168184 threshold->ThresholdAbove (inputValue - 1 );
169185 threshold->Update ();
0 commit comments