OTB  9.0.0
Orfeo Toolbox
otbOverlapSaveConvolutionImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbOverlapSaveConvolutionImageFilter_h
22 #define otbOverlapSaveConvolutionImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "itkImage.h"
26 #include "itkNumericTraits.h"
27 #include "itkArray.h"
28 #include "itkZeroFluxNeumannBoundaryCondition.h"
29 
30 namespace otb
31 {
61 template <class TInputImage, class TOutputImage, class TBoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition<TInputImage>>
62 class ITK_EXPORT OverlapSaveConvolutionImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
63 {
64 public:
66  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
67  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
69 
71  typedef TInputImage InputImageType;
72  typedef TOutputImage OutputImageType;
73 
76  typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
77  typedef itk::SmartPointer<Self> Pointer;
78  typedef itk::SmartPointer<const Self> ConstPointer;
79 
81  itkNewMacro(Self);
82 
84  itkTypeMacro(OverlapSaveConvolutionImageFilter, ImageToImageFilter);
85 
87  typedef typename InputImageType::PixelType InputPixelType;
88  typedef typename OutputImageType::PixelType OutputPixelType;
89  typedef typename itk::NumericTraits<InputPixelType>::RealType InputRealType;
90  typedef typename InputImageType::RegionType InputImageRegionType;
91  typedef typename OutputImageType::RegionType OutputImageRegionType;
92  typedef typename InputImageType::SizeType InputSizeType;
93  typedef typename itk::Array<InputRealType> ArrayType;
94  typedef TBoundaryCondition BoundaryConditionType;
95 
97  virtual void SetRadius(const InputSizeType rad)
98  {
99  itkDebugMacro("setting radius to " << rad);
100  if (this->m_Radius != rad)
101  {
102  this->m_Radius = rad;
103  unsigned int arraySize = 1;
104  for (unsigned int i = 0; i < m_Radius.GetSizeDimension(); ++i)
105  {
106  arraySize *= 2 * this->m_Radius[i] + 1;
107  }
108  this->m_Filter.SetSize(arraySize);
109  this->m_Filter.Fill(1);
110  this->Modified();
111  }
112  }
114 
116  itkGetConstReferenceMacro(Radius, InputSizeType);
117 
119  void SetFilter(ArrayType filter)
120  {
121  if ((filter.Size() != m_Filter.Size()))
122  {
123  itkExceptionMacro("Error in SetFilter, invalid filter size:" << filter.Size() << " instead of 2*(m_Radius[0]+1)*(2*m_Radius[1]+1): " << m_Filter.Size());
124  }
125  else
126  {
127  m_Filter = filter;
128  }
129  this->Modified();
130  }
131 
133  itkGetConstReferenceMacro(Filter, ArrayType);
134 
136  itkSetMacro(NormalizeFilter, bool);
137  itkGetMacro(NormalizeFilter, bool);
138  itkBooleanMacro(NormalizeFilter);
140 
144  void GenerateInputRequestedRegion() override;
145 
146 #ifdef ITK_USE_CONCEPT_CHECKING
147 
148  itkConceptMacro(InputHasNumericTraitsCheck, (itk::Concept::HasNumericTraits<InputPixelType>));
149 
151 #endif
152 
153 protected:
156 
159  {
160  }
161  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
162 
163  /* TODO For the moment this class provide only a GenerateData(),
164  * due to limited thread-safety of FFTW plan creation.
165  */
166  void GenerateData() override;
167  // void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
168 
169 private:
170  OverlapSaveConvolutionImageFilter(const Self&) = delete;
171  void operator=(const Self&) = delete;
172 
175 
178 
181 };
182 } // end namespace otb
183 
184 #ifndef OTB_MANUAL_INSTANTIATION
186 #endif
187 
188 #endif
otb::OverlapSaveConvolutionImageFilter::Self
OverlapSaveConvolutionImageFilter Self
Definition: otbOverlapSaveConvolutionImageFilter.h:75
otb::OverlapSaveConvolutionImageFilter::Superclass
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
Definition: otbOverlapSaveConvolutionImageFilter.h:76
otb::OverlapSaveConvolutionImageFilter
Definition: otbOverlapSaveConvolutionImageFilter.h:62
otb::OverlapSaveConvolutionImageFilter::SetRadius
virtual void SetRadius(const InputSizeType rad)
Definition: otbOverlapSaveConvolutionImageFilter.h:97
otb::OverlapSaveConvolutionImageFilter::BoundaryConditionType
TBoundaryCondition BoundaryConditionType
Definition: otbOverlapSaveConvolutionImageFilter.h:94
otb::OverlapSaveConvolutionImageFilter::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbOverlapSaveConvolutionImageFilter.h:84
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::OverlapSaveConvolutionImageFilter::m_NormalizeFilter
bool m_NormalizeFilter
Definition: otbOverlapSaveConvolutionImageFilter.h:180
otb::OverlapSaveConvolutionImageFilter::m_Filter
ArrayType m_Filter
Definition: otbOverlapSaveConvolutionImageFilter.h:177
otb::OverlapSaveConvolutionImageFilter::~OverlapSaveConvolutionImageFilter
~OverlapSaveConvolutionImageFilter() override
Definition: otbOverlapSaveConvolutionImageFilter.h:158
otb::OverlapSaveConvolutionImageFilter::InputRealType
itk::NumericTraits< InputPixelType >::RealType InputRealType
Definition: otbOverlapSaveConvolutionImageFilter.h:89
otb::Wrapper::Tags::Filter
static const std::string Filter
Definition: otbWrapperTags.h:39
otbOverlapSaveConvolutionImageFilter.hxx
otb::OverlapSaveConvolutionImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbOverlapSaveConvolutionImageFilter.h:91
otb::OverlapSaveConvolutionImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbOverlapSaveConvolutionImageFilter.h:72
otb::OverlapSaveConvolutionImageFilter::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbOverlapSaveConvolutionImageFilter.h:88
otb::OverlapSaveConvolutionImageFilter::SetFilter
void SetFilter(ArrayType filter)
Definition: otbOverlapSaveConvolutionImageFilter.h:119
otb::OverlapSaveConvolutionImageFilter::InputSizeType
InputImageType::SizeType InputSizeType
Definition: otbOverlapSaveConvolutionImageFilter.h:92
otb::OverlapSaveConvolutionImageFilter::InputImageType
TInputImage InputImageType
Definition: otbOverlapSaveConvolutionImageFilter.h:71
otb::OverlapSaveConvolutionImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbOverlapSaveConvolutionImageFilter.h:78
otb::OverlapSaveConvolutionImageFilter::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbOverlapSaveConvolutionImageFilter.h:90
otb::OverlapSaveConvolutionImageFilter::m_Radius
InputSizeType m_Radius
Definition: otbOverlapSaveConvolutionImageFilter.h:174
otb::OverlapSaveConvolutionImageFilter::ArrayType
itk::Array< InputRealType > ArrayType
Definition: otbOverlapSaveConvolutionImageFilter.h:93
otb::OverlapSaveConvolutionImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbOverlapSaveConvolutionImageFilter.h:77