OTB  9.0.0
Orfeo Toolbox
otbMNFImageFilter.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 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
otb::MNFImageFilter::TransformFilterPointerType
TransformFilterType::Pointer TransformFilterPointerType
Definition: otbMNFImageFilter.h:86
otb::MNFImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbMNFImageFilter.h:52
otb::MNFImageFilter::m_NumberOfPrincipalComponentsRequired
unsigned int m_NumberOfPrincipalComponentsRequired
Definition: otbMNFImageFilter.h:201
otb::MNFImageFilter::MatrixObjectType
CovarianceEstimatorFilterType::MatrixObjectType MatrixObjectType
Definition: otbMNFImageFilter.h:80
otb::Transform::TransformDirection
TransformDirection
Definition: otbPCAImageFilter.h:34
otb::MNFImageFilter::NoiseImageFilterType
TNoiseImageFilter NoiseImageFilterType
Definition: otbMNFImageFilter.h:88
otb::MNFImageFilter::SetTransformationMatrix
void SetTransformationMatrix(const MatrixType &transf, bool isForward=true)
Definition: otbMNFImageFilter.h:142
otb::MNFImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMNFImageFilter.h:54
otb::StreamingStatisticsVectorImageFilter::MatrixObjectType
StatFilterType::MatrixObjectType MatrixObjectType
Definition: otbStreamingStatisticsVectorImageFilter.h:323
otb::StreamingStatisticsVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingStatisticsVectorImageFilter.h:304
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MNFImageFilter::m_GivenMeanValues
bool m_GivenMeanValues
Definition: otbMNFImageFilter.h:204
otb::MNFImageFilter::m_TransformationMatrix
MatrixType m_TransformationMatrix
Definition: otbMNFImageFilter.h:216
otb::MNFImageFilter::m_MeanValues
VectorType m_MeanValues
Definition: otbMNFImageFilter.h:212
otb::MNFImageFilter::m_NoiseCovarianceMatrix
MatrixType m_NoiseCovarianceMatrix
Definition: otbMNFImageFilter.h:215
otb::MNFImageFilter::m_NoiseImageFilter
NoiseImageFilterPointerType m_NoiseImageFilter
Definition: otbMNFImageFilter.h:220
otb::MetaDataKey::VectorType
std::vector< double > VectorType
Definition: otbMetaDataKey.h:119
otb::StreamingStatisticsVectorImageFilter::RealPixelType
StatFilterType::RealPixelType RealPixelType
Definition: otbStreamingStatisticsVectorImageFilter.h:320
otb::MNFImageFilter::CovarianceEstimatorFilterPointerType
CovarianceEstimatorFilterType::Pointer CovarianceEstimatorFilterPointerType
Definition: otbMNFImageFilter.h:76
otb::MNFImageFilter::MatrixElementType
InternalMatrixType::element_type MatrixElementType
Definition: otbMNFImageFilter.h:83
otb::MNFImageFilter::m_IsTransformationMatrixForward
bool m_IsTransformationMatrixForward
Definition: otbMNFImageFilter.h:210
otb::MNFImageFilter::Self
MNFImageFilter Self
Definition: otbMNFImageFilter.h:51
otb::MNFImageFilter::m_GivenStdDevValues
bool m_GivenStdDevValues
Definition: otbMNFImageFilter.h:205
otb::MNFImageFilter::SetCovarianceMatrix
void SetCovarianceMatrix(const MatrixType &cov)
Definition: otbMNFImageFilter.h:128
otbMNFImageFilter.hxx
otb::MNFImageFilter::SetStatisticsUserIgnoredValue
void SetStatisticsUserIgnoredValue(RealType value)
Definition: otbMNFImageFilter.h:149
otb::MNFImageFilter::m_StdDevValues
VectorType m_StdDevValues
Definition: otbMNFImageFilter.h:213
otb::StreamingStatisticsVectorImageFilter
This class streams the whole input image through the PersistentStatisticsImageFilter.
Definition: otbStreamingStatisticsVectorImageFilter.h:297
otb::MNFImageFilter::m_NoiseCovarianceEstimator
CovarianceEstimatorFilterPointerType m_NoiseCovarianceEstimator
Definition: otbMNFImageFilter.h:222
otb::MatrixImageFilter
Apply a matrix multiplication over the channels of an image.
Definition: otbMatrixImageFilter.h:50
otb::MNFImageFilter::InternalMatrixType
MatrixType::InternalMatrixType InternalMatrixType
Definition: otbMNFImageFilter.h:82
otb::MNFImageFilter::~MNFImageFilter
~MNFImageFilter() override
Definition: otbMNFImageFilter.h:169
otb::MNFImageFilter::InputImageType
TInputImage InputImageType
Definition: otbMNFImageFilter.h:71
otb::MNFImageFilter::m_UseNormalization
bool m_UseNormalization
Definition: otbMNFImageFilter.h:203
otb::MNFImageFilter::NormalizeFilterPointerType
NormalizeFilterType::Pointer NormalizeFilterPointerType
Definition: otbMNFImageFilter.h:92
otb::MNFImageFilter::m_Normalizer
NormalizeFilterPointerType m_Normalizer
Definition: otbMNFImageFilter.h:219
otb::MNFImageFilter::SetNoiseCovarianceMatrix
void SetNoiseCovarianceMatrix(const MatrixType &mat)
Definition: otbMNFImageFilter.h:135
otb::MNFImageFilter::RealType
CovarianceEstimatorFilterType::RealType RealType
Definition: otbMNFImageFilter.h:78
otb::MNFImageFilter::m_GivenTransformationMatrix
bool m_GivenTransformationMatrix
Definition: otbMNFImageFilter.h:209
otb::MNFImageFilter::m_CovarianceEstimator
CovarianceEstimatorFilterPointerType m_CovarianceEstimator
Definition: otbMNFImageFilter.h:221
otb::MNFImageFilter::NoiseImageFilterPointerType
NoiseImageFilterType::Pointer NoiseImageFilterPointerType
Definition: otbMNFImageFilter.h:89
otb::MNFImageFilter::m_CovarianceMatrix
MatrixType m_CovarianceMatrix
Definition: otbMNFImageFilter.h:214
otb::MNFImageFilter::m_GivenNoiseCovarianceMatrix
bool m_GivenNoiseCovarianceMatrix
Definition: otbMNFImageFilter.h:208
otb::MNFImageFilter::SetMeanValues
void SetMeanValues(const VectorType &vec)
Definition: otbMNFImageFilter.h:113
otb::MNFImageFilter::NormalizeFilterType
NormalizeVectorImageFilter< InputImageType, OutputImageType > NormalizeFilterType
Definition: otbMNFImageFilter.h:91
otb::MNFImageFilter::m_GivenCovarianceMatrix
bool m_GivenCovarianceMatrix
Definition: otbMNFImageFilter.h:207
otb::NormalizeVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbNormalizeVectorImageFilter.h:142
otb::MNFImageFilter::TransformFilterType
MatrixImageFilter< InputImageType, OutputImageType > TransformFilterType
Definition: otbMNFImageFilter.h:85
otb::MatrixImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMatrixImageFilter.h:67
otb::MNFImageFilter::CovarianceEstimatorFilterType
StreamingStatisticsVectorImageFilter< InputImageType > CovarianceEstimatorFilterType
Definition: otbMNFImageFilter.h:75
otb::MNFImageFilter::MatrixType
MatrixObjectType::ComponentType MatrixType
Definition: otbMNFImageFilter.h:81
otb::MNFImageFilter::VectorType
CovarianceEstimatorFilterType::RealPixelType VectorType
Definition: otbMNFImageFilter.h:79
otb::MNFImageFilter::TransformDirectionEnumType
Transform::TransformDirection TransformDirectionEnumType
Definition: otbMNFImageFilter.h:67
otbPCAImageFilter.h
otb::MNFImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMNFImageFilter.h:53
otb::MNFImageFilter
Performs a Maximum Noise Fraction analysis of a vector image.
Definition: otbMNFImageFilter.h:47
otb::MNFImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbMNFImageFilter.h:72
otb::NormalizeVectorImageFilter
Normalize an VectorImage by setting its mean to zero and possibly variance to one (band by band).
Definition: otbNormalizeVectorImageFilter.h:132
otb::MNFImageFilter::m_Transformer
TransformFilterPointerType m_Transformer
Definition: otbMNFImageFilter.h:223
otb::MNFImageFilter::SetStdDevValues
void SetStdDevValues(const VectorType &vec)
Definition: otbMNFImageFilter.h:120
otb::StreamingStatisticsVectorImageFilter::RealType
StatFilterType::RealType RealType
Definition: otbStreamingStatisticsVectorImageFilter.h:318
otb::MNFImageFilter::m_EigenValues
VectorType m_EigenValues
Definition: otbMNFImageFilter.h:217