21 #ifndef otbBinaryFunctorNeighborhoodVectorImageFilter_hxx
22 #define otbBinaryFunctorNeighborhoodVectorImageFilter_hxx
27 #include "itkImageRegionIterator.h"
28 #include "itkNeighborhoodAlgorithm.h"
29 #include "itkProgressReporter.h"
37 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
40 this->SetNumberOfRequiredInputs(2);
49 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
53 this->SetNthInput(0,
const_cast<TInputImage1*
>(image1));
59 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
63 this->SetNthInput(1,
const_cast<TInputImage2*
>(image2));
69 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
71 const unsigned char& max)
74 GetFunctor().SetRadius(min, max);
81 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
84 Superclass::GenerateOutputInformation();
86 int nbComponents =
static_cast<int>(m_Functor.GetRadiusMax()) + 1 -
static_cast<int>(m_Functor.GetRadiusMin());
88 this->GetOutput()->SetNumberOfComponentsPerPixel(nbComponents);
94 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
99 itk::ZeroFluxNeumannBoundaryCondition<TInputImage1> nbc1;
100 itk::ZeroFluxNeumannBoundaryCondition<TInputImage2> nbc2;
102 Input1ImagePointer inputPtr1 =
dynamic_cast<const TInputImage1*
>(ProcessObjectType::GetInput(0));
103 Input2ImagePointer inputPtr2 =
dynamic_cast<const TInputImage2*
>(ProcessObjectType::GetInput(1));
116 outputPtr->SetNumberOfComponentsPerPixel(m_Functor.GetNumberOfComponentsPerPixel());
117 outputPtr->Allocate();
119 itk::ImageRegionIterator<TOutputImage> outputIt;
122 typedef typename itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage1> TypeFace1;
123 typename TypeFace1::FaceListType::iterator fit1;
124 typename TypeFace1::FaceListType faceList1;
126 faceList1 = bC1(inputPtr1, outputRegionForThread, r1);
128 typedef typename itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage2> TypeFace2;
129 typename TypeFace2::FaceListType::iterator fit2;
130 typename TypeFace2::FaceListType faceList2;
132 faceList2 = bC2(inputPtr2, outputRegionForThread, r2);
136 for (fit1 = faceList1.begin(), fit2 = faceList2.begin(); fit1 != faceList1.end() && fit2 != faceList2.end(); ++fit1, ++fit2)
138 neighInputIt1 = itk::ConstNeighborhoodIterator<TInputImage1>(r1, inputPtr1, *fit1);
139 neighInputIt1.OverrideBoundaryCondition(&nbc1);
140 neighInputIt1.GoToBegin();
142 neighInputIt2 = itk::ConstNeighborhoodIterator<TInputImage2>(r2, inputPtr2, *fit2);
143 neighInputIt2.OverrideBoundaryCondition(&nbc2);
144 neighInputIt2.GoToBegin();
146 outputIt = itk::ImageRegionIterator<TOutputImage>(outputPtr, *fit1);
147 outputIt.GoToBegin();
149 while (!outputIt.IsAtEnd())
151 outputIt.Set(m_Functor(neighInputIt1, neighInputIt2));
NeighborhoodIteratorType1::RadiusType RadiusType1
itk::ConstNeighborhoodIterator< TInputImage1 > NeighborhoodIteratorType1
Input1ImageType::ConstPointer Input1ImagePointer
itk::ConstNeighborhoodIterator< TInputImage2 > NeighborhoodIteratorType2
OutputImageType::RegionType OutputImageRegionType
OutputImageType::Pointer OutputImagePointer
void GenerateOutputInformation(void) override
Input2ImageType::ConstPointer Input2ImagePointer
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
NeighborhoodIteratorType2::RadiusType RadiusType2
void SetInput1(const TInputImage1 *image1)
BinaryFunctorNeighborhoodVectorImageFilter()
void SetInput2(const TInputImage2 *image2)
void SetRadius(const unsigned char &min, const unsigned char &max)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.