OTB  10.0.0
Orfeo Toolbox
otbResetMarginFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbResetMarginFilter_h
22 #define otbResetMarginFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 
26 namespace otb
27 {
43 template <typename TImage>
44 class ResetMarginFilter : public itk::ImageToImageFilter<TImage, TImage>
45 {
46 public:
47 
50  using InputImageType = TImage;
51  using OutputImageType = TImage;
53 
56  itkStaticConstMacro(InputImageDimension, unsigned int, InputImageType::ImageDimension);
57  itkStaticConstMacro(OutputImageDimension, unsigned int, OutputImageType::ImageDimension);
59 
63  using Superclass = itk::ImageToImageFilter<InputImageType, OutputImageType>;
64  using Pointer = itk::SmartPointer<Self>;
65  using ConstPointer = itk::SmartPointer<const Self>;
67 
69  itkNewMacro(Self);
70 
72  itkTypeMacro(ResetMarginFilter, unused);
73 
76  using InputPixelType = typename InputImageType::PixelType;
77  using OutputPixelType = typename OutputImageType::PixelType;
78  using InternalPixelType = typename OutputImageType::InternalPixelType;
79  using InputRealType = typename itk::NumericTraits<InputPixelType>::RealType;
80  using InputImageRegionType = typename InputImageType::RegionType;
81  using OutputImageRegionType = typename OutputImageType::RegionType;
82  using InputIndexType = typename InputImageType::IndexType;
83  using InputSizeType = typename InputImageType::SizeType;
84  using OutputIndexType = typename OutputImageType::IndexType;
85  using OutputSizeType = typename OutputImageType::SizeType;
86 
87  static_assert(InputImageDimension == OutputImageDimension, "Images have the same number of components");
89 
90  void SetROI(const InputImageRegionType& roi)
91  {
92  m_ROI = roi;
93  }
94 
96  {
97  return m_ROI;
98  }
99 
101  {
102  m_Pad = val;
103  }
104 
106  {
107  return m_Pad;
108  }
109 
110 protected:
113  {
114  this->DynamicMultiThreadingOff();
115  }
116 
117  InputImageType * GetInputImage() { return const_cast<InputImageType*>(this->GetInput()); }
118  InputImageType const* GetInputImage() const { return this->GetInput(); }
119 
125  InputImageRegionType & destRegion,
126  OutputImageRegionType const& srcRegion) override
127  {
128  destRegion = OutputRegionToInputRegion(srcRegion);
129  }
130 
135  OutputImageRegionType const& srcRegion);
136 
140  void GenerateOutputInformation() override;
141 
148  OutputImageRegionType const& outputRegionForThread,
149  itk::ThreadIdType threadId) override;
150 
151 private:
152 
154 
156 };
157 
158 } // otb namespace
159 
160 #ifndef OTB_MANUAL_INSTANTIATION
161 #include "otbResetMarginFilter.hxx"
162 #endif
163 
164 #endif // otbResetMarginFilter_h
typename InputImageType::PixelType InputPixelType
Hidden constructor.
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
ResetMarginFilter()
Hidden constructor.
const InputImageRegionType & GetROI() const
Hidden constructor.
typename OutputImageType::SizeType OutputSizeType
Hidden constructor.
typename OutputImageType::RegionType OutputImageRegionType
Hidden constructor.
itk::SmartPointer< Self > Pointer
typename OutputImageType::InternalPixelType InternalPixelType
Hidden constructor.
typename OutputImageType::IndexType OutputIndexType
Hidden constructor.
static const unsigned int InputImageDimension
InputImageRegionType m_ROI
Hidden constructor.
void GenerateOutputInformation() override
typename InputImageType::SizeType InputSizeType
Hidden constructor.
void SetPaddingValue(InternalPixelType val)
Hidden constructor.
InputImageType * GetInputImage()
Hidden constructor.
InternalPixelType m_Pad
Hidden constructor.
InputImageType const * GetInputImage() const
Hidden constructor.
typename OutputImageType::PixelType OutputPixelType
Hidden constructor.
void SetROI(const InputImageRegionType &roi)
Hidden constructor.
typename InputImageType::IndexType InputIndexType
Hidden constructor.
typename InputImageType::RegionType InputImageRegionType
Hidden constructor.
InternalPixelType GetPaddingValue() const
Hidden constructor.
static const unsigned int OutputImageDimension
typename itk::NumericTraits< InputPixelType >::RealType InputRealType
Hidden constructor.
void ThreadedGenerateData(OutputImageRegionType const &outputRegionForThread, itk::ThreadIdType threadId) override
InputImageRegionType OutputRegionToInputRegion(OutputImageRegionType const &srcRegion)
itk::SmartPointer< const Self > ConstPointer
void CallCopyOutputRegionToInputRegion(InputImageRegionType &destRegion, OutputImageRegionType const &srcRegion) override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.