[ITK] Problem using Size() and iterator with ImageToListSampleAdaptor
Paulo Guilherme Freire
pauloguilhermefreire at gmail.com
Tue Aug 12 15:22:25 EDT 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140812/7e846bf8/attachment-0001.html>
-------------- next part --------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET( ProgramName "list_sample" )
PROJECT( ${ProgramName} )
FIND_PACKAGE (ITK REQUIRED)
IF (ITK_FOUND)
INCLUDE( ${USE_ITK_FILE} )
ENDIF(ITK_FOUND)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
)
SET( SRCS
)
ADD_EXECUTABLE( ${ProgramName}
ListSampleImages.cxx
${SRCS}
)
LINK_DIRECTORIES(
${PROJECT_BINARY_DIR}/lib
)
TARGET_LINK_LIBRARIES( ${ProgramName}
${ITK_LIBRARIES}
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bipUtils.h
Type: text/x-chdr
Size: 20020 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20140812/7e846bf8/attachment-0002.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CmdLine.h
Type: text/x-chdr
Size: 10610 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20140812/7e846bf8/attachment-0003.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ListSampleImages.cxx
Type: text/x-c++src
Size: 2649 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20140812/7e846bf8/attachment-0001.cxx>
More information about the Community
mailing list