OTB  10.0.0
Orfeo Toolbox
otbExtractROIBase.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 otbExtractROIBase_h
22 #define otbExtractROIBase_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "itkSmartPointer.h"
26 #include "itkExtractImageFilterRegionCopier.h"
27 
28 namespace otb
29 {
30 
47 template <class TInputImage, class TOutputImage>
48 class ExtractROIBase : public itk::ImageToImageFilter<TInputImage, TOutputImage>
49 {
50 public:
53  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
54  typedef itk::SmartPointer<Self> Pointer;
55  typedef itk::SmartPointer<const Self> ConstPointer;
56 
58  itkNewMacro(Self);
59 
61  itkTypeMacro(ExtractROIBase, itk::ImageToImageFilter);
62 
64  typedef TInputImage InputImageType;
65  typedef TOutputImage OutputImageType;
66 
68  typedef typename TOutputImage::RegionType OutputImageRegionType;
69  typedef typename TInputImage::RegionType InputImageRegionType;
70 
72  typedef typename TOutputImage::PixelType OutputImagePixelType;
73  typedef typename TInputImage::PixelType InputImagePixelType;
74 
76  typedef typename TOutputImage::IndexType OutputImageIndexType;
77  typedef typename TInputImage::IndexType InputImageIndexType;
78  typedef typename TOutputImage::SizeType OutputImageSizeType;
79  typedef typename TInputImage::SizeType InputImageSizeType;
80 
82  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
83  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
85 
86  typedef itk::ImageToImageFilterDetail::ExtractImageFilterRegionCopier<itkGetStaticConstMacro(InputImageDimension),
87  itkGetStaticConstMacro(OutputImageDimension)>
89 
90  itkGetMacro(ExtractionRegion, InputImageRegionType);
91 
94 
96  itkSetMacro(StartX, unsigned long);
97  itkGetConstMacro(StartX, unsigned long);
98  itkSetMacro(StartY, unsigned long);
99  itkGetConstMacro(StartY, unsigned long);
100 
102  itkSetMacro(SizeX, unsigned long);
103  itkGetConstMacro(SizeX, unsigned long);
104  itkSetMacro(SizeY, unsigned long);
105  itkGetConstMacro(SizeY, unsigned long);
107 
108 protected:
109  ExtractROIBase();
110  ~ExtractROIBase() override
111  {
112  }
113  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
114 
115  void GenerateInputRequestedRegion() override;
116 
125  void GenerateOutputInformation() override;
126 
137  void CallCopyOutputRegionToInputRegion(InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override;
138 
149  // ATTENTION bizarre
150 
151  void ThreadedGenerateData(const OutputImageRegionType& /*outputRegionForThread*/, itk::ThreadIdType /*threadId*/) override
152 
153  {
154  }
155 
162 
165 
166 private:
167  ExtractROIBase(const Self&) = delete;
168  void operator=(const Self&) = delete;
169 
171  unsigned long m_StartX;
172  unsigned long m_StartY;
173 
175  unsigned long m_SizeX;
176  unsigned long m_SizeY;
177 };
178 
179 } // end namespace otb
180 
181 #ifndef OTB_MANUAL_INSTANTIATION
182 #include "otbExtractROIBase.hxx"
183 #endif
184 
185 #endif
Base class to extract area of images.
TOutputImage::RegionType OutputImageRegionType
TOutputImage::PixelType OutputImagePixelType
TInputImage InputImageType
OutputImageRegionType m_OutputImageRegion
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
TOutputImage::SizeType OutputImageSizeType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
static const unsigned int OutputImageDimension
void GenerateInputRequestedRegion() override
void SetExtractionRegion(InputImageRegionType roi)
TInputImage::PixelType InputImagePixelType
static const unsigned int InputImageDimension
TInputImage::IndexType InputImageIndexType
void operator=(const Self &)=delete
TOutputImage::IndexType OutputImageIndexType
itk::SmartPointer< const Self > ConstPointer
TInputImage::RegionType InputImageRegionType
void GenerateOutputInformation() override
itk::ImageToImageFilterDetail::ExtractImageFilterRegionCopier< itkGetStaticConstMacro(InputImageDimension), itkGetStaticConstMacro(OutputImageDimension)> ExtractROIBaseRegionCopierType
void SetInternalExtractionRegion(InputImageRegionType extractRegion)
TOutputImage OutputImageType
void ThreadedGenerateData(const OutputImageRegionType &, itk::ThreadIdType) override
void CallCopyOutputRegionToInputRegion(InputImageRegionType &destRegion, const OutputImageRegionType &srcRegion) override
itk::SmartPointer< Self > Pointer
InputImageRegionType m_ExtractionRegion
ExtractROIBase(const Self &)=delete
TInputImage::SizeType InputImageSizeType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.