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

Matt McCormick matt.mccormick at kitware.com
Wed Aug 13 13:36:21 EDT 2014


Hi,

Yes, it is a bug.  Thank you for discussing the issue on the list and
for including a buildable example that clearly illustrates the issue.

Please review [1] this patch [2].

Thanks,
Matt

[1]http://insightsoftwareconsortium.github.io/ITKBarCamp-doc/CommunitySoftwareProcess/PerformAGerritReview/index.html

[2] http://review.source.kitware.com/#/c/16663/

On Wed, Aug 13, 2014 at 12:39 PM, Bradley Lowekamp
<blowekamp at mail.nih.gov> wrote:
> 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
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community



More information about the Community mailing list