diff --git a/Code/BasicFilters/otbVectorImageToImageListFilter.txx b/Code/BasicFilters/otbVectorImageToImageListFilter.txx index 4d4e52705e7b8a2da2fd681859e891b6bc3c5e20..be66823147fce3ca40eee03b7d4833966786d924 100644 --- a/Code/BasicFilters/otbVectorImageToImageListFilter.txx +++ b/Code/BasicFilters/otbVectorImageToImageListFilter.txx @@ -88,8 +88,6 @@ VectorImageToImageListFilter<TVectorImageType,TImageList> typedef itk::ImageRegionConstIteratorWithIndex<InputVectorImageType> InputIteratorType; typedef itk::ImageRegionIteratorWithIndex<OutputImageType> OutputIteratorType; - - InputIteratorType inputIt(inputPtr,inputPtr->GetRequestedRegion()); std::vector<OutputIteratorType> outputIteratorList; @@ -98,10 +96,13 @@ VectorImageToImageListFilter<TVectorImageType,TImageList> { outputListIt.Get()->SetBufferedRegion(outputListIt.Get()->GetRequestedRegion()); outputListIt.Get()->Allocate(); - outputIteratorList.push_back(OutputIteratorType(outputListIt.Get(),outputListIt.Get()->GetRequestedRegion())); - outputIteratorList.back().GoToBegin(); + OutputIteratorType tmpIt = OutputIteratorType(outputListIt.Get(),outputListIt.Get()->GetRequestedRegion()); + tmpIt.GoToBegin(); + outputIteratorList.push_back(tmpIt); } + InputIteratorType inputIt(inputPtr,outputPtr->GetNthElement(0)->GetRequestedRegion()); + inputIt.GoToBegin(); while(!inputIt.IsAtEnd()) {