Skip to content

Commit 77e3bef

Browse files
N-Dekkerhjmjohnson
authored andcommitted
STYLE: Replace loops doing Set(0.0) with AllocateInitialized(), in tests
Replaced `while (!it.IsAtEnd())` loops doing `it.Set(0.0)` with `inputImage->AllocateInitialized()` calls.
1 parent 027b946 commit 77e3bef

9 files changed

+9
-97
lines changed

Modules/Filtering/DiffusionTensorImage/test/itkTensorFractionalAnisotropyImageFilterTest.cxx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,11 @@ itkTensorFractionalAnisotropyImageFilterTest(int, char *[])
5252

5353
// Initialize Image A
5454
inputImage->SetRegions(region);
55-
inputImage->Allocate();
55+
inputImage->AllocateInitialized();
5656

5757
// Declare Iterator type for the input image
5858
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
5959

60-
// Create one iterator for the Input Image A (this is a light object)
61-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
62-
63-
// Initialize the content of Image A
64-
while (!it.IsAtEnd())
65-
{
66-
it.Set(0.0);
67-
++it;
68-
}
69-
7060
size[0] = 4;
7161
size[1] = 4;
7262
size[2] = 4;

Modules/Filtering/DiffusionTensorImage/test/itkTensorRelativeAnisotropyImageFilterTest.cxx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,11 @@ itkTensorRelativeAnisotropyImageFilterTest(int, char *[])
5252

5353
// Initialize Image A
5454
inputImage->SetRegions(region);
55-
inputImage->Allocate();
55+
inputImage->AllocateInitialized();
5656

5757
// Declare Iterator type for the input image
5858
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
5959

60-
// Create one iterator for the Input Image A (this is a light object)
61-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
62-
63-
// Initialize the content of Image A
64-
while (!it.IsAtEnd())
65-
{
66-
it.Set(0.0);
67-
++it;
68-
}
69-
7060
size[0] = 4;
7161
size[1] = 4;
7262
size[2] = 4;

Modules/Filtering/ImageFeature/test/itkGradientVectorFlowImageFilterTest.cxx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ itkGradientVectorFlowImageFilterTest(int, char *[])
6464

6565
// Initialize Image A
6666
inputImage->SetRegions(region);
67-
inputImage->Allocate();
67+
inputImage->AllocateInitialized();
6868

6969
interImage->SetRegions(region);
7070
interImage->Allocate();
@@ -77,18 +77,9 @@ itkGradientVectorFlowImageFilterTest(int, char *[])
7777

7878
using myOutputIteratorType = itk::ImageRegionIteratorWithIndex<myGradientImageType>;
7979

80-
// Create one iterator for the Input Image A (this is a light object)
81-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
82-
8380
// Initialize the content of Image A
8481
std::cout << "Input Image initialization " << std::endl;
8582

86-
while (!it.IsAtEnd())
87-
{
88-
it.Set(0.0);
89-
++it;
90-
}
91-
9283
size[0] = 100;
9384
size[1] = 100;
9485

Modules/Filtering/ImageFeature/test/itkHessian3DToVesselnessMeasureImageFilterTest.cxx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,11 @@ itkHessian3DToVesselnessMeasureImageFilterTest(int argc, char * argv[])
5959

6060
// Initialize Image A
6161
inputImage->SetRegions(region);
62-
inputImage->Allocate();
62+
inputImage->AllocateInitialized();
6363

6464
// Declare Iterator type for the input image
6565
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
6666

67-
// Create one iterator for the Input Image A (this is a light object)
68-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
69-
70-
// Initialize the content of Image A
71-
while (!it.IsAtEnd())
72-
{
73-
it.Set(0.0);
74-
++it;
75-
}
76-
7767
size[0] = 1;
7868
size[1] = 8;
7969
size[2] = 1;

Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,11 @@ itkHessianRecursiveGaussianFilterTest(int argc, char * argv[])
5555

5656
// Initialize Image A
5757
inputImage->SetRegions(region);
58-
inputImage->Allocate();
58+
inputImage->AllocateInitialized();
5959

6060
// Declare Iterator type for the input image
6161
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
6262

63-
// Create one iterator for the Input Image A (this is a light object)
64-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
65-
66-
// Initialize the content of Image A
67-
while (!it.IsAtEnd())
68-
{
69-
it.Set(0.0);
70-
++it;
71-
}
72-
7363
size[0] = 4;
7464
size[1] = 4;
7565
size[2] = 4;

Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterSpeedTest.cxx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,11 @@ itkGradientRecursiveGaussianFilterSpeedTest(int argc, char * argv[])
6262

6363
// Initialize Image A
6464
inputImage->SetRegions(region);
65-
inputImage->Allocate();
65+
inputImage->AllocateInitialized();
6666

6767
// Declare Iterator type for the input image
6868
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
6969

70-
// Create one iterator for the Input Image A (this is a light object)
71-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
72-
73-
// Initialize the content of Image A
74-
while (!it.IsAtEnd())
75-
{
76-
it.Set(0.0);
77-
++it;
78-
}
79-
8070
size.Fill(imageSize - 4);
8171

8272
start[0] = 2;

Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest.cxx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,11 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[])
5959

6060
// Initialize Image A
6161
inputImage->SetRegions(region);
62-
inputImage->Allocate();
62+
inputImage->AllocateInitialized();
6363

6464
// Declare Iterator type for the input image
6565
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
6666

67-
// Create one iterator for the Input Image A (this is a light object)
68-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
69-
70-
// Initialize the content of Image A
71-
while (!it.IsAtEnd())
72-
{
73-
it.Set(0.0);
74-
++it;
75-
}
76-
7767
size[0] = 4;
7868
size[1] = 4;
7969
size[2] = 4;

Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest2.cxx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,11 @@ itkGradientRecursiveGaussianFilterTest2(int, char *[])
5555

5656
// Initialize Image A
5757
inputImage->SetRegions(region);
58-
inputImage->Allocate();
58+
inputImage->AllocateInitialized();
5959

6060
// Declare Iterator type for the input image
6161
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
6262

63-
// Create one iterator for the Input Image A (this is a light object)
64-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
65-
66-
// Initialize the content of Image A
67-
while (!it.IsAtEnd())
68-
{
69-
it.Set(0.0);
70-
++it;
71-
}
72-
7363
size[0] = 32;
7464

7565
start[0] = 16;

Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterTest.cxx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,13 @@ itkRecursiveGaussianImageFilterTest(int, char *[])
5959

6060
// Initialize Image A
6161
inputImage->SetRegions(region);
62-
inputImage->Allocate();
62+
inputImage->AllocateInitialized();
6363

6464
// Declare Iterator types appropriate for each image
6565
using myIteratorType = itk::ImageRegionIteratorWithIndex<myImageType>;
6666

67-
68-
// Create one iterator for the Input Image A (this is a light object)
69-
myIteratorType it(inputImage, inputImage->GetRequestedRegion());
70-
7167
// Initialize the content of Image A
7268
std::cout << "Input Image initialization " << std::endl;
73-
while (!it.IsAtEnd())
74-
{
75-
it.Set(0.0);
76-
++it;
77-
}
7869

7970
size[0] = 60;
8071
size[1] = 60;

0 commit comments

Comments
 (0)