Skip to content

Commit 4a03f35

Browse files
committed
STYLE: Call FillBuffer on inputImage A, B and C in ImageIntensity tests
Replaced manual `while` loops on iterators `it1`, `it2`, and `it3`. Removed those iterators that have become unused with this commit.
1 parent 1ae411b commit 4a03f35

8 files changed

Lines changed: 19 additions & 167 deletions

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/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/itkMaximumImageFilterTest.cxx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,11 @@ itkMaximumImageFilterTest(int, char *[])
6262
constexpr PixelType largePixelValue{ 3 };
6363
constexpr PixelType smallPixelValue{ 2 };
6464

65-
// Declare Iterator types appropriate for each image
66-
using IteratorType = itk::ImageRegionIteratorWithIndex<ImageType>;
67-
68-
// Create one iterator for Image A (this is a light object)
69-
IteratorType it1(inputImageA, inputImageA->GetBufferedRegion());
70-
7165
// Initialize the content of Image A
72-
while (!it1.IsAtEnd())
73-
{
74-
it1.Set(smallPixelValue);
75-
++it1;
76-
}
77-
78-
// Create one iterator for Image B (this is a light object)
79-
IteratorType it2(inputImageB, inputImageB->GetBufferedRegion());
66+
inputImageA->FillBuffer(smallPixelValue);
8067

8168
// Initialize the content of Image B
82-
while (!it2.IsAtEnd())
83-
{
84-
it2.Set(largePixelValue);
85-
++it2;
86-
}
69+
inputImageB->FillBuffer(largePixelValue);
8770

8871
// Create the filter
8972
auto maximumImageFilter = MaximumImageFilterType::New();

Modules/Filtering/ImageIntensity/test/itkMinimumImageFilterTest.cxx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,11 @@ itkMinimumImageFilterTest(int, char *[])
6262
constexpr PixelType largePixelValue{ 3 };
6363
constexpr PixelType smallPixelValue{ 2 };
6464

65-
// Declare Iterator types appropriate for each image
66-
using IteratorType = itk::ImageRegionIteratorWithIndex<ImageType>;
67-
68-
// Create one iterator for Image A (this is a light object)
69-
IteratorType it1(inputImageA, inputImageA->GetBufferedRegion());
70-
7165
// Initialize the content of Image A
72-
while (!it1.IsAtEnd())
73-
{
74-
it1.Set(smallPixelValue);
75-
++it1;
76-
}
77-
78-
// Create one iterator for Image B (this is a light object)
79-
IteratorType it2(inputImageB, inputImageB->GetBufferedRegion());
66+
inputImageA->FillBuffer(smallPixelValue);
8067

8168
// Initialize the content of Image B
82-
while (!it2.IsAtEnd())
83-
{
84-
it2.Set(largePixelValue);
85-
++it2;
86-
}
69+
inputImageB->FillBuffer(largePixelValue);
8770

8871
// Create the filter
8972
auto minimumImageFilter = MinimumFilterType::New();

Modules/Filtering/ImageIntensity/test/itkOrImageFilterTest.cxx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,13 @@ itkOrImageFilterTest(int argc, char * argv[])
6767
inputImageB->SetRegions(region);
6868
inputImageB->Allocate();
6969

70-
// Declare appropriate Iterator types for each image
71-
using InputImage1IteratorType = itk::ImageRegionIteratorWithIndex<InputImage1Type>;
72-
using InputImage2IteratorType = itk::ImageRegionIteratorWithIndex<InputImage2Type>;
73-
74-
// Create one iterator for Image A (this is a light object)
75-
InputImage1IteratorType it1(inputImageA, inputImageA->GetBufferedRegion());
76-
it1.GoToBegin();
77-
7870
// Initialize the content of Image A
7971
constexpr InputImage1Type::PixelType valueA{ 2 };
80-
while (!it1.IsAtEnd())
81-
{
82-
it1.Set(valueA);
83-
++it1;
84-
}
85-
86-
// Create one iterator for Image B (this is a light object)
87-
InputImage2IteratorType it2(inputImageB, inputImageB->GetBufferedRegion());
88-
it2.GoToBegin();
72+
inputImageA->FillBuffer(valueA);
8973

9074
// Initialize the content of Image B
9175
constexpr InputImage2Type::PixelType valueB{ 3 };
92-
while (!it2.IsAtEnd())
93-
{
94-
it2.Set(valueB);
95-
++it2;
96-
}
76+
inputImageB->FillBuffer(valueB);
9777

9878
// Create the filter
9979
auto filter = OrImageFilterType::New();

Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeImageFilterTest.cxx

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,43 +69,17 @@ itkTernaryMagnitudeImageFilterTest(int argc, char * argv[])
6969
inputImageC->SetRegions(region);
7070
inputImageC->Allocate();
7171

72-
// Declare Iterator types for each image
73-
using InputImage1IteratorType = itk::ImageRegionIteratorWithIndex<InputImage1Type>;
74-
using InputImage2IteratorType = itk::ImageRegionIteratorWithIndex<InputImage2Type>;
75-
using InputImage3IteratorType = itk::ImageRegionIteratorWithIndex<InputImage3Type>;
76-
77-
// Create one iterator for Image A (this is a light object)
78-
InputImage1IteratorType it1(inputImageA, inputImageA->GetBufferedRegion());
79-
8072
// Initialize the content of Image A
8173
constexpr InputImage1Type::PixelType valueA{ 2.0 };
82-
while (!it1.IsAtEnd())
83-
{
84-
it1.Set(valueA);
85-
++it1;
86-
}
87-
88-
// Create one iterator for Image B (this is a light object)
89-
InputImage2IteratorType it2(inputImageB, inputImageB->GetBufferedRegion());
74+
inputImageA->FillBuffer(valueA);
9075

9176
// Initialize the content of Image B
9277
constexpr InputImage2Type::PixelType valueB{ 3.0 };
93-
while (!it2.IsAtEnd())
94-
{
95-
it2.Set(valueB);
96-
++it2;
97-
}
98-
99-
// Create one iterator for Image C (this is a light object)
100-
InputImage3IteratorType it3(inputImageC, inputImageC->GetBufferedRegion());
78+
inputImageB->FillBuffer(valueB);
10179

10280
// Initialize the content of Image C
10381
constexpr InputImage3Type::PixelType valueC{ 4.0 };
104-
while (!it3.IsAtEnd())
105-
{
106-
it3.Set(valueC);
107-
++it3;
108-
}
82+
inputImageC->FillBuffer(valueC);
10983

11084
using TernaryMagnitudeImageFilterType =
11185
itk::TernaryMagnitudeImageFilter<InputImage1Type, InputImage2Type, InputImage3Type, OutputImageType>;

Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeSquaredImageFilterTest.cxx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,21 @@ itkTernaryMagnitudeSquaredImageFilterTest(int, char *[])
7474

7575
// Initialize the content of Image A
7676
constexpr InputImageType1::PixelType valueA{ 2.0 };
77-
while (!it1.IsAtEnd())
78-
{
79-
it1.Set(valueA);
80-
++it1;
81-
}
77+
inputImageA->FillBuffer(valueA);
8278

8379
// Create one iterator for Image B (this is a light object)
8480
InputImage2IteratorType it2(inputImageB, inputImageB->GetBufferedRegion());
8581

8682
// Initialize the content of Image B
8783
constexpr InputImageType2::PixelType valueB{ 3.0 };
88-
while (!it2.IsAtEnd())
89-
{
90-
it2.Set(valueB);
91-
++it2;
92-
}
84+
inputImageB->FillBuffer(valueB);
9385

9486
// Create one iterator for Image C (this is a light object)
9587
InputImage3IteratorType it3(inputImageC, inputImageC->GetBufferedRegion());
9688

9789
// Initialize the content of Image C
9890
constexpr InputImageType3::PixelType valueC{ 4.0 };
99-
while (!it3.IsAtEnd())
100-
{
101-
it3.Set(valueC);
102-
++it3;
103-
}
91+
inputImageC->FillBuffer(valueC);
10492

10593

10694
// Declare the type for the TernaryMagnitudeSquaredImageFilter

Modules/Filtering/ImageIntensity/test/itkXorImageFilterTest.cxx

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

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

8872
// Initialize the content of Image B
8973
constexpr InputImage2Type::PixelType valueB{ 3 };
90-
while (!it2.IsAtEnd())
91-
{
92-
it2.Set(valueB);
93-
++it2;
94-
}
74+
inputImageB->FillBuffer(valueB);
9575

9676
// Create the filter
9777
auto filter = XorImageFilterType::New();

0 commit comments

Comments
 (0)