Skip to content

Commit

Permalink
STYLE: Remove local ImageScanlineIterator type aliases, using C++17 CTAD
Browse files Browse the repository at this point in the history
Removed the local type aliases of `ImageScanlineIterator` and
`ImageScanlineConstIterator` that were previously only used to declare a single
local variable, and used C++17 class template argument deduction instead.
  • Loading branch information
N-Dekker authored and dzenanz committed Apr 24, 2023
1 parent a6c3742 commit 788e558
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 55 deletions.
Expand Up @@ -178,8 +178,7 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::Nonlinea
const TransformType * transform = this->GetInput()->Get();

// Create an iterator that will walk the output region for this thread.
using OutputIteratorType = ImageScanlineIterator<TOutputImage>;
OutputIteratorType outIt(output, outputRegionForThread);
ImageScanlineIterator outIt(output, outputRegionForThread);

// Define a few variables that will be used to translate from an input pixel
// to an output pixel
Expand Down Expand Up @@ -228,8 +227,7 @@ TransformToDisplacementFieldFilter<TOutputImage, TParametersValueType>::LinearTh
const OutputImageRegionType & largestPossibleRegion = outputPtr->GetLargestPossibleRegion();

// Create an iterator that will walk the output region for this thread.
using OutputIteratorType = ImageScanlineIterator<TOutputImage>;
OutputIteratorType outIt(outputPtr, outputRegionForThread);
ImageScanlineIterator outIt(outputPtr, outputRegionForThread);

// Define a few indices that will be used to translate from an input pixel
// to an output pixel
Expand Down
Expand Up @@ -107,11 +107,8 @@ BinShrinkImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
using OutputPixelType = typename OutputImageType::PixelType;
using AccumulatePixelType = typename NumericTraits<InputPixelType>::RealType;

using InputConstIteratorType = ImageScanlineConstIterator<InputImageType>;
using OutputIteratorType = ImageScanlineIterator<OutputImageType>;

InputConstIteratorType inputIterator(inputPtr, inputPtr->GetRequestedRegion());
OutputIteratorType outputIterator(outputPtr, outputRegionForThread);
ImageScanlineConstIterator inputIterator(inputPtr, inputPtr->GetRequestedRegion());
ImageScanlineIterator outputIterator(outputPtr, outputRegionForThread);

// Set up shaped neighbor hood by defining the offsets
OutputOffsetType negativeOffset, positiveOffset, iOffset;
Expand Down
4 changes: 1 addition & 3 deletions Modules/Filtering/ImageGrid/include/itkExpandImageFilter.hxx
Expand Up @@ -113,9 +113,7 @@ ExpandImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
OutputImagePointer outputPtr = this->GetOutput();

// Iterator for walking the output
using OutputIterator = ImageScanlineIterator<TOutputImage>;

OutputIterator outIt(outputPtr, outputRegionForThread);
ImageScanlineIterator outIt(outputPtr, outputRegionForThread);

// Report progress on a per scanline basis
const SizeValueType ln = outputRegionForThread.GetSize(0);
Expand Down
Expand Up @@ -435,8 +435,7 @@ ResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType, TTran
const TransformType * transformPtr = this->GetTransform();

// Create an iterator that will walk the output region for this thread.
using OutputIterator = ImageScanlineIterator<TOutputImage>;
OutputIterator outIt(outputPtr, outputRegionForThread);
ImageScanlineIterator outIt(outputPtr, outputRegionForThread);

TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels());

Expand Down
Expand Up @@ -125,11 +125,9 @@ BinaryContourImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData
OutputImageType * output = this->GetOutput();
const InputImageType * input = this->GetInput();

using InputLineIteratorType = ImageScanlineConstIterator<InputImageType>;
InputLineIteratorType inLineIt(input, outputRegionForThread);
ImageScanlineConstIterator inLineIt(input, outputRegionForThread);

using OutputLineIteratorType = ImageScanlineIterator<OutputImageType>;
OutputLineIteratorType outLineIt(output, outputRegionForThread);
ImageScanlineIterator outLineIt(output, outputRegionForThread);

for (inLineIt.GoToBegin(); !inLineIt.IsAtEnd(); inLineIt.NextLine(), outLineIt.NextLine())
{
Expand Down Expand Up @@ -197,8 +195,7 @@ BinaryContourImageFilter<TInputImage, TOutputImage>::ThreadedIntegrateData(const
{
OutputImagePointer output = this->GetOutput();

using OutputLineIteratorType = ImageScanlineIterator<OutputImageType>;
OutputLineIteratorType outLineIt(output, outputRegionForThread);
ImageScanlineIterator outLineIt(output, outputRegionForThread);

OffsetValueType linecount = m_ForegroundLineMap.size();

Expand Down
Expand Up @@ -115,11 +115,9 @@ LabelContourImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
OutputImageType * output = this->GetOutput();
const InputImageType * input = this->GetInput();

using InputLineIteratorType = ImageScanlineConstIterator<InputImageType>;
InputLineIteratorType inLineIt(input, outputRegionForThread);
ImageScanlineConstIterator inLineIt(input, outputRegionForThread);

using OutputLineIteratorType = ImageScanlineIterator<OutputImageType>;
OutputLineIteratorType outLineIt(output, outputRegionForThread);
ImageScanlineIterator outLineIt(output, outputRegionForThread);

for (inLineIt.GoToBegin(); !inLineIt.IsAtEnd(); inLineIt.NextLine(), outLineIt.NextLine())
{
Expand Down Expand Up @@ -158,8 +156,7 @@ LabelContourImageFilter<TInputImage, TOutputImage>::ThreadedIntegrateData(
{
OutputImageType * output = this->GetOutput();

using OutputLineIteratorType = ImageScanlineIterator<OutputImageType>;
OutputLineIteratorType outLineIt(output, outputRegionForThread);
ImageScanlineIterator outLineIt(output, outputRegionForThread);

SizeValueType pixelcount = output->GetRequestedRegion().GetNumberOfPixels();
SizeValueType xsize = output->GetRequestedRegion().GetSize()[0];
Expand Down
Expand Up @@ -153,8 +153,8 @@ BinaryImageToLabelMapFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateD
const RegionType & outputRegionForThread)
{
const TInputImage * input = this->GetInput();
using InputLineIteratorType = ImageScanlineConstIterator<InputImageType>;
InputLineIteratorType inLineIt(input, outputRegionForThread);

ImageScanlineConstIterator inLineIt(input, outputRegionForThread);

WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread);
SizeValueType lineId = workUnitData.firstLine;
Expand Down
Expand Up @@ -102,11 +102,8 @@ ThresholdImageFilter<TImage>::DynamicThreadedGenerateData(const OutputImageRegio

// Define/declare an iterator that will walk the output region for this
// thread.
using InputIterator = ImageScanlineConstIterator<TImage>;
using OutputIterator = ImageScanlineIterator<TImage>;

InputIterator inIt(inputPtr, outputRegionForThread);
OutputIterator outIt(outputPtr, outputRegionForThread);
ImageScanlineConstIterator inIt(inputPtr, outputRegionForThread);
ImageScanlineIterator outIt(outputPtr, outputRegionForThread);

// Walk the regions; threshold each pixel
while (!outIt.IsAtEnd())
Expand Down
Expand Up @@ -166,8 +166,7 @@ void
ConnectedComponentImageFilter<TInputImage, TOutputImage, TMaskImage>::DynamicThreadedGenerateData(
const RegionType & outputRegionForThread)
{
using InputLineIteratorType = ImageScanlineConstIterator<InputImageType>;
InputLineIteratorType inLineIt(m_Input, outputRegionForThread);
ImageScanlineConstIterator inLineIt(m_Input, outputRegionForThread);

WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread);
SizeValueType lineId = workUnitData.firstLine;
Expand Down
27 changes: 7 additions & 20 deletions Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx
Expand Up @@ -141,9 +141,7 @@ SLICImageFilter<TInputImage, TOutputImage, TDistancePixel>::BeforeThreadedGenera
m_OldClusters.resize(numberOfClusters * numberOfClusterComponents);


using InputConstIteratorType = ImageScanlineConstIterator<InputImageType>;

InputConstIteratorType it(shrunkImage, shrunkImage->GetLargestPossibleRegion());
ImageScanlineConstIterator it(shrunkImage, shrunkImage->GetLargestPossibleRegion());

// Initialize cluster centers
size_t cnt = 0;
Expand Down Expand Up @@ -197,9 +195,6 @@ void
SLICImageFilter<TInputImage, TOutputImage, TDistancePixel>::ThreadedUpdateDistanceAndLabel(
const OutputImageRegionType & outputRegionForThread)
{
using InputConstIteratorType = ImageScanlineConstIterator<InputImageType>;
using DistanceIteratorType = ImageScanlineIterator<DistanceImageType>;

const InputImageType * inputImage = this->GetInput();
OutputImageType * outputImage = this->GetOutput();
const unsigned int numberOfComponents = inputImage->GetNumberOfComponentsPerPixel();
Expand Down Expand Up @@ -234,8 +229,8 @@ SLICImageFilter<TInputImage, TOutputImage, TDistancePixel>::ThreadedUpdateDistan

const size_t ln = localRegion.GetSize(0);

InputConstIteratorType inputIter(inputImage, localRegion);
DistanceIteratorType distanceIter(m_DistanceImage, localRegion);
ImageScanlineConstIterator inputIter(inputImage, localRegion);
ImageScanlineIterator distanceIter(m_DistanceImage, localRegion);


while (!inputIter.IsAtEnd())
Expand Down Expand Up @@ -275,15 +270,12 @@ SLICImageFilter<TInputImage, TOutputImage, TDistancePixel>::ThreadedUpdateCluste
const unsigned int numberOfComponents = inputImage->GetNumberOfComponentsPerPixel();
const unsigned int numberOfClusterComponents = numberOfComponents + ImageDimension;

using InputConstIteratorType = ImageScanlineConstIterator<InputImageType>;
using OutputIteratorType = ImageScanlineIterator<OutputImageType>;

UpdateClusterMap clusterMap;

itkDebugMacro("Estimating Centers");
// calculate new centers
OutputIteratorType itOut(outputImage, updateRegionForThread);
InputConstIteratorType itIn(inputImage, updateRegionForThread);
ImageScanlineIterator itOut(outputImage, updateRegionForThread);
ImageScanlineConstIterator itIn(inputImage, updateRegionForThread);
while (!itOut.IsAtEnd())
{
const size_t ln = updateRegionForThread.GetSize(0);
Expand Down Expand Up @@ -540,13 +532,8 @@ SLICImageFilter<TInputImage, TOutputImage, TDistancePixel>::SingleThreadedConnec
// a new label, otherwise it just gets the previously encountered
// label id.


using OutputIteratorType = ImageScanlineIterator<OutputImageType>;
OutputIteratorType outputIter(outputImage, outputImage->GetRequestedRegion());

using MarkerIteratorType = ImageScanlineIterator<MarkerImageType>;
MarkerIteratorType markerIter(m_MarkerImage, outputImage->GetRequestedRegion());

ImageScanlineIterator outputIter(outputImage, outputImage->GetRequestedRegion());
ImageScanlineIterator markerIter(m_MarkerImage, outputImage->GetRequestedRegion());

while (!markerIter.IsAtEnd())
{
Expand Down

0 comments on commit 788e558

Please sign in to comment.