22 #ifndef otbROIdataConversion_hxx
23 #define otbROIdataConversion_hxx
25 #include "itkVector.h"
28 #include "itkImageRegionIterator.h"
33 template <
class TInputImage,
class TInputROIImage>
36 this->SetNumberOfRequiredInputs(2);
37 this->SetNumberOfRequiredInputs(2);
40 template <
class TInputImage,
class TInputROIImage>
43 typename OutputImageType::Pointer outputPtr = this->GetOutput();
44 typename OutputImageType::SizeType outputSize = outputPtr->GetRequestedRegion().GetSize();
45 outputSize[0] = GetNumberOfSample();
46 outputPtr->SetRegions(outputSize);
49 template <
class TInputImage,
class TInputROIImage>
52 typename InputImageType::Pointer inputImagePtr =
const_cast<InputImageType*
>(this->GetInputImage());
53 typename InputROIImageType::Pointer inputROIPtr = this->GetROIImage();
54 inputImagePtr->SetRequestedRegion(inputImagePtr->GetLargestPossibleRegion());
55 inputROIPtr->SetRequestedRegion(inputROIPtr->GetLargestPossibleRegion());
58 template <
class TInputImage,
class TInputROIImage>
61 typename InputImageType::Pointer inputImagePtr =
const_cast<InputImageType*
>(this->GetInputImage());
62 typename InputROIImageType::ConstPointer inputROIPtr = this->GetROIImage();
63 typename OutputImageType::Pointer outputPtr = this->GetOutput();
65 outputPtr->Allocate();
66 typename InputImageType::PixelType zero;
67 itk::NumericTraits<typename InputImageType::PixelType>::SetLength(zero, outputPtr->GetNumberOfComponentsPerPixel());
68 outputPtr->FillBuffer(zero);
70 itk::ImageRegionConstIterator<InputImageType> inputIter(inputImagePtr, inputImagePtr->GetRequestedRegion());
71 itk::ImageRegionConstIterator<InputROIImageType> trainingIter(inputROIPtr, inputROIPtr->GetRequestedRegion());
72 itk::ImageRegionIterator<OutputImageType> outputIter(outputPtr, outputPtr->GetRequestedRegion());
74 inputIter.GoToBegin();
75 trainingIter.GoToBegin();
76 outputIter.GoToBegin();
78 while (!trainingIter.IsAtEnd())
80 if (trainingIter.Get() != 0)
82 outputIter.Set(inputIter.Get());
91 template <
class TInputImage,
class TInputROIImage>
95 itk::ImageRegionConstIterator<InputROIImageType> trainingIter(inputROIPtr, inputROIPtr->GetRequestedRegion());
97 trainingIter.GoToBegin();
100 while (!trainingIter.IsAtEnd())
102 if (trainingIter.Get() != 0)