[Insight-developers] problem with iterator
Luis Ibanez
luis.ibanez at kitware.com
Sat Nov 20 14:00:03 EST 2010
Hi Martin,
Please see comments below:
On Thu, Nov 18, 2010 at 10:37 AM, Martin Waitzbauer <mazzok at gmx.at> wrote:
> Hi there, i think i have aproblem with understanding the iterators
> orrectly
>
> im oading a 3d dataset with 256(X)x256(Y)x124(Z)
>
> I wanted to check if i was understanding the iterator behavior correctly by
> iterating throught al the slices
> this can be done with
> InputIteratorType it(input,input->GetLargestPossibleRegion());
>
> since i want to acces the slies individually i tried
> InputImageType::RegionType reg;
> InputImageType::RegionType::SizeType size;
> InputImageType::RegionType::IndexType index;
> size[0] = 100;
> size[1] = 100;
>
You are missing to initialize: size[2]
These two variables will contain garbage
from memory and will mislead your
interpretation of the iterator behavior....
> index[0] = 0;
> index[1] = 0;
>
for(int j =0; j < Z_Depth;j++){
> index[2] = j;
> reg.SetSize(size);
> reg.SetIndex(index);
> InputIteratorType it(input,reg);
> OutputIteratorType ot(output,reg);
> for(it.GoToBegin();!it.IsAtEnd();++it){
> ot.Set(it.Get());
> ot++;
> }
> }
>
>
You could do this easier with
A) The itkImageSliceIteratorWithIndex
or with
B) The itkRegionOfInterestImageFilter
> so i wanted to cut out a 100x100 pieces beginning from (0,0) at each slice,
> and copy it to the output iterator
> visual studio will give me an error on the initialitaion of
> InputIteratorType it(input,reg);
> I couldnt find a way how to instantiate a 'null' InputIteraottype and fill
> if with the desired Region!
> is there a way like the above that i can adress slice-individually
> iterators?
>
>
Yes,
Use the
The itkImageSliceIteratorWithIndex
http://www.itk.org/Doxygen/html/classitk_1_1ImageSliceConstIteratorWithIndex.html
Regards,
Luis
> Thanks alot
> M
> --
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
> _______________________________________________
> 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.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-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20101120/b42d839f/attachment.htm>
More information about the Insight-developers
mailing list