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
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@ class ITK_TEMPLATE_EXPORT ContourExtractor2DImageFilter
using RegionIndexRange = ImageRegionIndexRange<InputImageType::ImageDimension>;
using RegionRange = ImageRegionRange<InputImageType>;
using RegionConstRange = ImageRegionRange<const InputImageType>;
using RegionIterator = ImageRegionIterator<InputImageType>;
using RegionConstIterator = ImageRegionConstIterator<InputImageType>;

#ifndef ITK_FUTURE_LEGACY_REMOVE
using RegionIterator ITK_FUTURE_DEPRECATED("Please use `itk::ImageRegionIterator<TImage>` directly!") =
ImageRegionIterator<InputImageType>;
using RegionConstIterator ITK_FUTURE_DEPRECATED("Please use `itk::ImageRegionConstIterator<TImage>` directly!") =
ImageRegionConstIterator<InputImageType>;
#endif

/** Control the orientation of the contours with reference to the image
* gradient. (See class documentation.) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "itkMultiThreaderBase.h"
#include "itkShapedImageNeighborhoodRange.h"
#include "itkTotalProgressReporter.h"
#include "itkImageRegionConstIteratorWithIndex.h"

namespace itk
{
Expand Down Expand Up @@ -347,15 +348,16 @@ ContourExtractor2DImageFilter<TInputImage>::GenerateDataForLabels()
{
labelBoundingBoxes[label] = BoundingBoxType{ right_bot, left_top };
}
// We use RegionConstIterator here instead of RegionRange because we want access to the GetIndex() method.
RegionConstIterator inputIt{ input, inputRegion };
for (inputIt.GoToBegin(); !inputIt.IsAtEnd(); ++inputIt)
// We use ImageRegionConstIteratorWithIndex here instead of RegionRange because we want access to the GetIndex()
// method.
for (ImageRegionConstIteratorWithIndex<TInputImage> inputIt{ input, inputRegion }; !inputIt.IsAtEnd(); ++inputIt)
{
const auto & index = inputIt.GetIndex();
BoundingBoxType & bbox = labelBoundingBoxes[inputIt.Get()];
bbox.min[0] = std::min(bbox.min[0], inputIt.ComputeIndex()[0]);
bbox.min[1] = std::min(bbox.min[1], inputIt.ComputeIndex()[1]);
bbox.max[0] = std::max(bbox.max[0], inputIt.ComputeIndex()[0]);
bbox.max[1] = std::max(bbox.max[1], inputIt.ComputeIndex()[1]);
bbox.min[0] = std::min(bbox.min[0], index[0]);
bbox.min[1] = std::min(bbox.min[1], index[1]);
bbox.max[0] = std::max(bbox.max[0], index[0]);
bbox.max[1] = std::max(bbox.max[1], index[1]);
}
// Build the extended regions from the bounding boxes
for (const InputPixelType label : allLabels)
Expand Down
Loading