[Insight-users] How to loop over all the pixels within the itk multithreaded framework?

Guang Yang samggyy at gmail.com
Tue Aug 10 09:31:40 EDT 2010


Hi there,

I've got a requirement to loop all the pixels within the itk multithreaded
framework:

    template<float>
    void
    CreateImage<float>::ThreadedGenerateData(const OutputImageRegionType&
outputRegionForThread, int threadId)
    {

      outputIterator = ImageRegionIterator<OutputImageType>(outImage,
outputRegionForThread); // Output is a 2D image

      pixelNum = 0;
      for ( outputIterator.GoToBegin(); !outputIterator.IsAtEnd();
++outputIterator)
      {
      // Some manipulations

      // Loop over all the pixels
      pixelNum++;

     }
  }

It is only working for single threaded program,

Then I try to use:

outIndex = outputIterator.GetIndex();
int pixel2D = sizeOfOutputImage[1]*outIndex[1] + outIndex[0]; // Change 2D
array to 1D index in order to loop all the pixels

inside the for loop above, but still not working properly. Any suggestions
would be appreciated. Thanks a lot.



Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100810/e7a8a165/attachment.htm>


More information about the Insight-users mailing list