Skip to content

Commit

Permalink
STYLE: Replace Index var; var.Fill with auto var = Index::Filled
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Dekker committed Nov 11, 2024
1 parent 1a4112c commit d99166c
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 38 deletions.
3 changes: 1 addition & 2 deletions src/Core/Common/AddOffsetToIndex/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ main()
{
constexpr unsigned int Dimension = 2;

itk::Index<Dimension> index;
index.Fill(5);
auto index = itk::Index<Dimension>::Filled(5);

itk::Offset<Dimension> offset;
offset.Fill(1);
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Common/CreateAnImageRegion/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ main()
using RegionType = itk::ImageRegion<Dimension>;
auto size = RegionType::SizeType::Filled(3);

RegionType::IndexType index;
index.Fill(1);
auto index = RegionType::IndexType::Filled(1);

RegionType region(index, size);

Expand Down
6 changes: 2 additions & 4 deletions src/Core/Common/CropImageBySpecifyingRegion/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ main()

std::cout << "Image largest region: " << image->GetLargestPossibleRegion() << std::endl;

ImageType::IndexType desiredStart;
desiredStart.Fill(3);
auto desiredStart = ImageType::IndexType::Filled(3);

auto desiredSize = ImageType::SizeType::Filled(4);

Expand All @@ -60,8 +59,7 @@ main()
output->DisconnectPipeline();
output->FillBuffer(2);

itk::Index<2> index;
index.Fill(5);
auto index = itk::Index<2>::Filled(5);

std::cout << "new largest region: " << output->GetLargestPossibleRegion() << std::endl;
std::cout << "new: " << (int)output->GetPixel(index) << std::endl;
Expand Down
6 changes: 2 additions & 4 deletions src/Core/Common/DistanceBetweenIndices/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
int
main()
{
itk::Index<2> pixel1;
pixel1.Fill(2);
auto pixel1 = itk::Index<2>::Filled(2);

itk::Index<2> pixel2;
pixel2.Fill(4);
auto pixel2 = itk::Index<2>::Filled(4);

itk::Point<double, 2> p1;
p1[0] = pixel1[0];
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Common/IterateImageStartingAtSeed/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ CreateImage(ImageType::Pointer image)
// Make a line
for (unsigned int i = 20; i < 50; ++i)
{
itk::Index<2> pixelIndex;
pixelIndex.Fill(i);
auto pixelIndex = itk::Index<2>::Filled(i);

image->SetPixel(pixelIndex, 255);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Core/ImageFunction/ComputeMedianOfImageAtPixel/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ main()
auto medianImageFunction = MedianImageFunctionType::New();
medianImageFunction->SetInputImage(image);

itk::Index<2> index;
index.Fill(10);
auto index = itk::Index<2>::Filled(10);
std::cout << "Median at " << index << " is " << static_cast<int>(medianImageFunction->EvaluateAtIndex(index))
<< std::endl;
return EXIT_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,21 @@ main()
neighborhoodOperatorImageFunction->SetInputImage(image);

{
itk::Index<2> index;
index.Fill(20);
auto index = itk::Index<2>::Filled(20);

float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
std::cout << "Sum on border: " << output << std::endl;
}

{
itk::Index<2> index;
index.Fill(35);
auto index = itk::Index<2>::Filled(35);

float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
std::cout << "Sum in center: " << output << std::endl;
}

{
itk::Index<2> index;
index.Fill(7);
auto index = itk::Index<2>::Filled(7);

float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
std::cout << "Sum outside: " << output << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ main(int argc, char * argv[])

auto extractFilter = ExtractFilterType::New();

FloatImageType::IndexType start;
start.Fill(50);
auto start = FloatImageType::IndexType::Filled(50);

auto patchSize = FloatImageType::SizeType::Filled(51);

Expand Down
3 changes: 1 addition & 2 deletions src/Filtering/Convolution/NormalizedCorrelation/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ main(int argc, char * argv[])

auto extractFilter = ExtractFilterType::New();

FloatImageType::IndexType start;
start.Fill(50);
auto start = FloatImageType::IndexType::Filled(50);

auto patchSize = FloatImageType::SizeType::Filled(51);

Expand Down
3 changes: 1 addition & 2 deletions src/Filtering/DistanceMap/ApproxDistanceMapOfBinary/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ CreateImage(UnsignedCharImageType::Pointer image)
// Create a line of white pixels
for (unsigned int i = 40; i < 60; ++i)
{
itk::Index<2> pixel;
pixel.Fill(i);
auto pixel = itk::Index<2>::Filled(i);
image->SetPixel(pixel, 255);
}
}
3 changes: 1 addition & 2 deletions src/Filtering/DistanceMap/MaurerDistanceMapOfBinary/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ CreateImage(UnsignedCharImageType::Pointer image)
// Create a line of white pixels
for (unsigned int i = 40; i < 60; ++i)
{
itk::Index<2> pixel;
pixel.Fill(i);
auto pixel = itk::Index<2>::Filled(i);
image->SetPixel(pixel, 255);
}
}
3 changes: 1 addition & 2 deletions src/Filtering/DistanceMap/SignedDistanceMapOfBinary/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ CreateImage(UnsignedCharImageType::Pointer image)
// Create a line of white pixels
for (unsigned int i = 40; i < 60; ++i)
{
itk::Index<2> pixel;
pixel.Fill(i);
auto pixel = itk::Index<2>::Filled(i);
image->SetPixel(pixel, 255);
}
}
3 changes: 1 addition & 2 deletions src/Filtering/ImageFeature/ExtractContoursFromImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ void CreateImage(UnsignedCharImageType::Pointer image)
// Create a line pixels
for(unsigned int i = 40; i < 60; ++i)
{
itk::Index<2> pixel;
pixel.Fill(i);
auto pixel = itk::Index<2>::Filled(i);
image->SetPixel(pixel, 255);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Filtering/ImageFilterBase/ComputeLocalNoise/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ CreateImage(ImageType::Pointer image)
}

// Create a rogue white pixel
ImageType::IndexType pixel;
pixel.Fill(20);
auto pixel = ImageType::IndexType::Filled(20);
image->SetPixel(pixel, 255);

itk::WriteImage(image, "input.mhd");
Expand Down
3 changes: 1 addition & 2 deletions src/Filtering/Path/ExtractContoursFromImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ CreateImage(UnsignedCharImageType::Pointer image)
// Create a line of white pixels
for (unsigned int i = 40; i < 60; ++i)
{
itk::Index<2> pixel;
pixel.Fill(i);
auto pixel = itk::Index<2>::Filled(i);
image->SetPixel(pixel, 255);
}

Expand Down

0 comments on commit d99166c

Please sign in to comment.