<div dir="ltr"><div><div>Hi Kris,<br><br></div>My situation is actually to accelerate the sparse field level set in the RSS segmentation module in Slicer. Their the vertex of the segmenting surface is stored in a list. For each vertex i need to access its neighbors. They are not purely random and they are not guaranteed to be inside the inner region of the volume so i need the bound checking.<br>
<br></div><div>I will update with the list new progress on this asap i get anything new.<br><br>Thanks!<br><br>Best,<br></div><div>yi<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 13, 2013 at 3:12 PM, Kris Zygmunt <span dir="ltr"><<a href="mailto:krismz@sci.utah.edu" target="_blank">krismz@sci.utah.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If you were going to take Brad's approach with generating the list of sample points once, you could try using the Subsamplers in Numerics/Statistics to do the subsampling and then use the sorts available in itkStatisticsAlgorithm. You could start with itkUniformRandomSpatialNeighbo<u></u>rSubsampler to choose samples within a specified region of the image (see the corresponding test for an example). In this approach, each sample is already a NeighborhoodIterator. As Brad pointed out, it depends on what you're doing for this overhead to be useful, but I'd be curious to see how the timing works out and compars to what you've done already.<br>
<br>
I'm not sure whether this will be useful for you, but I mention it in case others are looking for ways to sample the images.<br>
-Kris<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Date: Mon, 13 May 2013 11:59:23 -0400<br>
From: Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>><br>
Subject: Re: [Insight-developers] fast image pixel access method<br>
To: <<a href="mailto:gaoyi.cn@gmail.com" target="_blank">gaoyi.cn@gmail.com</a>><br>
Cc: "<a href="mailto:Insight-developers@itk.org" target="_blank">Insight-developers@itk.org</a>" <<a href="mailto:Insight-developers@itk.org" target="_blank">Insight-developers@itk.org</a>>,<br>
"Williams, Norman K" <<a href="mailto:norman-k-williams@uiowa.edu" target="_blank">norman-k-williams@uiowa.edu</a>><br>
Message-ID: <<a href="mailto:8EF7C1BA-41CE-4F5D-B7AA-9F186F70FCE5@mail.nih.gov" target="_blank">8EF7C1BA-41CE-4F5D-B7AA-<u></u>9F186F70FCE5@mail.nih.gov</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<div><div class="h5"><br>
<br>
One more thought.<br>
<br>
If you are generating the list of sample points once and then using them multiple times to sample there are perhaps other interesting things which could be done.<br>
<br>
CPU likes to access memory in a linear fashion. Depending on your density, and the size of the neighborhood etc.. If you access your random points in a sequential fashion you may see benefits. That is 1) generate a sequential set of random points 2) sample the points in order. Step 2 should may see some benefits... Now under what conditions does it out weight the first?<br>
<br>
Brad<br>
<br>
On May 13, 2013, at 11:49 AM, "Gao, Yi" <<a href="mailto:gaoyi.cn@gmail.com" target="_blank">gaoyi.cn@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Brad,<br>
<br>
Thank you for the suggestion!<br>
<br>
Sorry in my previous code I had the mistake for randomly picking position for the center point. Now I changed it to be in the inner region.<br>
index[0] = rg.lrand32(1, size[0] - 2);<br>
index[1] = rg.lrand32(1, size[1] - 2);<br>
index[2] = rg.lrand32(1, size[2] - 2);<br>
<br>
And I also turn off the boundary condition by:<br>
it.<u></u>NeedToUseBoundaryConditionOff(<u></u>);<br>
<br>
Now with the same parameters, nbhditerator is around 4 seconds (vs direct access 5.5 seconds)!<br>
<br>
I will modify my code to take advantage of this!<br>
<br>
Thank you!<br>
<br>
Best,<br>
yi<br>
<br>
<br>
<br>
On Mon, May 13, 2013 at 11:34 AM, Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>> wrote:<br>
Hello,<br>
<br>
On May 13, 2013, at 11:03 AM, "Gao, Yi" <<a href="mailto:gaoyi.cn@gmail.com" target="_blank">gaoyi.cn@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
When using NeighborhoodIterator, i'm not sure if the boundary checking is automatically turned on. I guess if that is by default on, then there is not much speed gain with it.<br>
</blockquote>
<br>
<br>
Because the region you specify to the Iterator is on the boundary it will turn on the boundary checking. You can either turn off the condition:<br>
<br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1ConstNeighborhoodIterator.html#a438cb0146b802b04a771a2461952cff8" target="_blank">http://www.itk.org/Doxygen/<u></u>html/classitk_1_<u></u>1ConstNeighborhoodIterator.<u></u>html#<u></u>a438cb0146b802b04a771a2461952c<u></u>ff8</a><br>
<br>
or you can change the region size you initialize the Iterator with.<br>
<br>
You can just use the operator<< to check what the iterator is doing.<br>
<br>
Also consider using a large type for the accumulation type, such as itk::NumericTraits<T>::<u></u>AccumulatorType;<br>
<br>
And consider using std::accumulate(it.Begin(), it.End(), 0 )<br>
<br>
Brad<br>
<br>
</blockquote>
<br></div></div>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://www.itk.org/pipermail/insight-developers/attachments/20130513/8b26666b/attachment-0001.htm" target="_blank">http://www.itk.org/pipermail/<u></u>insight-developers/<u></u>attachments/20130513/8b26666b/<u></u>attachment-0001.htm</a>><br>
<br>
------------------------------<br>
<br>
______________________________<u></u>_________________<br>
Insight-developers mailing list<br>
<a href="mailto:Insight-developers@itk.org" target="_blank">Insight-developers@itk.org</a><br>
<a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/<u></u>listinfo/insight-developers</a><br>
<br>
<br>
End of Insight-developers Digest, Vol 109, Issue 13<br>
******************************<u></u>*********************<br>
</blockquote>
<br>
</blockquote></div><br></div>