@@ -28,32 +28,54 @@ namespace itk
28
28
29
29
template <typename TInputImage, typename TOutputImage>
30
30
void
31
- EigenToMeasureImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData( const OutputImageRegionType & regionForThread )
31
+ EigenToMeasureImageFilter<TInputImage, TOutputImage>::GenerateData( )
32
32
{
33
33
const InputImageType * inputPtr = this ->GetInput (0 );
34
34
OutputImageType * outputPtr = this ->GetOutput (0 );
35
35
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 ();
57
79
}
58
80
59
81
} // namespace itk
0 commit comments