21 #ifndef otbBinaryFunctorNeighborhoodVectorImageFilter_hxx
22 #define otbBinaryFunctorNeighborhoodVectorImageFilter_hxx
25 #include "itkImageRegionIterator.h"
26 #include "itkNeighborhoodAlgorithm.h"
27 #include "itkProgressReporter.h"
35 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
38 this->SetNumberOfRequiredInputs(2);
47 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
51 this->SetNthInput(0,
const_cast<TInputImage1*
>(image1));
57 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
61 this->SetNthInput(1,
const_cast<TInputImage2*
>(image2));
67 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
69 const unsigned char& max)
72 GetFunctor().SetRadius(min, max);
79 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
82 Superclass::GenerateOutputInformation();
84 int nbComponents =
static_cast<int>(m_Functor.GetRadiusMax()) + 1 -
static_cast<int>(m_Functor.GetRadiusMin());
86 this->GetOutput()->SetNumberOfComponentsPerPixel(nbComponents);
92 template <
class TInputImage1,
class TInputImage2,
class TOutputImage,
class TFunction>
97 itk::ZeroFluxNeumannBoundaryCondition<TInputImage1> nbc1;
98 itk::ZeroFluxNeumannBoundaryCondition<TInputImage2> nbc2;
100 Input1ImagePointer inputPtr1 =
dynamic_cast<const TInputImage1*
>(ProcessObjectType::GetInput(0));
101 Input2ImagePointer inputPtr2 =
dynamic_cast<const TInputImage2*
>(ProcessObjectType::GetInput(1));
114 outputPtr->SetNumberOfComponentsPerPixel(m_Functor.GetNumberOfComponentsPerPixel());
115 outputPtr->Allocate();
117 itk::ImageRegionIterator<TOutputImage> outputIt;
120 typedef typename itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage1> TypeFace1;
121 typename TypeFace1::FaceListType::iterator fit1;
122 typename TypeFace1::FaceListType faceList1;
124 faceList1 = bC1(inputPtr1, outputRegionForThread, r1);
126 typedef typename itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage2> TypeFace2;
127 typename TypeFace2::FaceListType::iterator fit2;
128 typename TypeFace2::FaceListType faceList2;
130 faceList2 = bC2(inputPtr2, outputRegionForThread, r2);
133 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
137 for (fit1 = faceList1.begin(), fit2 = faceList2.begin(); fit1 != faceList1.end() && fit2 != faceList2.end(); ++fit1, ++fit2)
139 neighInputIt1 = itk::ConstNeighborhoodIterator<TInputImage1>(r1, inputPtr1, *fit1);
140 neighInputIt1.OverrideBoundaryCondition(&nbc1);
141 neighInputIt1.GoToBegin();
143 neighInputIt2 = itk::ConstNeighborhoodIterator<TInputImage2>(r2, inputPtr2, *fit2);
144 neighInputIt2.OverrideBoundaryCondition(&nbc2);
145 neighInputIt2.GoToBegin();
147 outputIt = itk::ImageRegionIterator<TOutputImage>(outputPtr, *fit1);
148 outputIt.GoToBegin();
150 while (!outputIt.IsAtEnd())
152 outputIt.Set(m_Functor(neighInputIt1, neighInputIt2));
158 progress.CompletedPixel();