From 0ac02f6f4475ce3d83f871d3437d512184b51cde Mon Sep 17 00:00:00 2001 From: "Christian P. V. Christoffersen" <88783438+br-cpvc@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:12:39 +0000 Subject: [PATCH] accelerating antsAtroposSegmentationImageFilter.hxx function GetPosteriorProbabilityImage using ITK ParallelizeImageRegion --- .../antsAtroposSegmentationImageFilter.hxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ImageSegmentation/antsAtroposSegmentationImageFilter.hxx b/ImageSegmentation/antsAtroposSegmentationImageFilter.hxx index 9610c83c2..05fcad10b 100644 --- a/ImageSegmentation/antsAtroposSegmentationImageFilter.hxx +++ b/ImageSegmentation/antsAtroposSegmentationImageFilter.hxx @@ -1988,10 +1988,16 @@ AtroposSegmentationImageFilter::GetPo radius[d] = this->m_MRFRadius[d]; } + auto multiThreader = this->GetMultiThreader(); + using RegionType = typename RealImageType::RegionType; + multiThreader->template ParallelizeImageRegion( + this->GetOutput()->GetRequestedRegion(), + [this, &radius, &c, &totalNumberOfClasses, &distancePriorProbabilityImage, &priorProbabilityImage, &sumPriorProbabilityImage, &smoothImages, &posteriorProbabilityImage](const RegionType & outputRegionForThread) { + ConstNeighborhoodIterator ItO( - radius, this->GetOutput(), this->GetOutput()->GetRequestedRegion()); + radius, this->GetOutput(), outputRegionForThread); ImageRegionIterator ItS(this->m_SumPosteriorProbabilityImage, - this->m_SumPosteriorProbabilityImage->GetRequestedRegion()); + outputRegionForThread); for (ItO.GoToBegin(), ItS.GoToBegin(); !ItO.IsAtEnd(); ++ItO, ++ItS) { if (!this->GetMaskImage() || @@ -2113,6 +2119,7 @@ AtroposSegmentationImageFilter::GetPo ItS.Set(ItS.Get() + posteriorProbability); } } + }, nullptr); // end ParallelizeImageRegion if (!this->m_MinimizeMemoryUsage) { typedef ImageDuplicator DuplicatorType;