[Insight-users] Doubt regarding Iterators

Luis Ibanez luis.ibanez at kitware.com
Fri Apr 20 11:49:45 EDT 2007


Hi Raja,


    Please read the ITK Software Guide

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

    In particular Chapter 11 "Iterators"
    in pdf-pages 733-777


If you need to change the pixel values, you should use
a non-const iterator. In your case, you may want to use
the:

      ImageRegionIteratorWithIndex


Note the absence of "Const" in the name.


If you are visiting a specific slice, then you should
make sure that the Region that you provide is restricted
to that specific slice.

For example, in an image of size 512 x 256 x 768

if you want to visit all the pixels in slice Z=431

then you can set your region to have


    size = 512 x 256 x 1

and

    start index = 0 , 0, 431


You will find more details on the use of Iterators,
in the ITK Software Guide.



   Regards,


      Luis



-------------------------
Raja Yalamanchili wrote:
> Hi,
> 
> I have taken a 3D data,took a slice of it, done some processing on it 
> and again i want to write the modified data on 3D data.
> 
> So to go to a specific slice and write modified data i'm using 
> (IndexIt)"ImageRegionConstIteratorWithIndex" but using this iterator i'm 
> not able to set the value,so i ran another 
> iterator(labelIt)"ImageRegionIterator",but they are incrementing in a 
> different way.The code is:
> 
>  IndexIt(LabelImage,LabelImage->GetLargestPossibleRegion());(ImageRegionConstIteratorWithIndex)
> 
> labelIt(LabelImage,LabelImage->GetLargestPossibleRegion());(ImageRegionIterator)
> 
> LabelImage is a 3D volume data of char type;
> 
> 
> for(IndexIt.GoToBegin() , labelIt.GoToBegin() ; IndexIt.GetIndex()[2] < 
> 8 ;++IndexIt ,++labelIt ) ;
> 
> at the end i' getting  IndexIt ={0,0,8},  labelIt={0,4096, 28554296};
> 
> Can anyone tell me what is the difference between two iterators    and   
> any possible solution to modify my 3D data from slice.
> 
> 
> Thanks In Advance,
> 
> Raja Yalamanchili.(UH)
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list