OTB  9.0.0
Orfeo Toolbox
otbSFSTexturesImageFilter.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 otbSFSTexturesImageFilter_h
22 #define otbSFSTexturesImageFilter_h
23 
24 #include "otbSFSTexturesFunctor.h"
25 #include "itkImageToImageFilter.h"
26 #include "itkImageRegionIteratorWithIndex.h"
27 #include "itkConstNeighborhoodIterator.h"
28 
29 namespace otb
30 {
31 
57 template <class TInputImage, class TOutputImage>
58 class ITK_EXPORT SFSTexturesImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
59 {
60 public:
63  typedef TInputImage InputImageType;
64  typedef TOutputImage OutputImageType;
65  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
66  typedef itk::SmartPointer<Self> Pointer;
67  typedef itk::SmartPointer<const Self> ConstPointer;
68 
70  itkNewMacro(Self);
71 
73  itkTypeMacro(UnaryFunctorNeighborhoodImageFilter, ImageToImageFilter);
74 
76  typedef typename InputImageType::ConstPointer InputImagePointerType;
77  typedef typename InputImageType::RegionType InputImageRegionType;
78  typedef typename InputImageType::PixelType InputImagePixelType;
79  typedef typename InputImageType::SizeType InputImageSizeType;
80  typedef typename OutputImageType::Pointer OutputImagePointerType;
81  typedef typename OutputImageType::RegionType OutputImageRegionType;
82  typedef typename OutputImageType::PixelType OutputImagePixelType;
83  typedef itk::ConstNeighborhoodIterator<TInputImage> NeighborhoodIteratorType;
84  typedef typename NeighborhoodIteratorType::RadiusType RadiusType;
87  typedef itk::ProcessObject ProcessObjectType;
88 
90  itkGetMacro(Radius, unsigned int);
91 
94  {
95  return m_Functor;
96  }
97 
98  const FunctorType& GetFunctor() const
99  {
100  return m_Functor;
101  }
102  void SetFunctor(const FunctorType& functor)
103  {
104  m_Functor = functor;
105  this->Modified();
106  }
107 
109  void SetSpatialThreshold(unsigned int thresh)
110  {
111  this->GetFunctor().SetSpatialThreshold(thresh);
112  m_Radius = thresh;
113  this->Modified();
114  }
115  unsigned int GetSpatialThreshold()
116  {
117  return this->GetFunctor().GetSpatialThreshold();
118  }
119 
122  {
123  this->GetFunctor().SetSpectralThreshold(thresh);
124  }
126  {
127  return this->GetFunctor().GetSpectralThreshold();
128  }
129 
131  void SetRatioMaxConsiderationNumber(unsigned int value)
132  {
133  this->GetFunctor().SetRatioMaxConsiderationNumber(value);
134  }
136  {
137  return this->GetFunctor().GetRatioMaxConsiderationNumber();
138  }
140 
142  void SetAlpha(double alpha)
143  {
144  this->GetFunctor().SetAlpha(alpha);
145  }
146  double GetAlpha()
147  {
148  return this->GetFunctor().GetAlpha();
149  }
151 
153  void SetNumberOfDirections(unsigned int D)
154  {
155  this->GetFunctor().SetNumberOfDirections(D);
156  double step = CONST_PI / static_cast<double>(D);
157  this->GetFunctor().SetDirectionStep(step);
158  }
159  unsigned int GetNumberOfDirections()
160  {
161  return this->GetFunctor().GetNumberOfDirections();
162  }
164 
174  typedef enum { LENGTH = 1, WIDTH, PSI, WMEAN, RATIO, SD } FeatureType;
175 
176  void SetFeatureStatus(FeatureType id, bool isSelected)
177  {
178  if (static_cast<unsigned int>(id) > this->GetTexturesStatus().size() || id == 0)
179  {
180  itkExceptionMacro(<< "Invalid texture index " << id << ", must be in [1;" << this->GetTexturesStatus().size() << "]");
181  }
182  else
183  {
184  this->GetFunctor().SetTextureStatus(id - 1, isSelected);
185  }
186  }
187 
188  std::vector<bool> GetTexturesStatus()
189  {
190  return this->GetFunctor().GetTexturesStatus();
191  }
192 
193  void InitFeatureStatus(bool status);
194 
196  const OutputImageType* GetLengthOutput() const;
197  OutputImageType* GetLengthOutput();
199 
201  const OutputImageType* GetWidthOutput() const;
202  OutputImageType* GetWidthOutput();
204 
206  const OutputImageType* GetPSIOutput() const;
207  OutputImageType* GetPSIOutput();
209 
211  const OutputImageType* GetWMeanOutput() const;
212  OutputImageType* GetWMeanOutput();
214 
216  const OutputImageType* GetRatioOutput() const;
217  OutputImageType* GetRatioOutput();
219 
221  const OutputImageType* GetSDOutput() const;
222  OutputImageType* GetSDOutput();
224 
225  void GenerateOutputInformation() override;
226  std::vector<FunctorType> m_FunctorList;
227 
228 protected:
231  {
232  }
233  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
234 
235  void BeforeThreadedGenerateData() override;
236  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
238  void GenerateInputRequestedRegion(void) override;
239 
240 private:
241  SFSTexturesImageFilter(const Self&) = delete;
242  void operator=(const Self&) = delete;
243 
244  unsigned int m_Radius;
246 };
247 
248 } // end namespace otb
249 
250 #ifndef OTB_MANUAL_INSTANTIATION
252 #endif
253 
254 #endif
otb::SFSTexturesImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbSFSTexturesImageFilter.h:65
otb::SFSTexturesImageFilter::SetAlpha
void SetAlpha(double alpha)
Definition: otbSFSTexturesImageFilter.h:142
otb::SFSTexturesImageFilter::FunctorType
Functor::SFSTexturesFunctor< NeighborhoodIteratorType, OutputImagePixelType > FunctorType
Definition: otbSFSTexturesImageFilter.h:85
otb::SFSTexturesImageFilter::OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Definition: otbSFSTexturesImageFilter.h:82
otb::CONST_PI
constexpr double CONST_PI
Definition: otbMath.h:49
otb::SFSTexturesImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbSFSTexturesImageFilter.h:81
otb::SFSTexturesImageFilter::SetSpatialThreshold
void SetSpatialThreshold(unsigned int thresh)
Definition: otbSFSTexturesImageFilter.h:109
otb::SFSTexturesImageFilter::SetFeatureStatus
void SetFeatureStatus(FeatureType id, bool isSelected)
Definition: otbSFSTexturesImageFilter.h:176
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SFSTexturesImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbSFSTexturesImageFilter.h:67
otb::SFSTexturesImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: otbSFSTexturesImageFilter.h:98
otb::SFSTexturesImageFilter::FunctorOutputType
FunctorType::OutputType FunctorOutputType
Definition: otbSFSTexturesImageFilter.h:86
otbSFSTexturesImageFilter.hxx
otb::SFSTexturesImageFilter::Self
SFSTexturesImageFilter Self
Definition: otbSFSTexturesImageFilter.h:62
otb::SFSTexturesImageFilter::RadiusType
NeighborhoodIteratorType::RadiusType RadiusType
Definition: otbSFSTexturesImageFilter.h:84
otb::SFSTexturesImageFilter::SetNumberOfDirections
void SetNumberOfDirections(unsigned int D)
Definition: otbSFSTexturesImageFilter.h:153
otb::Functor::SFSTexturesFunctor< NeighborhoodIteratorType, OutputImagePixelType >
otb::SFSTexturesImageFilter::GetSpectralThreshold
InputImagePixelType GetSpectralThreshold()
Definition: otbSFSTexturesImageFilter.h:125
otb::SFSTexturesImageFilter::GetTexturesStatus
std::vector< bool > GetTexturesStatus()
Definition: otbSFSTexturesImageFilter.h:188
otb::SFSTexturesImageFilter
This functor computes the texture describes in the following publication It is based on line directio...
Definition: otbSFSTexturesImageFilter.h:58
otb::Functor::SFSTexturesFunctor< NeighborhoodIteratorType, OutputImagePixelType >::OutputType
std::vector< OutputValueType > OutputType
Definition: otbSFSTexturesFunctor.h:82
otb::SFSTexturesImageFilter::GetRatioMaxConsiderationNumber
unsigned int GetRatioMaxConsiderationNumber()
Definition: otbSFSTexturesImageFilter.h:135
otb::SFSTexturesImageFilter::NeighborhoodIteratorType
itk::ConstNeighborhoodIterator< TInputImage > NeighborhoodIteratorType
Definition: otbSFSTexturesImageFilter.h:83
otb::SFSTexturesImageFilter::OutputImagePointerType
OutputImageType::Pointer OutputImagePointerType
Definition: otbSFSTexturesImageFilter.h:80
otb::SFSTexturesImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbSFSTexturesImageFilter.h:64
otb::SFSTexturesImageFilter::InputImageSizeType
InputImageType::SizeType InputImageSizeType
Definition: otbSFSTexturesImageFilter.h:79
otb::SFSTexturesImageFilter::m_FunctorList
std::vector< FunctorType > m_FunctorList
Definition: otbSFSTexturesImageFilter.h:226
otb::UnaryFunctorNeighborhoodImageFilter
Implements neighborhood-wise generic operation on image.
Definition: otbUnaryFunctorNeighborhoodImageFilter.h:43
otb::SFSTexturesImageFilter::FeatureType
FeatureType
Definition: otbSFSTexturesImageFilter.h:174
otbSFSTexturesFunctor.h
otb::SFSTexturesImageFilter::~SFSTexturesImageFilter
~SFSTexturesImageFilter() override
Definition: otbSFSTexturesImageFilter.h:230
otb::SFSTexturesImageFilter::m_Functor
FunctorType m_Functor
Definition: otbSFSTexturesImageFilter.h:245
otb::SFSTexturesImageFilter::WMEAN
@ WMEAN
Definition: otbSFSTexturesImageFilter.h:174
otb::SFSTexturesImageFilter::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbSFSTexturesImageFilter.h:77
otb::SFSTexturesImageFilter::GetAlpha
double GetAlpha()
Definition: otbSFSTexturesImageFilter.h:146
otb::SFSTexturesImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSFSTexturesImageFilter.h:66
otb::SFSTexturesImageFilter::SetRatioMaxConsiderationNumber
void SetRatioMaxConsiderationNumber(unsigned int value)
Definition: otbSFSTexturesImageFilter.h:131
otb::SFSTexturesImageFilter::SetFunctor
void SetFunctor(const FunctorType &functor)
Definition: otbSFSTexturesImageFilter.h:102
otb::SFSTexturesImageFilter::GetNumberOfDirections
unsigned int GetNumberOfDirections()
Definition: otbSFSTexturesImageFilter.h:159
otb::SFSTexturesImageFilter::GetSpatialThreshold
unsigned int GetSpatialThreshold()
Definition: otbSFSTexturesImageFilter.h:115
otb::SFSTexturesImageFilter::InputImageType
TInputImage InputImageType
Definition: otbSFSTexturesImageFilter.h:63
otb::SFSTexturesImageFilter::ProcessObjectType
itk::ProcessObject ProcessObjectType
Definition: otbSFSTexturesImageFilter.h:87
otb::SFSTexturesImageFilter::m_Radius
unsigned int m_Radius
Definition: otbSFSTexturesImageFilter.h:244
otb::SFSTexturesImageFilter::SetSpectralThreshold
void SetSpectralThreshold(InputImagePixelType thresh)
Definition: otbSFSTexturesImageFilter.h:121
otb::SFSTexturesImageFilter::InputImagePointerType
InputImageType::ConstPointer InputImagePointerType
Definition: otbSFSTexturesImageFilter.h:73
otb::SFSTexturesImageFilter::InputImagePixelType
InputImageType::PixelType InputImagePixelType
Definition: otbSFSTexturesImageFilter.h:78
otb::SFSTexturesImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: otbSFSTexturesImageFilter.h:93