34
34
ImageRandomCoordinateSampler<TInputImage>::GenerateData()
35
35
{
36
36
/* * Get handles to the input image, output sample container, and interpolator. */
37
- InputImageConstPointer inputImage = this ->GetInput ();
38
- typename ImageSampleContainerType::Pointer sampleContainer = this ->GetOutput ();
39
- typename InterpolatorType::Pointer interpolator = this ->GetModifiableInterpolator ();
37
+ const InputImageType & inputImage = elastix::Deref ( this ->GetInput () );
38
+ ImageSampleContainerType & sampleContainer = elastix::Deref ( this ->GetOutput () );
39
+ typename InterpolatorType::Pointer interpolator = this ->GetModifiableInterpolator ();
40
40
41
41
/* * Set up the interpolator. */
42
- interpolator->SetInputImage (inputImage); // only once?
42
+ interpolator->SetInputImage (& inputImage); // only once?
43
43
44
44
const auto croppedInputImageRegion = this ->GetCroppedInputImageRegion ();
45
45
@@ -57,7 +57,7 @@ ImageRandomCoordinateSampler<TInputImage>::GenerateData()
57
57
typename MaskType::ConstPointer mask = this ->GetMask ();
58
58
if (mask.IsNull () && Superclass::m_UseMultiThread)
59
59
{
60
- auto & samples = elastix::Deref ( sampleContainer) .CastToSTLContainer ();
60
+ auto & samples = sampleContainer.CastToSTLContainer ();
61
61
samples.resize (this ->Superclass ::m_NumberOfSamples);
62
62
63
63
/* * Clear the random number list. */
@@ -73,7 +73,7 @@ ImageRandomCoordinateSampler<TInputImage>::GenerateData()
73
73
m_RandomCoordinates.push_back (randomCIndex);
74
74
}
75
75
76
- m_OptionalUserData.emplace (m_RandomCoordinates, * inputImage, *interpolator, samples);
76
+ m_OptionalUserData.emplace (m_RandomCoordinates, inputImage, *interpolator, samples);
77
77
78
78
MultiThreaderBase & multiThreader = elastix::Deref (this ->ProcessObject ::GetMultiThreader ());
79
79
multiThreader.SetSingleMethod (&Self::ThreaderCallback, &*m_OptionalUserData);
@@ -82,18 +82,18 @@ ImageRandomCoordinateSampler<TInputImage>::GenerateData()
82
82
}
83
83
84
84
/* * Reserve memory for the output. */
85
- sampleContainer-> Reserve (this ->GetNumberOfSamples ());
85
+ sampleContainer. Reserve (this ->GetNumberOfSamples ());
86
86
87
87
/* * Setup an iterator over the output, which is of ImageSampleContainerType. */
88
88
typename ImageSampleContainerType::Iterator iter;
89
- typename ImageSampleContainerType::ConstIterator end = sampleContainer-> End ();
89
+ typename ImageSampleContainerType::ConstIterator end = sampleContainer. End ();
90
90
91
91
InputImageContinuousIndexType sampleContIndex;
92
92
/* * Fill the sample container. */
93
93
if (mask.IsNull ())
94
94
{
95
95
/* * Start looping over the sample container. */
96
- for (iter = sampleContainer-> Begin (); iter != end; ++iter)
96
+ for (iter = sampleContainer. Begin (); iter != end; ++iter)
97
97
{
98
98
/* * Make a reference to the current sample in the container. */
99
99
InputImagePointType & samplePoint = iter->Value ().m_ImageCoordinates ;
@@ -103,7 +103,7 @@ ImageRandomCoordinateSampler<TInputImage>::GenerateData()
103
103
this ->GenerateRandomCoordinate (smallestContIndex, largestContIndex, sampleContIndex);
104
104
105
105
/* * Convert to point */
106
- inputImage-> TransformContinuousIndexToPhysicalPoint (sampleContIndex, samplePoint);
106
+ inputImage. TransformContinuousIndexToPhysicalPoint (sampleContIndex, samplePoint);
107
107
108
108
/* * Compute the value at the continuous index. */
109
109
sampleValue = static_cast <ImageSampleValueType>(this ->m_Interpolator ->EvaluateAtContinuousIndex (sampleContIndex));
@@ -121,7 +121,7 @@ ImageRandomCoordinateSampler<TInputImage>::GenerateData()
121
121
unsigned long maximumNumberOfSamplesToTry = 10 * this ->GetNumberOfSamples ();
122
122
123
123
/* * Start looping over the sample container */
124
- for (iter = sampleContainer-> Begin (); iter != end; ++iter)
124
+ for (iter = sampleContainer. Begin (); iter != end; ++iter)
125
125
{
126
126
/* * Make a reference to the current sample in the container. */
127
127
InputImagePointType & samplePoint = iter->Value ().m_ImageCoordinates ;
@@ -135,17 +135,17 @@ ImageRandomCoordinateSampler<TInputImage>::GenerateData()
135
135
if (numberOfSamplesTried > maximumNumberOfSamplesToTry)
136
136
{
137
137
/* * Squeeze the sample container to the size that is still valid. */
138
- typename ImageSampleContainerType::iterator stlnow = sampleContainer-> begin ();
139
- typename ImageSampleContainerType::iterator stlend = sampleContainer-> end ();
138
+ typename ImageSampleContainerType::iterator stlnow = sampleContainer. begin ();
139
+ typename ImageSampleContainerType::iterator stlend = sampleContainer. end ();
140
140
stlnow += iter.Index ();
141
- sampleContainer-> erase (stlnow, stlend);
141
+ sampleContainer. erase (stlnow, stlend);
142
142
itkExceptionMacro (
143
143
<< " Could not find enough image samples within reasonable time. Probably the mask is too small" );
144
144
}
145
145
146
146
/* * Generate a point in the input image region. */
147
147
this ->GenerateRandomCoordinate (smallestContIndex, largestContIndex, sampleContIndex);
148
- inputImage-> TransformContinuousIndexToPhysicalPoint (sampleContIndex, samplePoint);
148
+ inputImage. TransformContinuousIndexToPhysicalPoint (sampleContIndex, samplePoint);
149
149
150
150
} while (!interpolator->IsInsideBuffer (sampleContIndex) || !mask->IsInsideInWorldSpace (samplePoint));
151
151
0 commit comments