[ITK-users] MultiThreading, ImageRegionIterator crash

Dženan Zukić dzenanz at gmail.com
Wed Jun 7 09:34:38 EDT 2017


Hi Nicolas,

ThreadedComputation should be called ThreadedGenerateData, otherwise the
code looks OK. If you overrode AllocateOutputs(), then you might not have
allocated the output (assuming index is wrong for imgIt). Can you provide a
runnable example <http://sscce.org/>?

Regards,
Dženan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)

On Wed, Jun 7, 2017 at 5:46 AM, Nicolas Courtial <
nicolas.courtial at univ-rennes1.fr> wrote:

> Hello everyone,
>
> I'm quite new in ITK world, and I'm currently doing few experiences in
> order to learn its logic.
>
> After few easy exercices, I'm now at a step I want to multithread a method.
> As I did in the past, I've been reading the ITK classes to get
> "inspiration", and e- mails from here in case of troubles.
>
> I'm facing an issue at the moment, and I can't figure why, and how to
> solve it.
>
> My filter works with
>
>    - One 3D InputImage (of any pixel type)
>    - Two "tool" 3D images, respectively of float and unsigned char pixel
>    types
>
> From what I read, I've understood there are two main ways of
> multithreading:
>
>    - The old fashioned one using BeforeThreadedGenerateData/
>    ThreadedGenerateData/AfterThreadedGenerateData
>    - the one using itk::DomainThreader member.
>
> As I'm a bit old school, I used the first option.
> My problem remains here: (I changed my variables' name to make it clearer)
>
> ThreadedComputation(const OutputImageRegionType &outputRegionForThread,
> ThreadIdType threadId) {
>         itk::ProgressReporter progress(this, threadId,
> outputRegionForThread.GetNumberOfPixels());
>         typename TOutputImage::Pointer image = this->GetOutput(0);
>
>         itk::ImageRegionIterator< TOutputImage > imgIt(image,
> outputRegionForThread);
>         itk::ImageRegionIterator< FloatImageType> floatIt (m_MyFloatImage,
> outputRegionForThread);
>     ....
>
> When creating the floatIt iterator, I have a crash. Using a try catch
> block, the issue is due to out of bound region.
> Everything is correct, but the index, for which it's completly crazy
> ([156245468,0,156245468] or something approching).
>
> I've tried different options to solve this, but rather than doing
> witchcraft and at some point getting something working, I'd prefer to
> improve my understanding thanks to your expertise.
>
> Thanks all,
>
> Nicolas Courtial
>
>
>
>
>
> _____________________________________
> 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.php
>
> 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://public.kitware.com/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170607/f01f896a/attachment.html>


More information about the Insight-users mailing list