Skip to content

Commit 44690ac

Browse files
authored
Merge pull request InsightSoftwareConsortium#5651 from N-Dekker/FillBuffer-ImageIntensity-tests
Call FillBuffer on inputImage (A, B, or C) in ImageIntensity tests
2 parents 70204be + 4a03f35 commit 44690ac

26 files changed

+38
-279
lines changed

Modules/Filtering/ImageIntensity/test/itkAcosImageFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[])
6666
// Initialize the content of Image A
6767
const double pi = std::atan(1.0) * 4.0;
6868
const double value = pi / 6.0;
69-
it.GoToBegin();
70-
while (!it.IsAtEnd())
71-
{
72-
it.Set(value);
73-
++it;
74-
}
69+
inputImage->FillBuffer(value);
7570

7671
// Declare the type for the Acos filter
7772
using FilterType = itk::AcosImageFilter<InputImageType, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkAndImageFilterTest.cxx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,13 @@ itkAndImageFilterTest(int argc, char * argv[])
6363
inputImageB->SetRegions(region);
6464
inputImageB->Allocate();
6565

66-
// Declare Iterator types appropriate for each image
67-
using InputImage1IteratorType = itk::ImageRegionIteratorWithIndex<InputImage1Type>;
68-
using InputImage2IteratorType = itk::ImageRegionIteratorWithIndex<InputImage2Type>;
69-
70-
// Create one iterator for Image A (this is a light object)
71-
InputImage1IteratorType it1(inputImageA, inputImageA->GetBufferedRegion());
72-
it1.GoToBegin();
73-
7466
// Initialize the content of Image A
7567
constexpr InputImage1Type::PixelType valueA{ 2 };
76-
while (!it1.IsAtEnd())
77-
{
78-
it1.Set(valueA);
79-
++it1;
80-
}
81-
82-
// Create one iterator for Image B (this is a light object)
83-
InputImage2IteratorType it2(inputImageB, inputImageB->GetBufferedRegion());
84-
it2.GoToBegin();
68+
inputImageA->FillBuffer(valueA);
8569

8670
// Initialize the content of Image B
8771
constexpr InputImage2Type::PixelType valueB{ 3 };
88-
while (!it2.IsAtEnd())
89-
{
90-
it2.Set(valueB);
91-
++it2;
92-
}
72+
inputImageB->FillBuffer(valueB);
9373

9474
using AndImageFilterType = itk::AndImageFilter<InputImage1Type, InputImage2Type, OutputImageType>;
9575

Modules/Filtering/ImageIntensity/test/itkAsinImageFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,7 @@ itkAsinImageFilterAndAdaptorTest(int, char *[])
6464
// Initialize the content of Image A
6565
const double pi = std::atan(1.0) * 4.0;
6666
const double value = pi / 6.0;
67-
it.GoToBegin();
68-
while (!it.IsAtEnd())
69-
{
70-
it.Set(value);
71-
++it;
72-
}
67+
inputImage->FillBuffer(value);
7368

7469
// Declare the type for the Asin filter
7570
using FilterType = itk::AsinImageFilter<InputImageType, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkAtanImageFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ itkAtanImageFilterAndAdaptorTest(int, char *[])
6363

6464
// Initialize the content of Image A
6565
constexpr double value{ itk::Math::pi / 6.0 };
66-
it.GoToBegin();
67-
while (!it.IsAtEnd())
68-
{
69-
it.Set(value);
70-
++it;
71-
}
66+
inputImage->FillBuffer(value);
7267

7368
// Declare the type for the Atan filter
7469
using FilterType = itk::AtanImageFilter<InputImageType, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkBinaryMagnitudeImageFilterTest.cxx

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,32 +59,16 @@ itkBinaryMagnitudeImageFilterTest(int, char *[])
5959
inputImageB->SetRegions(region);
6060
inputImageB->Allocate();
6161

62-
// Declare appropriate Iterator types for each image
63-
using InputImage1IteratorType = itk::ImageRegionIteratorWithIndex<InputImageType1>;
64-
using InputImage2IteratorType = itk::ImageRegionIteratorWithIndex<InputImageType2>;
62+
// Declare appropriate Iterator type
6563
using OutputImageIteratorType = itk::ImageRegionIteratorWithIndex<OutputImageType>;
6664

67-
// Create one iterator for Image A (this is a light object)
68-
InputImage1IteratorType it1(inputImageA, inputImageA->GetBufferedRegion());
69-
7065
// Initialize the content of Image A
7166
constexpr InputImageType1::PixelType input1Value{ 3.0 };
72-
while (!it1.IsAtEnd())
73-
{
74-
it1.Set(input1Value);
75-
++it1;
76-
}
77-
78-
// Create one iterator for Image B (this is a light object)
79-
InputImage2IteratorType it2(inputImageB, inputImageB->GetBufferedRegion());
67+
inputImageA->FillBuffer(input1Value);
8068

8169
// Initialize the content of Image B
8270
constexpr InputImageType2::PixelType input2Value{ 4.0 };
83-
while (!it2.IsAtEnd())
84-
{
85-
it2.Set(input2Value);
86-
++it2;
87-
}
71+
inputImageB->FillBuffer(input2Value);
8872

8973
// Define the values of the output image
9074
constexpr OutputImageType::PixelType outputValue{ 5.0 };

Modules/Filtering/ImageIntensity/test/itkComplexToImaginaryFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ itkComplexToImaginaryFilterAndAdaptorTest(int, char *[])
6161

6262
// Initialize the content of Image A
6363
constexpr InputPixelType value(13, 25);
64-
it.GoToBegin();
65-
while (!it.IsAtEnd())
66-
{
67-
it.Set(value);
68-
++it;
69-
}
64+
inputImage->FillBuffer(value);
7065

7166
// Declare the type for the ComplexToImaginary filter
7267
using FilterType = itk::ComplexToImaginaryImageFilter<InputImageType, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkComplexToModulusFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,7 @@ itkComplexToModulusFilterAndAdaptorTest(int, char *[])
6565
const double modulus = std::sqrt(value.real() * value.real() + value.imag() * value.imag());
6666

6767
std::cout << "Modulus of input pixel = " << modulus << std::endl;
68-
it.GoToBegin();
69-
while (!it.IsAtEnd())
70-
{
71-
it.Set(value);
72-
++it;
73-
}
68+
inputImage->FillBuffer(value);
7469

7570
// Declare the type for the ComplexToModulus filter
7671
using FilterType = itk::ComplexToModulusImageFilter<InputImageType, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkComplexToPhaseFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ itkComplexToPhaseFilterAndAdaptorTest(int, char *[])
6161

6262
// Initialize the content of Image A
6363
constexpr InputPixelType value(13, 25);
64-
it.GoToBegin();
65-
while (!it.IsAtEnd())
66-
{
67-
it.Set(value);
68-
++it;
69-
}
64+
inputImage->FillBuffer(value);
7065

7166
// Declare the type for the ComplexToPhase filter
7267
using FilterType = itk::ComplexToPhaseImageFilter<InputImageType, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkComplexToRealFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ itkComplexToRealFilterAndAdaptorTest(int, char *[])
6161

6262
// Initialize the content of Image A
6363
constexpr InputPixelType value(13, 25);
64-
it.GoToBegin();
65-
while (!it.IsAtEnd())
66-
{
67-
it.Set(value);
68-
++it;
69-
}
64+
inputImage->FillBuffer(value);
7065

7166
// Declare the type for the ComplexToReal filter
7267
using FilterType = itk::ComplexToRealImageFilter<InputImageType, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkCosImageFilterAndAdaptorTest.cxx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ itkCosImageFilterAndAdaptorTest(int, char *[])
6363

6464
// Initialize the content of Image A
6565
constexpr double value{ itk::Math::pi / 6.0 };
66-
it.GoToBegin();
67-
while (!it.IsAtEnd())
68-
{
69-
it.Set(value);
70-
++it;
71-
}
66+
inputImage->FillBuffer(value);
7267

7368
// Declare the type for the Cos filter
7469
using FilterType = itk::CosImageFilter<InputImageType, OutputImageType>;

0 commit comments

Comments
 (0)