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
Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(typename )?(.*Index.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\4\.Fill\(
    Replace with: $1auto $4 = $3::Filled\(
    Filters: itk*.h;itk*.hxx;itk*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to pull request #4887
commit 504d63b
"STYLE: Replace `index.Fill` with `auto index = Index::Filled` in tests"
  • Loading branch information
N-Dekker authored and dzenanz committed Oct 29, 2024
1 parent 7fd1e73 commit 3ff56ea
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::InitializePatchWeight
physicalWeightsImage->Allocate();
physicalWeightsImage->FillBuffer(1.0);

typename WeightsImageType::IndexType centerIndex;
centerIndex.Fill(patchRadius);
auto centerIndex = WeightsImageType::IndexType::Filled(patchRadius);

unsigned int pos = 0;
for (ImageRegionIteratorWithIndex<WeightsImageType> pwIt(physicalWeightsImage, physicalRegion); !pwIt.IsAtEnd();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ AutoCropLabelMapFilter<TInputImage>::GenerateOutputInformation()
}

// find the bounding box of the objects
IndexType minIdx;
minIdx.Fill(NumericTraits<typename TInputImage::IndexValueType>::max());
IndexType maxIdx;
maxIdx.Fill(NumericTraits<typename TInputImage::IndexValueType>::NonpositiveMin());
auto minIdx = IndexType::Filled(NumericTraits<typename TInputImage::IndexValueType>::max());
auto maxIdx = IndexType::Filled(NumericTraits<typename TInputImage::IndexValueType>::NonpositiveMin());

const InputImageType * inputImage = this->GetInput();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ LabelMapMaskImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
else
{
// Compute the bounding box of all the objects which don't have that label
IndexType mins;
mins.Fill(NumericTraits<IndexValueType>::max());
IndexType maxs;
maxs.Fill(NumericTraits<IndexValueType>::NonpositiveMin());
auto mins = IndexType::Filled(NumericTraits<IndexValueType>::max());
auto maxs = IndexType::Filled(NumericTraits<IndexValueType>::NonpositiveMin());
for (typename InputImageType::ConstIterator loit(this->GetInput()); !loit.IsAtEnd(); ++loit)
{
if (loit.GetLabel() != m_Label)
Expand Down Expand Up @@ -168,10 +166,8 @@ LabelMapMaskImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
// Just find the bounding box of the object with that label

const LabelObjectType * labelObject = input->GetLabelObject(m_Label);
IndexType mins;
mins.Fill(NumericTraits<IndexValueType>::max());
IndexType maxs;
maxs.Fill(NumericTraits<IndexValueType>::NonpositiveMin());
auto mins = IndexType::Filled(NumericTraits<IndexValueType>::max());
auto maxs = IndexType::Filled(NumericTraits<IndexValueType>::NonpositiveMin());
// Iterate over all the lines
typename LabelObjectType::ConstLineIterator lit(labelObject);
while (!lit.IsAtEnd())
Expand Down
12 changes: 5 additions & 7 deletions Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,11 @@ ShapeLabelMapFilter<TImage, TLabelImage>::ThreadedProcessLabelObject(LabelObject
// Init the vars
SizeValueType nbOfPixels = 0;
ContinuousIndex<double, ImageDimension> centroid{};
IndexType mins;
mins.Fill(NumericTraits<IndexValueType>::max());
IndexType maxs;
maxs.Fill(NumericTraits<IndexValueType>::NonpositiveMin());
SizeValueType nbOfPixelsOnBorder = 0;
double perimeterOnBorder = 0;
MatrixType centralMoments{};
auto mins = IndexType::Filled(NumericTraits<IndexValueType>::max());
auto maxs = IndexType::Filled(NumericTraits<IndexValueType>::NonpositiveMin());
SizeValueType nbOfPixelsOnBorder = 0;
double perimeterOnBorder = 0;
MatrixType centralMoments{};

using LengthType = typename LabelObjectType::LengthType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,14 @@ DiscreteGaussianDerivativeImageFunction<TInputImage, TOutput>::RecomputeGaussian
kernelImage->AllocateInitialized();

// Initially the kernel image will be an impulse at the center
typename KernelImageType::IndexType centerIndex;
centerIndex.Fill(2 * m_OperatorArray[0].GetRadius()[0]); // include also
// boundaries
auto centerIndex = KernelImageType::IndexType::Filled(2 * m_OperatorArray[0].GetRadius()[0]); // include also
// boundaries
kernelImage->SetPixel(centerIndex, itk::NumericTraits<TOutput>::OneValue());

// Create an image region to be used later that does not include boundaries
RegionType kernelRegion;
size.Fill(2 * m_OperatorArray[0].GetRadius()[0] + 1);
typename RegionType::IndexType origin;
origin.Fill(m_OperatorArray[0].GetRadius()[0]);
auto origin = RegionType::IndexType::Filled(m_OperatorArray[0].GetRadius()[0]);
kernelRegion.SetSize(size);
kernelRegion.SetIndex(origin);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ DiscreteGradientMagnitudeGaussianImageFunction<TInputImage, TOutput>::RecomputeG
kernelImage->AllocateInitialized();

// Initially the kernel image will be an impulse at the center
typename KernelImageType::IndexType centerIndex;
centerIndex.Fill(2 * maxRadius); // include also boundaries
auto centerIndex = KernelImageType::IndexType::Filled(2 * maxRadius); // include also boundaries

// Create an image region to be used later that does not include boundaries
RegionType kernelRegion;
size.Fill(2 * maxRadius + 1);
typename RegionType::IndexType origin;
origin.Fill(maxRadius);
auto origin = RegionType::IndexType::Filled(maxRadius);
kernelRegion.SetSize(size);
kernelRegion.SetIndex(origin);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ DiscreteHessianGaussianImageFunction<TInputImage, TOutput>::RecomputeGaussianKer
kernelImage->AllocateInitialized();

// Initially the kernel image will be an impulse at the center
typename KernelImageType::IndexType centerIndex;
centerIndex.Fill(2 * maxRadius); // include also boundaries
auto centerIndex = KernelImageType::IndexType::Filled(2 * maxRadius); // include also boundaries

// Create an image region to be used later that does not include boundaries
RegionType kernelRegion;
size.Fill(2 * maxRadius + 1);
typename RegionType::IndexType origin;
origin.Fill(maxRadius);
auto origin = RegionType::IndexType::Filled(maxRadius);
kernelRegion.SetSize(size);
kernelRegion.SetIndex(origin);

Expand Down

0 comments on commit 3ff56ea

Please sign in to comment.