Skip to content

Commit

Permalink
ENH: Improve progress for GradientMagnitudeRecursiveGaussianImageFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Jan 6, 2022
1 parent 6f23810 commit 6c32f95
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ GradientMagnitudeRecursiveGaussianImageFilter<TInputImage, TOutputImage>::Genera

typename TOutputImage::Pointer outputImage(this->GetOutput());

// Reset progress of internal filters to zero,
// otherwise progress starts from non-zero value the second time the filter is invoked.
m_DerivativeFilter->UpdateProgress(0.0);
for (unsigned int k = 0; k < ImageDimension - 1; ++k)
{
m_SmoothingFilters[k]->UpdateProgress(0.0);
}
m_SqrSpacingFilter->UpdateProgress(0.0);
m_SqrtFilter->UpdateProgress(0.0);

// Create a process accumulator for tracking the progress of this minipipeline
auto progress = ProgressAccumulator::New();
progress->SetMiniPipelineFilter(this);
Expand All @@ -208,13 +218,14 @@ GradientMagnitudeRecursiveGaussianImageFilter<TInputImage, TOutputImage>::Genera

m_DerivativeFilter->SetInput(inputImage);

const unsigned int numberOfFilterRuns = ImageDimension * ImageDimension;
const unsigned int numberOfFilterRuns = 1 + ImageDimension * (ImageDimension + 1);
progress->RegisterInternalFilter(m_DerivativeFilter, 1.0f / numberOfFilterRuns);

for (unsigned int k = 0; k < ImageDimension - 1; ++k)
{
progress->RegisterInternalFilter(m_SmoothingFilters[k], 1.0f / numberOfFilterRuns);
}
progress->RegisterInternalFilter(m_SqrSpacingFilter, 1.0f / numberOfFilterRuns);
progress->RegisterInternalFilter(m_SqrtFilter, 1.0f / numberOfFilterRuns);

for (unsigned int dim = 0; dim < ImageDimension; ++dim)
{
Expand Down

0 comments on commit 6c32f95

Please sign in to comment.