Hi Brad,

Thank you for the suggestion!

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.
index[0] = rg.lrand32(1, size[0] - 2);
index[1] = rg.lrand32(1, size[1] - 2);
index[2] = rg.lrand32(1, size[2] - 2);

And I also turn off the boundary condition by:
it.NeedToUseBoundaryConditionOff();

Now with the same parameters, nbhditerator is around 4 seconds (vs direct
access 5.5 seconds)!

I will modify my code to take advantage of this!

Thank you!

Best,
yi



On Mon, May 13, 2013 at 11:34 AM, Bradley Lowekamp
<[email protected]>wrote:

> Hello,
>
> On May 13, 2013, at 11:03 AM, "Gao, Yi" <[email protected]> wrote:
> > 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.
>
>
> 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:
>
>
> http://www.itk.org/Doxygen/html/classitk_1_1ConstNeighborhoodIterator.html#a438cb0146b802b04a771a2461952cff8
>
> or you can change the region size you initialize the Iterator with.
>
> You can just use the operator<< to check what the iterator is doing.
>
> Also consider using a large type for the accumulation type, such as
> itk::NumericTraits<T>::AccumulatorType;
>
> And consider using std::accumulate(it.Begin(), it.End(), 0 )
>
> Brad
_______________________________________________
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://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://www.itk.org/mailman/listinfo/insight-developers

Reply via email to