Skip to content

Commit

Permalink
Merge pull request #4988 from blowekamp/fix_object_morphology_race
Browse files Browse the repository at this point in the history
BUG: Address race condition with threaded copying input to output
  • Loading branch information
blowekamp authored Nov 26, 2024
2 parents 4ef72c3 + 08bc946 commit 2816ed3
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,11 @@ ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::BeforeThreadedG
{
this->GetOutput()->FillBuffer(0);
}
}

template <typename TInputImage, typename TOutputImage, typename TKernel>
void
ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreadedGenerateData(
const OutputImageRegionType & outputRegionForThread)
{
ImageRegionConstIterator<TInputImage> iRegIter;
ImageRegionIterator<TOutputImage> oRegIter;
iRegIter = ImageRegionConstIterator<InputImageType>(this->GetInput(), outputRegionForThread);
oRegIter = ImageRegionIterator<OutputImageType>(this->GetOutput(), outputRegionForThread);
RegionType requestedRegion = this->GetOutput()->GetRequestedRegion();

auto iRegIter = ImageRegionConstIterator<InputImageType>(this->GetInput(), requestedRegion);
auto oRegIter = ImageRegionIterator<OutputImageType>(this->GetOutput(), requestedRegion);
/* Copy the input image to the output image - then only boundary pixels
* need to be changed in the output image */
while (!oRegIter.IsAtEnd())
Expand All @@ -121,7 +115,14 @@ ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreaded
++oRegIter;
++iRegIter;
}
}


template <typename TInputImage, typename TOutputImage, typename TKernel>
void
ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreadedGenerateData(
const OutputImageRegionType & outputRegionForThread)
{
// Find the boundary "faces"
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> fC;
typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType faceList =
Expand Down

0 comments on commit 2816ed3

Please sign in to comment.