1616 *
1717 *=========================================================================*/
1818
19- #include < iostream>
20-
21- // Native ITK stuff
2219#include " itkImageRegionIterator.h"
23-
24- // Spatial function stuff
2520#include " itkSphereSpatialFunction.h"
2621#include " itkFloodFilledSpatialFunctionConditionalIterator.h"
22+ #include " itkGTest.h"
23+
24+ #include < iostream>
25+
2726
28- int
29- itkFloodFillIteratorTest (int , char *[])
27+ TEST (FloodFillIterator, SphereFloodFill)
3028{
3129 constexpr unsigned int dim{ 3 };
3230
33- // Image type alias
3431 using TImageType = itk::Image<int , dim>;
3532
36- // -----------------Create a new input image--------------------
37- // Image size and spacing parameters
3833 TImageType::SizeValueType sourceImageSize[] = { 20 , 20 , 20 };
3934 TImageType::SpacingValueType sourceImageSpacing[] = { 1.0 , 1.0 , 1.0 };
4035 TImageType::PointValueType sourceImageOrigin[] = { 0 , 0 , 0 };
4136
42- // Creates the sourceImage (but doesn't set the size or allocate memory)
4337 auto sourceImage = TImageType::New ();
4438 sourceImage->SetOrigin (sourceImageOrigin);
4539 sourceImage->SetSpacing (sourceImageSpacing);
4640
47- std::cout << " New sourceImage created" << std::endl;
48-
49- // -----The following block allocates the sourceImage-----
50-
51- // Create a size object native to the sourceImage type
5241 TImageType::SizeType sourceImageSizeObject;
53- // Set the size object to the array defined earlier
5442 sourceImageSizeObject.SetSize (sourceImageSize);
55- // Create a region object native to the sourceImage type
5643 TImageType::RegionType largestPossibleRegion;
57- // Resize the region
5844 largestPossibleRegion.SetSize (sourceImageSizeObject);
59- // Set the largest legal region size (i.e. the size of the whole sourceImage), the buffered, and
60- // the requested region to what we just defined.
6145 sourceImage->SetRegions (largestPossibleRegion);
62- // Now allocate memory for the sourceImage
6346 sourceImage->AllocateInitialized ();
6447
65- std::cout << " New sourceImage allocated" << std::endl;
66-
67- // ---------Create and initialize a spatial function-----------
48+ std::cout << " New sourceImage created and allocated" << std::endl;
6849
6950 using TFunctionType = itk::SphereSpatialFunction<dim>;
7051 using TFunctionPositionType = TFunctionType::InputType;
7152
72- // Create and initialize a new sphere function
73-
7453 auto spatialFunc = TFunctionType::New ();
7554 spatialFunc->SetRadius (5 );
7655
@@ -80,17 +59,13 @@ itkFloodFillIteratorTest(int, char *[])
8059 center[2 ] = 10 ;
8160 spatialFunc->SetCenter (center);
8261
83- std::cout << " Sphere spatial function created" << std::endl;
84-
85- // ---------Create and initialize a spatial function iterator-----------
8662 TImageType::IndexType seedPos;
8763 constexpr TImageType::IndexValueType pos[]{ 10 , 10 , 10 };
8864 seedPos.SetIndex (pos);
8965
9066 using TItType = itk::FloodFilledSpatialFunctionConditionalIterator<TImageType, TFunctionType>;
9167 TItType sfi (sourceImage, spatialFunc, seedPos);
9268
93- // Iterate through the entire image and set interior pixels to 255
9469 for (; !(sfi.IsAtEnd ()); ++sfi)
9570 {
9671
@@ -99,6 +74,4 @@ itkFloodFillIteratorTest(int, char *[])
9974 }
10075
10176 std::cout << " Spatial function iterator created, sphere drawn" << std::endl;
102-
103- return EXIT_SUCCESS ;
10477}
0 commit comments