[Insight-users] Iterators: PROBLEM

Sergiy Volkovych volkovych at gmail.com
Sat Aug 7 01:16:48 EDT 2010


I think the problem appears when the program tries to increment one of the
iterators.
Try to replace the "for" line to this:

for (DskIt.GoToBegin(), DFltIt.GoToBegin(),
DSubIt.GoToBegin();!DskIt.IsAtEnd() && !DFltIt.IsAtEnd() &&
!DSubIt.IsAtEnd(); ++DskIt, ++DFltIt, ++DSubIt)

If it doesn't go to the internal part of the loop at all, it means that one
of your images is empty (the region wasn't allocated properly). You may
identify which iterator creates a problem by:

DskIt.GoToBegin();
if (DskIt.IsAtEnd())
  std::cerr << "Not ok ;-("<< std::endl;

If the problem appeared due to the manually created image Dsk, try to
allocate it with this lines:

ImageType::Pointer Dsk = ImageType::New(); 
Dsk->SetRegions(DFlt->GetLargestPossibleRegion()); 
Dsk->Allocate();

But be aware that DFlt and DSub images should already have been filled by
the values before doing it.

Also you may initialize iterators based on the LargestPossibleRegion:

IteratorType DskIt (Dsk, Dsk->GetLargestPossibleRegion()); 
ConstIteratorType DFltIt (DFlt, DFlt->GetLargestPossibleRegion()); 
ConstIteratorType DSubIt (DSub, DSub->GetLargestPossibleRegion()); 

If it still doesn't work, please, place the larger part of code (I want to
see how all images are obtained to be sure that you haven't errors in the
other part of code).

Sergiy.
-- 
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/Iterators-PROBLEM-tp5381369p5383008.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list