21 #ifndef otbRadiometricMomentsImageFilter_hxx
22 #define otbRadiometricMomentsImageFilter_hxx
25 #include "itkImageRegionIterator.h"
26 #include "itkNeighborhoodAlgorithm.h"
27 #include "itkProgressReporter.h"
28 #include "itkZeroFluxNeumannBoundaryCondition.h"
29 #include "itkNeighborhoodAlgorithm.h"
36 template <
class TInputImage,
class TOutputImage>
39 this->SetNumberOfRequiredInputs(1);
44 template <
class TInputImage,
class TOutputImage>
48 Superclass::GenerateInputRequestedRegion();
51 typename Superclass::InputImagePointer inputPtr =
const_cast<TInputImage*
>(this->GetInput());
52 typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
54 if (!inputPtr || !outputPtr)
60 typename TInputImage::RegionType inputRequestedRegion;
61 inputRequestedRegion = inputPtr->GetRequestedRegion();
64 inputRequestedRegion.PadByRadius(m_Radius);
67 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
69 inputPtr->SetRequestedRegion(inputRequestedRegion);
78 inputPtr->SetRequestedRegion(inputRequestedRegion);
81 itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
82 std::ostringstream msg;
83 msg << this->GetNameOfClass() <<
"::GenerateInputRequestedRegion()";
84 e.SetLocation(msg.str());
85 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
86 e.SetDataObject(inputPtr);
94 template <
class TInputImage,
class TOutputImage>
97 Superclass::GenerateOutputInformation();
98 this->GetOutput()->SetNumberOfComponentsPerPixel(4);
104 template <
class TInputImage,
class TOutputImage>
106 itk::ThreadIdType threadId)
108 itk::ZeroFluxNeumannBoundaryCondition<TInputImage> nbc;
113 InputImagePointer inputPtr =
dynamic_cast<const TInputImage*
>(ProcessObjectType::GetInput(0));
123 itk::ImageRegionIterator<TOutputImage> outputIt;
126 typename itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType faceList;
127 typename itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
128 faceList = bC(inputPtr, outputRegionForThread, r);
130 typename itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType::iterator fit;
133 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
137 for (fit = faceList.begin(); fit != faceList.end(); ++fit)
139 neighInputIt = itk::ConstNeighborhoodIterator<TInputImage>(r, inputPtr, *fit);
141 outputIt = itk::ImageRegionIterator<TOutputImage>(outputPtr, *fit);
142 neighInputIt.OverrideBoundaryCondition(&nbc);
143 neighInputIt.GoToBegin();
145 while (!outputIt.IsAtEnd())
147 outputIt.Set(m_Functor(neighInputIt));
151 progress.CompletedPixel();