Skip to content

Commit

Permalink
accelerating antsAtroposSegmentationImageFilter.hxx function GetPoste…
Browse files Browse the repository at this point in the history
…riorProbabilityImage using ITK ParallelizeImageRegion
  • Loading branch information
br-cpvc committed Dec 6, 2022
1 parent 74afcc5 commit 0ac02f6
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 0ac02f6

Please sign in to comment.