[ITK] Problem using Size() and iterator with ImageToListSampleAdaptor

Bradley Lowekamp blowekamp at mail.nih.gov
Wed Aug 13 12:39:26 EDT 2014


Hello,

This sounds like a bug to me. Have you tried using an itk::Image of FixedArray to see if the same thins occurs?

Brad

On Aug 12, 2014, at 2:22 PM, Paulo Guilherme Freire <pauloguilhermefreire at gmail.com> wrote:

> Hello.
> 
> I've been having some troubles to understand the use of Size() and iterator when dealing with ImageToListSampleAdaptor.
> 
> Here's what I've been doing:
> 
> 1) Read N images (usually N = 3) and store them in an itk::VectorImage container.
> 
> 2) Set such itk::VectorImage as input for itk::ImageToListSampleAdaptor.
> 
> 3) Iterate over the list using a for loop (using the Size() method from the ListSample) and an iterator; in both cases, count how many times the loop was executed.
> 
> Here is my problem: when I iterate over the list using Size() I get a different value of iterations than when I use an iterator. For example, suppose I read three 3D (256 x 256 x 256) images. When I count the number of iterations using an iterator (say, ListSampleType::Iterator), I get 16777216 (which is precisely 256 times 256 times 256). However, when I count the number of iterations using a for loop (for(unsigned int = 0; i < ListSample->Size(); ++i)), I get 50331648 (which is precisely the result of 16777216 times 3). 
> 
> My question is: shouldn't the number of iterations be the same (irregardless of whether I use an iterator or a for loop)?
> 
> The code I've been using is attached to this email. I would really appreciate it if someone could help me solve this "mystery" :-)
> 
> Best regards,
> Paulo
> 
> 
> <CMakeLists.txt><bipUtils.h><CmdLine.h><ListSampleImages.cxx>_______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community




More information about the Community mailing list