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);
41 this->DynamicMultiThreadingOn();
45 template <
class TInputImage,
class TOutputImage>
49 Superclass::GenerateInputRequestedRegion();
52 typename Superclass::InputImagePointer inputPtr =
const_cast<TInputImage*
>(this->GetInput());
53 typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
55 if (!inputPtr || !outputPtr)
61 typename TInputImage::RegionType inputRequestedRegion;
62 inputRequestedRegion = inputPtr->GetRequestedRegion();
65 inputRequestedRegion.PadByRadius(m_Radius);
68 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
70 inputPtr->SetRequestedRegion(inputRequestedRegion);
79 inputPtr->SetRequestedRegion(inputRequestedRegion);
82 itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
83 std::ostringstream msg;
84 msg << this->GetNameOfClass() <<
"::GenerateInputRequestedRegion()";
85 e.SetLocation(msg.str());
86 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
87 e.SetDataObject(inputPtr);
95 template <
class TInputImage,
class TOutputImage>
98 Superclass::GenerateOutputInformation();
99 this->GetOutput()->SetNumberOfComponentsPerPixel(4);
105 template <
class TInputImage,
class TOutputImage>
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;
134 for (fit = faceList.begin(); fit != faceList.end(); ++fit)
136 neighInputIt = itk::ConstNeighborhoodIterator<TInputImage>(r, inputPtr, *fit);
138 outputIt = itk::ImageRegionIterator<TOutputImage>(outputPtr, *fit);
139 neighInputIt.OverrideBoundaryCondition(&nbc);
140 neighInputIt.GoToBegin();
142 while (!outputIt.IsAtEnd())
144 outputIt.Set(m_Functor(neighInputIt));
OutputImageType::Pointer OutputImagePointer
InputImageType::ConstPointer InputImagePointer
NeighborhoodIteratorType::RadiusType RadiusType
RadiometricMomentsImageFilter()
void GenerateOutputInformation(void) override
itk::ConstNeighborhoodIterator< TInputImage > NeighborhoodIteratorType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void GenerateInputRequestedRegion(void) override
OutputImageType::RegionType OutputImageRegionType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.