Skip to content

Commit be145aa

Browse files
committed
BUG: Retain previous EigenToMeasureImageFilter
1 parent 3978d94 commit be145aa

File tree

2 files changed

+45
-23
lines changed

2 files changed

+45
-23
lines changed

include/itkEigenToMeasureImageFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ITK_TEMPLATE_EXPORT EigenToMeasureImageFilter : public ImageToImageFilter<
117117
ProcessPixel(const InputImagePixelType & pixel) = 0;
118118

119119
void
120-
DynamicThreadedGenerateData(const OutputImageRegionType & regionForThread) override;
120+
GenerateData() override;
121121
}; // end class
122122
} // namespace itk
123123

include/itkEigenToMeasureImageFilter.hxx

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,54 @@ namespace itk
2828

2929
template <typename TInputImage, typename TOutputImage>
3030
void
31-
EigenToMeasureImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(const OutputImageRegionType & regionForThread)
31+
EigenToMeasureImageFilter<TInputImage, TOutputImage>::GenerateData()
3232
{
3333
const InputImageType * inputPtr = this->GetInput(0);
3434
OutputImageType * outputPtr = this->GetOutput(0);
3535
const MaskSpatialObjectType * maskPointer = this->GetMask();
36-
typename InputImageType::PointType point;
37-
38-
/* Setup iterator */
39-
ImageRegionConstIteratorWithIndex<TInputImage> inputIt(inputPtr, regionForThread);
40-
ImageRegionIterator<OutputImageType> outputIt(outputPtr, regionForThread);
41-
42-
while (!inputIt.IsAtEnd())
43-
{
44-
inputPtr->TransformIndexToPhysicalPoint(inputIt.GetIndex(), point);
45-
if ((!maskPointer) || (maskPointer->IsInsideInObjectSpace(point)))
46-
{
47-
outputIt.Set(this->ProcessPixel(inputIt.Get()));
48-
}
49-
else
50-
{
51-
outputIt.Set(NumericTraits<OutputImagePixelType>::Zero);
52-
}
53-
54-
++inputIt;
55-
++outputIt;
56-
}
36+
37+
this->AllocateOutputs();
38+
39+
this->BeforeThreadedGenerateData();
40+
41+
const OutputImageRegionType requestedRegion( outputPtr->GetRequestedRegion() );
42+
43+
// Define the portion of the input to walk for this thread, using
44+
// the CallCopyOutputRegionToInputRegion method allows for the input
45+
// and output images to be different dimensions
46+
InputImageRegionType inputRegionForThread;
47+
this->CallCopyOutputRegionToInputRegion(inputRegionForThread, requestedRegion);
48+
49+
MultiThreaderBase::Pointer mt = this->GetMultiThreader();
50+
51+
mt->ParallelizeImageRegion<TInputImage::ImageDimension>(
52+
requestedRegion,
53+
[inputPtr, maskPointer, outputPtr, this](const OutputImageRegionType & region) {
54+
typename InputImageType::PointType point;
55+
56+
/* Setup iterator */
57+
ImageRegionConstIteratorWithIndex<TInputImage> inputIt(inputPtr, region);
58+
ImageRegionIterator<OutputImageType> outputIt(outputPtr, region);
59+
60+
while (!inputIt.IsAtEnd())
61+
{
62+
inputPtr->TransformIndexToPhysicalPoint(inputIt.GetIndex(), point);
63+
if ((!maskPointer) || (maskPointer->IsInsideInObjectSpace(point)))
64+
{
65+
outputIt.Set(this->ProcessPixel(inputIt.Get()));
66+
}
67+
else
68+
{
69+
outputIt.Set(NumericTraits<OutputImagePixelType>::Zero);
70+
}
71+
72+
++inputIt;
73+
++outputIt;
74+
}
75+
},
76+
nullptr);
77+
78+
this->AfterThreadedGenerateData();
5779
}
5880

5981
} // namespace itk

0 commit comments

Comments
 (0)