diff --git a/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.h b/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.h index 346ac7b2a1e..b2329d432fd 100644 --- a/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.h +++ b/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.h @@ -20,7 +20,7 @@ #include "itkImageToImageFilter.h" #include "itkVectorImage.h" -#include "itkImageRegionConstIterator.h" +#include "itkImageScanlineIterator.h" #include namespace itk @@ -108,7 +108,7 @@ class ITK_TEMPLATE_EXPORT ComposeImageFilter : public ImageToImageFilter; + using InputIteratorType = ImageScanlineConstIterator; using InputIteratorContainerType = std::vector; }; } // namespace itk diff --git a/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx b/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx index 16f794c3d78..60a520f1786 100644 --- a/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx +++ b/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx @@ -112,7 +112,6 @@ ComposeImageFilter::DynamicThreadedGenerateData(const TotalProgressReporter progress(this, outputImage->GetRequestedRegion().GetNumberOfPixels()); - ImageRegionIterator oit(outputImage, outputRegionForThread); InputIteratorContainerType inputItContainer; inputItContainer.reserve(this->GetNumberOfIndexedInputs()); @@ -126,26 +125,36 @@ ComposeImageFilter::DynamicThreadedGenerateData(const OutputPixelType pix; NumericTraits::SetLength(pix, static_cast(this->GetNumberOfIndexedInputs())); - while (!oit.IsAtEnd()) + for (ImageScanlineIterator oit(outputImage, outputRegionForThread); !oit.IsAtEnd(); oit.NextLine()) { - if constexpr (std::is_same::ValueType>>::value) + while (!oit.IsAtEndOfLine()) { - oit.Set({ inputItContainer[0].Get(), inputItContainer[1].Get() }); - ++(inputItContainer[0]); - ++(inputItContainer[1]); - } - else - { - for (unsigned int i = 0; i < this->GetNumberOfInputs(); ++i) + if constexpr (std::is_same::ValueType>>::value) + { + oit.Set({ inputItContainer[0].Get(), inputItContainer[1].Get() }); + ++(inputItContainer[0]); + ++(inputItContainer[1]); + } + else { - pix[i] = static_cast::ValueType>(inputItContainer[i].Get()); - ++(inputItContainer[i]); + unsigned int i = 0; + for (auto & it : inputItContainer) + { + pix[i] = static_cast::ValueType>(it.Get()); + ++i; + ++it; + } + + oit.Set(pix); } - oit.Set(pix); + ++oit; + } + for (auto & it : inputItContainer) + { + it.NextLine(); } - ++oit; - progress.CompletedPixel(); + progress.Completed(outputRegionForThread.GetSize()[0]); } } } // end namespace itk