Skip to content

Commit

Permalink
Merge pull request #1462 from br-cpvc/upstream_20221206_1415
Browse files Browse the repository at this point in the history
PERF: accelerating antsAtroposSegmentationImageFilter.hxx function GetPosteriorProbabilityImage using ITK ParallelizeImageRegion
  • Loading branch information
ntustison committed Dec 15, 2022
2 parents 74afcc5 + 0ac02f6 commit cdabb0d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ImageSegmentation/antsAtroposSegmentationImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1988,10 +1988,16 @@ AtroposSegmentationImageFilter<TInputImage, TMaskImage, TClassifiedImage>::GetPo
radius[d] = this->m_MRFRadius[d];
}

auto multiThreader = this->GetMultiThreader();
using RegionType = typename RealImageType::RegionType;
multiThreader->template ParallelizeImageRegion<ImageDimension>(
this->GetOutput()->GetRequestedRegion(),
[this, &radius, &c, &totalNumberOfClasses, &distancePriorProbabilityImage, &priorProbabilityImage, &sumPriorProbabilityImage, &smoothImages, &posteriorProbabilityImage](const RegionType & outputRegionForThread) {

ConstNeighborhoodIterator<ClassifiedImageType> ItO(
radius, this->GetOutput(), this->GetOutput()->GetRequestedRegion());
radius, this->GetOutput(), outputRegionForThread);
ImageRegionIterator<RealImageType> ItS(this->m_SumPosteriorProbabilityImage,
this->m_SumPosteriorProbabilityImage->GetRequestedRegion());
outputRegionForThread);
for (ItO.GoToBegin(), ItS.GoToBegin(); !ItO.IsAtEnd(); ++ItO, ++ItS)
{
if (!this->GetMaskImage() ||
Expand Down Expand Up @@ -2113,6 +2119,7 @@ AtroposSegmentationImageFilter<TInputImage, TMaskImage, TClassifiedImage>::GetPo
ItS.Set(ItS.Get() + posteriorProbability);
}
}
}, nullptr); // end ParallelizeImageRegion
if (!this->m_MinimizeMemoryUsage)
{
typedef ImageDuplicator<RealImageType> DuplicatorType;
Expand Down

0 comments on commit cdabb0d

Please sign in to comment.