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

Guang Yang samggyy at gmail.com
Wed Aug 11 03:19:45 EDT 2010


Hi Jim,

When I try to output the image as a vector:

outputImageVector.put(pixelNum, pixelValue);

It gives me only the result processed by one thread. For example, my output
image is 100 by 100, then the output will only got 10 by 100 results, and
other pixels are zeros.

Also I found that the pixelNum is not loop from 0 to 9999 (because I've got
10000 pixels), it is only loop from something like 2000 to 3000.

May I ask how to gather all the results from different threads please?



Thanks,
Aaron



On Wed, Aug 11, 2010 at 2:22 AM, Jim Miller <millerjv at gmail.com> wrote:

> Why do you think your iterator is not working?
>
> The codes looks like it is iterating over the pixels assigned to that
> thread.
>
>
>
> On Aug 10, 2010, at 9:31 AM, Guang Yang <samggyy at gmail.com> wrote:
>
> > 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
> >
> >
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.html
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100811/975da35a/attachment.htm>


More information about the Insight-users mailing list