ParallelizeImageRegion with multiple images?

Hello,

I am updating my code to ITK 5.0. In particular I’d like to take advantage of the parallelization improvements. However, the examples I’ve seen so far, e.g. https://itk.org/ITKExamples/src/Core/Common/UseParallelizeImageRegion/Documentation.html only deal with parallelizing over one image. I need to parallelize over multiple images, of different types. What’s the recommended approach to do so? I don’t ParallelizeImageRegion() is really suitable for this?

(If you are interested, I would like to update this beast of a filter: https://github.com/spinicist/QUIT/blob/master/Source/Filters/ApplyAlgorithmFilter.hxx to be a bit more sensible)

Thanks.

1 Like

Replace this by something like this

this->GetMultiThreader()->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
this->GetMultiThreader()->template ParallelizeImageRegion<OutputImageDimension>(
    this->GetOutput()->GetRequestedRegion(),
    [this](const OutputImageRegionType & fullRegion)
      { this->DynamicThreadedGenerateData(outputRegionForThread); }, this);

And rename ThreadedGenerateData into DynamicThreadedGenerateData as per migration guide.

1 Like

Thanks @dzenanz, I think I have something working now. I missed the migration guide when googling earlier.