[prev in list] [next in list] [prev in thread] [next in thread]
List: insight-users
Subject: Re: [ITK-users] MultiThreading, ImageRegionIterator crash
From: Nicolas Courtial <nicolas.courtial () univ-rennes1 ! fr>
Date: 2017-07-18 14:22:15
Message-ID: a9279150-6183-1cd0-5acc-7bee416c2936 () univ-rennes1 ! fr
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi everyone,
I'm really sorry I haven't given any news since your answer. I had to
change my plans to rush other problems I had to deal with.
Anyway, yesterday I've had the occasion to think about everything once
from the start, and.... Well, it has driven to the classical "Oh dear,
how could I miss that".
Anyway, the solution was within the question:
remindiner: "e/verything is correct, but the index, for which it's
completly crazy ([156245468,0,156245468] or something approching)."/
During my algorithm, I needed to create an image to store energy levels.
I had for that created a dedicated module.
That one was incomplete, and wasn't correclty setting the start index of
the image's region.
Sorry again about that, and thanks for your advices!
Le 07/06/2017 à 15:34, Dženan ZukiÄ a écrit :
> 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@univ-rennes1.fr
> <mailto:nicolas.courtial@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 <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> <http://www.kitware.com/opensource/opensource.html>
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
> <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 <http://www.itk.org/Wiki/ITK_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
> <http://public.kitware.com/mailman/listinfo/insight-users>
>
>
>
>
> ------------------------------------------------------------------------
> Logo AVG <http://www.avg.com/internet-security>
>
> Cet email a fait l'objet d'une analyse antivirus par le logiciel
> antivirus AVG.
> www.avg.com <http://www.avg.com/internet-security>
>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
[Attachment #5 (text/html)]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi everyone,<br>
<br>
I'm really sorry I haven't given any news since your answer. I had
to change my plans to rush other problems I had to deal with.<br>
Anyway, yesterday I've had the occasion to think about everything
once from the start, and.... Well, it has driven to the classical
"Oh dear, how could I miss that".<br>
<br>
Anyway, the solution was within the question:<br>
remindiner: "e<i>verything is correct, but the index, for which it's
completly crazy ([156245468,0,156245468] or something
approching)."</i><br>
<br>
During my algorithm, I needed to create an image to store energy
levels. I had for that created a dedicated module.<br>
That one was incomplete, and wasn't correclty setting the start
index of the image's region.<br>
<br>
Sorry again about that, and thanks for your advices!<br>
<br>
<br>
<div class="moz-cite-prefix">Le 07/06/2017 à 15:34, Dženan Zukić a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CAPf2UMTfPRJQ2Yxbj4C7N0nmhdU1ivqp0AM9xzseRNrDBnkLCA@mail.gmail.com">
<div dir="ltr">
<div class="gmail_default"
style="font-family:verdana,sans-serif;font-size:small">Hi
Nicolas,</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;font-size:small">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 href="http://sscce.org/"
moz-do-not-send="true">a runnable example</a>?</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;font-size:small">
<div dir="ltr">
<div class="gmail_default"
style="font-family:verdana,sans-serif;font-size:small"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif;font-size:small">Regards,</div>
<div class="gmail_default"><font face="verdana, sans-serif">Dženan
Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro,
N.C.)</font></div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Jun 7, 2017 at 5:46 AM, Nicolas
Courtial <span dir="ltr"><<a
href="mailto:nicolas.courtial@univ-rennes1.fr"
target="_blank" \
moz-do-not-send="true">nicolas.courtial@univ-rennes1.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> Hello everyone,<br>
<br>
I'm quite new in ITK world, and I'm currently doing few
experiences in order to learn its logic.<br>
<br>
After few easy exercices, I'm now at a step I want to
multithread a method.<br>
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.<br>
<br>
I'm facing an issue at the moment, and I can't figure why,
and how to solve it.<br>
<br>
My filter works with<br>
<ul>
<li>One 3D InputImage (of any pixel type)<br>
</li>
<li>Two "tool" 3D images, respectively of float and
unsigned char pixel types</li>
</ul>
<p>From what I read, I've understood there are two main
ways of multithreading:</p>
<ul>
<li>The old fashioned one using
BeforeThreadedGenerateData/<wbr>ThreadedGenerateData/<wbr>AfterThreadedGenerateData</li>
<li>the one using itk::DomainThreader member.</li>
</ul>
<p>As I'm a bit old school, I used the first option.</p>
My problem remains here: (I changed my variables' name to
make it clearer)<br>
<br>
ThreadedComputation(const OutputImageRegionType
&outputRegionForThread, ThreadIdType threadId) {<br>
itk::ProgressReporter progress(this, threadId,
outputRegionForThread.<wbr>GetNumberOfPixels());<br>
typename TOutputImage::Pointer image =
this->GetOutput(0);<br>
<br>
itk::ImageRegionIterator< TOutputImage >
imgIt(image, outputRegionForThread);<br>
itk::ImageRegionIterator< FloatImageType>
floatIt (m_MyFloatImage, outputRegionForThread);<br>
....<br>
<br>
When creating the floatIt iterator, I have a crash. Using
a try catch block, the issue is due to out of bound
region.<br>
Everything is correct, but the index, for which it's
completly crazy ([156245468,0,156245468] or something
approching).<br>
<br>
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.<br>
<br>
Thanks all,<br>
<br>
Nicolas Courtial<br>
<br>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
</div>
<br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com"
rel="noreferrer" target="_blank" \
moz-do-not-send="true">www.kitware.com</a><br> <br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html"
rel="noreferrer" target="_blank" \
moz-do-not-send="true">http://www.kitware.com/<wbr>opensource/opensource.html</a><br> \
<br> Kitware offers ITK Training Courses, for more information
visit:<br>
<a href="http://www.kitware.com/products/protraining.php"
rel="noreferrer" target="_blank" \
moz-do-not-send="true">http://www.kitware.com/<wbr>products/protraining.php</a><br> \
<br> Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer"
target="_blank" \
moz-do-not-send="true">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br> <br>
Follow this link to subscribe/unsubscribe:<br>
<a
href="http://public.kitware.com/mailman/listinfo/insight-users"
rel="noreferrer" target="_blank" \
moz-do-not-send="true">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2">
<br>
<br>
<hr style="border:none; color:#909090; background-color:#B0B0B0;
height: 1px; width: 99%;">
<table style="border-collapse:collapse;border:none;">
<tbody>
<tr>
<td style="border:none;padding:0px 15px 0px 8px"> <a
href="http://www.avg.com/internet-security"
moz-do-not-send="true"> <img
src="http://static.avast.com/emails/avg-mail-stamp.png"
alt="Logo AVG" moz-do-not-send="true" border="0"> </a>
</td>
<td>
<p style="color:#3d4d5a;
font-family:"Calibri","Verdana","Arial","Helvetica";
font-size:12pt;"> Cet email a fait l'objet d'une
analyse antivirus par le logiciel antivirus AVG.
<br>
<a href="http://www.avg.com/internet-security"
moz-do-not-send="true">www.avg.com</a> </p>
</td>
</tr>
</tbody>
</table>
<br>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
height="1" moz-do-not-send="true"> </a></div>
</blockquote>
<br>
</body>
</html>
_____________________________________
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic