[Insight-developers] fast image pixel access method

Gao, Yi gaoyi.cn at gmail.com
Mon May 13 11:49:34 EDT 2013


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
<blowekamp at mail.nih.gov>wrote:

> Hello,
>
> On May 13, 2013, at 11:03 AM, "Gao, Yi" <gaoyi.cn at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20130513/00097483/attachment.htm>


More information about the Insight-developers mailing list