Skip to content

Commit f794baa

Browse files
Jon Haitz Legarretadzenanz
authored andcommitted
BUG: Fix test errors stemming from the new multi-threading mechanism.
Fix errors stemming from the use of the new `itk::MultiThreaderBase` class for multi-threading. The solution adopted in this patch set was based on the discussion in: http://review.source.kitware.com/#/c/23434/
1 parent 98f2f2b commit f794baa

File tree

4 files changed

+6
-20
lines changed

4 files changed

+6
-20
lines changed

include/itkCoocurrenceTextureFeaturesImageFilter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter
224224
/** This method causes the filter to generate its output. */
225225
void BeforeThreadedGenerateData() override;
226226
void AfterThreadedGenerateData() override;
227-
void ThreadedGenerateData(const OutputRegionType & outputRegionForThread,
228-
ThreadIdType threadId) override;
227+
void DynamicThreadedGenerateData( const OutputRegionType & outputRegionForThread ) override;
229228
void GenerateOutputInformation() override;
230229

231230
private:

include/itkCoocurrenceTextureFeaturesImageFilter.hxx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ CoocurrenceTextureFeaturesImageFilter< TInputImage, TOutputImage, TMaskImage>
6868
this->m_NeighborhoodRadius = nhood.GetRadius( );
6969

7070
this->m_Normalize = false;
71+
this->DynamicMultiThreadingOn();
7172
}
7273

7374
template<typename TInputImage, typename TOutputImage, typename TMaskImage>
@@ -128,16 +129,11 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
128129
template<typename TInputImage, typename TOutputImage, typename TMaskImage>
129130
void
130131
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
131-
::ThreadedGenerateData(const OutputRegionType & outputRegionForThread,
132-
ThreadIdType threadId)
132+
::DynamicThreadedGenerateData( const OutputRegionType & outputRegionForThread )
133133
{
134134
// Recuperation of the different inputs/outputs
135135
OutputImageType* outputPtr = this->GetOutput();
136136

137-
ProgressReporter progress( this,
138-
threadId,
139-
outputRegionForThread.GetNumberOfPixels() );
140-
141137
// Creation of the output pixel type
142138
typename TOutputImage::PixelType outputPixel;
143139
NumericTraits<typename TOutputImage::PixelType>::SetLength(outputPixel, outputPtr->GetNumberOfComponentsPerPixel());
@@ -181,7 +177,6 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
181177
{
182178
outputPixel.Fill(0);
183179
outputIt.Set(outputPixel);
184-
progress.CompletedPixel();
185180
++inputNIt;
186181
++outputIt;
187182
continue;
@@ -237,7 +232,6 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
237232
this->ComputeFeatures( hist, totalNumberOfFreq, outputPixel);
238233
outputIt.Set(outputPixel);
239234

240-
progress.CompletedPixel();
241235
++inputNIt;
242236
++outputIt;
243237
}

include/itkRunLengthTextureFeaturesImageFilter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ class ITK_TEMPLATE_EXPORT RunLengthTextureFeaturesImageFilter
246246
/** This method causes the filter to generate its output. */
247247
void BeforeThreadedGenerateData() override;
248248
void AfterThreadedGenerateData() override;
249-
void ThreadedGenerateData(const OutputRegionType & outputRegionForThread,
250-
ThreadIdType threadId) override;
249+
void DynamicThreadedGenerateData( const OutputRegionType & outputRegionForThread ) override;
251250
void GenerateOutputInformation() override;
252251

253252
private:

include/itkRunLengthTextureFeaturesImageFilter.hxx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ RunLengthTextureFeaturesImageFilter< TInputImage, TOutputImage, TMaskImage>
6969
NeighborhoodType nhood;
7070
nhood.SetRadius( 2 );
7171
this->m_NeighborhoodRadius = nhood.GetRadius( );
72+
this->DynamicMultiThreadingOn();
7273
}
7374

7475
template<typename TInputImage, typename TOutputImage, typename TMaskImage>
@@ -132,16 +133,11 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
132133
template<typename TInputImage, typename TOutputImage, typename TMaskImage>
133134
void
134135
RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
135-
::ThreadedGenerateData(const OutputRegionType & outputRegionForThread,
136-
ThreadIdType threadId)
136+
::DynamicThreadedGenerateData( const OutputRegionType & outputRegionForThread )
137137
{
138138
// Get the inputs/outputs
139139
TOutputImage * outputPtr = this->GetOutput();
140140

141-
ProgressReporter progress( this,
142-
threadId,
143-
outputRegionForThread.GetNumberOfPixels() );
144-
145141
// Creation of the output pixel type
146142
typename TOutputImage::PixelType outputPixel;
147143
NumericTraits<typename TOutputImage::PixelType>::SetLength(outputPixel, outputPtr->GetNumberOfComponentsPerPixel());
@@ -208,7 +204,6 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
208204
{
209205
outputPixel.Fill(0);
210206
outputIt.Set(outputPixel);
211-
progress.CompletedPixel();
212207
++inputNIt;
213208
++outputIt;
214209
continue;
@@ -285,7 +280,6 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage, TMaskImage>
285280
this->ComputeFeatures( histogram, totalNumberOfRuns, outputPixel);
286281
outputIt.Set(outputPixel);
287282

288-
progress.CompletedPixel();
289283
++inputNIt;
290284
++outputIt;
291285
}

0 commit comments

Comments
 (0)