18 #ifndef __otbVectorImageToImageListFilter_txx
19 #define __otbVectorImageToImageListFilter_txx
31 template <
class TVectorImageType,
class TImageList>
41 if (outputPtr->Size() != inputPtr->GetNumberOfComponentsPerPixel())
45 for (
unsigned int i = 0; i < inputPtr->GetNumberOfComponentsPerPixel(); ++i)
47 typename OutputImageType::Pointer tmpImagePtr = OutputImageType::New();
48 this->AddOutput(tmpImagePtr);
49 outputPtr->PushBack(tmpImagePtr);
52 for (
unsigned int i = 0; i < inputPtr->GetNumberOfComponentsPerPixel(); ++i)
54 typename OutputImageType::Pointer tmpImagePtr = outputPtr->GetNthElement(i);
55 tmpImagePtr->CopyInformation(inputPtr);
56 tmpImagePtr->SetLargestPossibleRegion(inputPtr->GetLargestPossibleRegion());
57 tmpImagePtr->SetRequestedRegion(inputPtr->GetLargestPossibleRegion());
62 template <
class TVectorImageType,
class TImageList>
72 if (outputPtr->Size() > 0)
74 inputPtr->SetRequestedRegion(outputPtr->GetNthElement(0)->GetRequestedRegion());
81 template <
class TVectorImageType,
class TImageList>
92 std::vector<OutputIteratorType> outputIteratorList;
94 typename OutputImageListType::ConstIterator outputListIt = outputPtr->
Begin();
95 for (; outputListIt != outputPtr->End(); ++outputListIt)
97 outputListIt.
Get()->SetBufferedRegion(outputListIt.Get()->GetRequestedRegion());
98 outputListIt.Get()->Allocate();
99 OutputIteratorType tmpIt = OutputIteratorType(outputListIt.Get(), outputListIt.Get()->GetRequestedRegion());
101 outputIteratorList.push_back(tmpIt);
104 InputIteratorType inputIt(inputPtr, outputPtr->GetNthElement(0)->GetRequestedRegion());
106 itk::ProgressReporter progress(
this, 0, outputPtr->GetNthElement(0)->GetRequestedRegion().GetNumberOfPixels());
109 while (!inputIt.IsAtEnd())
111 unsigned int counter = 0;
112 for (
typename std::vector<OutputIteratorType>::iterator it = outputIteratorList.begin();
113 it != outputIteratorList.end(); ++it)
115 if (!(*it).IsAtEnd())
117 (*it).Set(static_cast<typename OutputImageType::PixelType>(inputIt.Get()[counter]));
123 itkGenericExceptionMacro(
"End of image for band " << counter <<
" at index " << (*it).GetIndex() <<
" !");
133 template <
class TVectorImageType,
class TImageList>
138 Superclass::PrintSelf(os, indent);