[Insight-users] Iterators and their directions

Luis Ibanez luis.ibanez at kitware.com
Tue Mar 17 19:19:03 EDT 2009



Hi Brady,


There is not one Iterator that will give you this behavior,

However, you can get the equivalent with a set of ShapeIterators.

Where each one of the iterators will do the equivalent of what
you have under every pair of for-loops.

You could then drive the set of four ShapeIterators in a common
while loop to iterate through the image, while at every location
you apply a customized Operators.

Please take a look at the ITK Software Guide

      http://www.itk.org/ItkSoftwareGuide.pdf

In particular to the chapter on "Image Iterators".

Take also a look at the Operator classes in Insight/Code/Common,
they will give you an idea on how to implement the local operation
on the neighborhood of every pixel.


    Regards,


        Luis



--------------------
Brady McCary wrote:
> insight-users,
> 
> I would like to have an iterator that has more than one increment
> direction. E.g., in 2D:
> 
> double A[M][N];
> 
> // Populate A
> 
> for(unsigned int i = 0; i < M; i++)
> for(unsigned int j = 0; j < N; j++)
> {
>     // Do something with the neighborhood of A[i][j]
> }
> 
> for(unsigned int i = 0; i < M; i++)
> for(unsigned int j = N-1; j >= 0; j--)
> {
>     // Do something with the neighborhood of A[i][j]
> }
> 
> for(unsigned int i = M-1; i >= 0; i--)
> for(unsigned int j = 0; j < N; j++)
> {
>     // Do something with the neighborhood of A[i][j]
> }
> 
> for(unsigned int i = M-1; i >= 0; i--)
> for(unsigned int j = N-1; j >= 0; j--)
> {
>     // Do something with the neighborhood of A[i][j]
> }
> 
> In an N dimensional array there will be 2^N iteration patterns. Is
> there such an iterator, or do I need to write my own?
> 
> Brady
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> 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-users
> 


More information about the Insight-users mailing list