OTB  10.0.0
Orfeo Toolbox
otbMNFImageFilter.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 otbMNFImageFilter_h
22 #define otbMNFImageFilter_h
23 
24 #include "otbPCAImageFilter.h"
25 
26 
27 namespace otb
28 {
29 
46 template <class TInputImage, class TOutputImage, class TNoiseImageFilter, Transform::TransformDirection TDirectionOfTransformation>
47 class ITK_EXPORT MNFImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
48 {
49 public:
52  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
53  typedef itk::SmartPointer<Self> Pointer;
54  typedef itk::SmartPointer<const Self> ConstPointer;
55 
57  itkNewMacro(Self);
58 
60  itkTypeMacro(MNFImageFilter, ImageToImageFilter);
61 
63  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
64  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
66 
68  itkStaticConstMacro(DirectionOfTransformation, TransformDirectionEnumType, TDirectionOfTransformation);
69 
71  typedef TInputImage InputImageType;
72  typedef TOutputImage OutputImageType;
73 
77 
81  typedef typename MatrixObjectType::ComponentType MatrixType;
82  typedef typename MatrixType::InternalMatrixType InternalMatrixType;
83  typedef typename InternalMatrixType::element_type MatrixElementType;
84 
87 
88  typedef TNoiseImageFilter NoiseImageFilterType;
89  typedef typename NoiseImageFilterType::Pointer NoiseImageFilterPointerType;
90 
93 
97  itkGetMacro(NumberOfPrincipalComponentsRequired, unsigned int);
98  itkSetMacro(NumberOfPrincipalComponentsRequired, unsigned int);
100 
101  itkGetConstMacro(Normalizer, NormalizeFilterType*);
102  itkGetMacro(Normalizer, NormalizeFilterType*);
103  itkGetMacro(NoiseCovarianceEstimator, CovarianceEstimatorFilterType*);
104  itkGetMacro(Transformer, TransformFilterType*);
105  itkGetMacro(NoiseImageFilter, NoiseImageFilterType*);
106 
108  itkGetMacro(UseNormalization, bool);
109  itkSetMacro(UseNormalization, bool);
111 
112  itkGetConstMacro(MeanValues, VectorType);
113  void SetMeanValues(const VectorType& vec)
114  {
115  m_MeanValues = vec;
116  m_GivenMeanValues = true;
117  }
118 
119  itkGetConstMacro(StdDevValues, VectorType);
120  void SetStdDevValues(const VectorType& vec)
121  {
122  m_StdDevValues = vec;
123  m_UseNormalization = true;
124  m_GivenStdDevValues = true;
125  }
126 
127  itkGetConstMacro(CovarianceMatrix, MatrixType);
129  {
130  m_CovarianceMatrix = cov;
131  m_GivenCovarianceMatrix = true;
132  }
133 
134  itkGetConstMacro(NoiseCovarianceMatrix, MatrixType);
136  {
137  m_NoiseCovarianceMatrix = mat;
138  m_GivenNoiseCovarianceMatrix = true;
139  }
140 
141  itkGetConstMacro(TransformationMatrix, MatrixType);
142  void SetTransformationMatrix(const MatrixType& transf, bool isForward = true)
143  {
144  m_TransformationMatrix = transf;
145  m_GivenTransformationMatrix = true;
146  m_IsTransformationMatrixForward = isForward;
147  }
148 
150  {
152  m_Normalizer->GetCovarianceEstimator()->SetUserIgnoredValue(value);
153  m_Normalizer->GetCovarianceEstimator()->SetIgnoreUserDefinedValue(true);
154 
156  m_CovarianceEstimator->SetUserIgnoredValue(value);
157  m_CovarianceEstimator->SetIgnoreUserDefinedValue(true);
158 
160  m_NoiseCovarianceEstimator->SetUserIgnoredValue(value);
161  m_NoiseCovarianceEstimator->SetIgnoreUserDefinedValue(true);
162  }
164 
165  itkGetConstMacro(EigenValues, VectorType);
166 
167 protected:
168  MNFImageFilter();
169  ~MNFImageFilter() override
170  {
171  }
172 
181  void GenerateOutputInformation() override;
182 
186  void GenerateData() override;
187 
188  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
189 
191  void ForwardGenerateOutputInformation();
192  void ReverseGenerateOutputInformation();
193  virtual void ForwardGenerateData();
194  virtual void ReverseGenerateData();
196 
198  virtual void GenerateTransformationMatrix();
199 
202 
206 
211 
218 
224 
225 private:
226  MNFImageFilter(const Self&); // not implemented
227  void operator=(const Self&); // not implemented
228 }; // end of class
229 
230 } // end of namespace otb
231 
232 #ifndef OTB_MANUAL_INSTANTIATION
233 #include "otbMNFImageFilter.hxx"
234 #endif
235 
236 
237 #endif
Performs a Maximum Noise Fraction analysis of a vector image.
void SetStdDevValues(const VectorType &vec)
NormalizeVectorImageFilter< InputImageType, OutputImageType > NormalizeFilterType
void SetMeanValues(const VectorType &vec)
itk::SmartPointer< const Self > ConstPointer
NormalizeFilterType::Pointer NormalizeFilterPointerType
CovarianceEstimatorFilterType::MatrixObjectType MatrixObjectType
itk::SmartPointer< Self > Pointer
TransformFilterType::Pointer TransformFilterPointerType
CovarianceEstimatorFilterPointerType m_CovarianceEstimator
CovarianceEstimatorFilterType::Pointer CovarianceEstimatorFilterPointerType
StreamingStatisticsVectorImageFilter< InputImageType > CovarianceEstimatorFilterType
NoiseImageFilterPointerType m_NoiseImageFilter
NormalizeFilterPointerType m_Normalizer
MatrixImageFilter< InputImageType, OutputImageType > TransformFilterType
Transform::TransformDirection TransformDirectionEnumType
TNoiseImageFilter NoiseImageFilterType
CovarianceEstimatorFilterType::RealType RealType
MNFImageFilter(const Self &)
void SetNoiseCovarianceMatrix(const MatrixType &mat)
CovarianceEstimatorFilterPointerType m_NoiseCovarianceEstimator
MatrixType m_NoiseCovarianceMatrix
void SetTransformationMatrix(const MatrixType &transf, bool isForward=true)
MatrixObjectType::ComponentType MatrixType
MatrixType m_TransformationMatrix
void SetCovarianceMatrix(const MatrixType &cov)
CovarianceEstimatorFilterType::RealPixelType VectorType
NoiseImageFilterType::Pointer NoiseImageFilterPointerType
TInputImage InputImageType
TOutputImage OutputImageType
TransformFilterPointerType m_Transformer
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
MatrixType::InternalMatrixType InternalMatrixType
unsigned int m_NumberOfPrincipalComponentsRequired
void SetStatisticsUserIgnoredValue(RealType value)
void operator=(const Self &)
InternalMatrixType::element_type MatrixElementType
Apply a matrix multiplication over the channels of an image.
itk::SmartPointer< Self > Pointer
Normalize an VectorImage by setting its mean to zero and possibly variance to one (band by band).
This class streams the whole input image through the PersistentStatisticsImageFilter.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.