Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions Modules/Core/Common/include/itkImageAlgorithm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#define itkImageAlgorithm_hxx

#include "itkArray.h"
#include "itkImageRegionIterator.h"
#include "itkImageScanlineIterator.h"
#include "itkImageRegionRange.h"

#include <array>

Expand All @@ -35,33 +34,17 @@ ImageAlgorithm::DispatchedCopy(const InputImageType * inIm
const typename OutputImageType::RegionType & outRegion,
FalseType)
{
if (inRegion.GetSize()[0] == outRegion.GetSize()[0])
{
itk::ImageScanlineConstIterator it(inImage, inRegion);
itk::ImageScanlineIterator ot(outImage, outRegion);
ImageRegionRange<OutputImageType> outputRange(*outImage, outRegion);

while (!it.IsAtEnd())
{
while (!it.IsAtEndOfLine())
{
ot.Set(static_cast<typename OutputImageType::PixelType>(it.Get()));
++ot;
++it;
}
ot.NextLine();
it.NextLine();
}
return;
}
using InputPixelType = typename InputImageType::PixelType;
using OutputPixelType = typename OutputImageType::PixelType;

itk::ImageRegionConstIterator<InputImageType> it(inImage, inRegion);
itk::ImageRegionIterator<OutputImageType> ot(outImage, outRegion);
auto outputIt = outputRange.begin();

while (!it.IsAtEnd())
for (const InputPixelType & inputPixel : ImageRegionRange<const InputImageType>(*inImage, inRegion))
{
ot.Set(static_cast<typename OutputImageType::PixelType>(it.Get()));
++ot;
++it;
*outputIt = static_cast<OutputPixelType>(inputPixel);
++outputIt;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "itkObjectFactory.h"
#include "itkTotalProgressReporter.h"
#include "itkImageAlgorithm.h"
#include "itkImageScanlineIterator.h"

namespace itk
{
Expand Down
Loading