OTB  9.0.0
Orfeo Toolbox
otbFastICAImageFilter.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 otbFastICAImageFilter_h
22 #define otbFastICAImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbPCAImageFilter.h"
27 #include <functional>
28 
29 namespace otb
30 {
46 template <class TInputImage, class TOutputImage, Transform::TransformDirection TDirectionOfTransformation>
47 class ITK_EXPORT FastICAImageFilter : 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(FastICAImageFilter, 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 
76 
80  typedef typename MatrixType::InternalMatrixType InternalMatrixType;
81  typedef typename InternalMatrixType::element_type MatrixElementType;
82 
85 
88 
91 
92  typedef std::function<double(double)> NonLinearityType;
93 
97  itkGetMacro(NumberOfPrincipalComponentsRequired, unsigned int);
98  itkSetMacro(NumberOfPrincipalComponentsRequired, unsigned int);
100 
101  itkGetConstMacro(PCAFilter, PCAFilterType*);
102  itkGetMacro(PCAFilter, PCAFilterType*);
103 
104  itkGetConstMacro(TransformFilter, TransformFilterType*);
105  itkGetMacro(TransformFilter, TransformFilterType*);
106 
108  {
109  return this->GetPCAFilter()->GetMeanValues();
110  }
111  void SetMeanValues(const VectorType& vec)
112  {
113  m_PCAFilter->SetMeanValues(vec);
114  }
115 
117  {
118  return this->GetPCAFilter()->GetStdDevValues();
119  }
120  void SetStdDevValues(const VectorType& vec)
121  {
122  m_PCAFilter->SetStdDevValues(vec);
123  }
124 
126  {
127  return this->GetPCAFilter()->GetTransformationMatrix();
128  }
129  void SetPCATransformationMatrix(const MatrixType& mat, bool isForward = true)
130  {
131  m_PCAFilter->SetTransformationMatrix(mat, isForward);
132  }
133 
134  itkGetConstMacro(TransformationMatrix, MatrixType);
135  itkGetMacro(TransformationMatrix, MatrixType);
136  void SetTransformationMatrix(const MatrixType& mat, bool isForward = true)
137  {
138  m_IsTransformationForward = isForward;
139  m_GivenTransformationMatrix = true;
140  m_TransformationMatrix = mat;
141  this->Modified();
142  }
143 
144  itkGetMacro(NumberOfIterations, unsigned int);
145  itkSetMacro(NumberOfIterations, unsigned int);
146 
147  itkGetMacro(ConvergenceThreshold, double);
148  itkSetMacro(ConvergenceThreshold, double);
149 
150  void SetNonLinearity(NonLinearityType NonLinearity, NonLinearityType NonLinearityDerivative)
151  {
152  m_NonLinearity = NonLinearity;
153  m_NonLinearityDerivative = NonLinearityDerivative;
154  this->Modified();
155  }
156 
157  itkGetMacro(NonLinearity, NonLinearityType);
158  itkGetMacro(NonLinearityDerivative, NonLinearityType);
159 
160  itkGetMacro(Mu, double);
161  itkSetMacro(Mu, double);
162 
163 protected:
166  {
167  }
168 
177  void GenerateOutputInformation() override;
178 
182  void GenerateData() override;
183 
185  void ForwardGenerateOutputInformation();
186  void ReverseGenerateOutputInformation();
187  virtual void ForwardGenerateData();
188  virtual void ReverseGenerateData();
190 
192  virtual void GenerateTransformationMatrix();
193 
195 
200 
202  unsigned int m_NumberOfIterations; // def is 50
203  double m_ConvergenceThreshold; // def is 1e-4
204  NonLinearityType m_NonLinearity; // see g() function in the biblio. Def is tanh
206  double m_Mu; // def is 1. in [0, 1]
208 
211 
212 private:
213  FastICAImageFilter(const Self&) = delete;
214  void operator=(const Self&) = delete;
215 }; // end of class
216 
217 } // end of namespace otb
218 
219 #ifndef OTB_MANUAL_INSTANTIATION
220 #include "otbFastICAImageFilter.hxx"
221 #endif
222 
223 
224 #endif
otb::FastICAImageFilter::InputImageType
TInputImage InputImageType
Definition: otbFastICAImageFilter.h:71
otb::FastICAImageFilter::InternalOptimizerPointerType
InternalOptimizerType::Pointer InternalOptimizerPointerType
Definition: otbFastICAImageFilter.h:87
otb::FastICAImageFilter::MatrixElementType
InternalMatrixType::element_type MatrixElementType
Definition: otbFastICAImageFilter.h:81
otb::Transform::TransformDirection
TransformDirection
Definition: otbPCAImageFilter.h:34
otb::FastICAImageFilter::SetTransformationMatrix
void SetTransformationMatrix(const MatrixType &mat, bool isForward=true)
Definition: otbFastICAImageFilter.h:136
otb::FastICAImageFilter::InternalMatrixType
MatrixType::InternalMatrixType InternalMatrixType
Definition: otbFastICAImageFilter.h:80
otb::FastICAImageFilter::GetStdDevValues
VectorType GetStdDevValues() const
Definition: otbFastICAImageFilter.h:116
otb::FastICAImageFilter::PCAFilterType
PCAImageFilter< InputImageType, OutputImageType, TDirectionOfTransformation > PCAFilterType
Definition: otbFastICAImageFilter.h:74
otb::StreamingStatisticsVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStreamingStatisticsVectorImageFilter.h:304
otb::FastICAImageFilter::m_NonLinearity
NonLinearityType m_NonLinearity
Definition: otbFastICAImageFilter.h:204
otb::FastICAImageFilter::m_TransformationMatrix
MatrixType m_TransformationMatrix
Definition: otbFastICAImageFilter.h:199
otb::PCAImageFilter
Performs a Principal Component Analysis.
Definition: otbPCAImageFilter.h:53
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::FastICAImageFilter::GetPCATransformationMatrix
MatrixType GetPCATransformationMatrix() const
Definition: otbFastICAImageFilter.h:125
otb::FastICAImageFilter::TransformFilterPointerType
TransformFilterType::Pointer TransformFilterPointerType
Definition: otbFastICAImageFilter.h:84
otb::FastICAImageFilter::InternalOptimizerType
FastICAInternalOptimizerVectorImageFilter< InputImageType, InputImageType > InternalOptimizerType
Definition: otbFastICAImageFilter.h:86
otb::PCAImageFilter::VectorType
CovarianceEstimatorFilterType::RealPixelType VectorType
Definition: otbPCAImageFilter.h:85
otb::FastICAImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbFastICAImageFilter.h:72
otb::FastICAImageFilter::m_TransformFilter
TransformFilterPointerType m_TransformFilter
Definition: otbFastICAImageFilter.h:210
otb::FastICAImageFilter::m_PCAFilter
PCAFilterPointerType m_PCAFilter
Definition: otbFastICAImageFilter.h:209
otb::FastICAImageFilter::GetMeanValues
VectorType GetMeanValues() const
Definition: otbFastICAImageFilter.h:107
otb::FastICAImageFilter::MeanEstimatorFilterPointerType
MeanEstimatorFilterType::Pointer MeanEstimatorFilterPointerType
Definition: otbFastICAImageFilter.h:90
otb::FastICAImageFilter
Performs a Independent Component Analysis (ICA)
Definition: otbFastICAImageFilter.h:47
otbFastICAInternalOptimizerVectorImageFilter.h
otb::FastICAImageFilter::m_NumberOfPrincipalComponentsRequired
unsigned int m_NumberOfPrincipalComponentsRequired
Definition: otbFastICAImageFilter.h:194
otb::FastICAImageFilter::Self
FastICAImageFilter Self
Definition: otbFastICAImageFilter.h:51
otb::PCAImageFilter::MatrixType
MatrixObjectType::ComponentType MatrixType
Definition: otbPCAImageFilter.h:87
otb::FastICAImageFilter::SetNonLinearity
void SetNonLinearity(NonLinearityType NonLinearity, NonLinearityType NonLinearityDerivative)
Definition: otbFastICAImageFilter.h:150
otb::FastICAImageFilter::MeanEstimatorFilterType
StreamingStatisticsVectorImageFilter< InputImageType > MeanEstimatorFilterType
Definition: otbFastICAImageFilter.h:89
otb::FastICAImageFilter::~FastICAImageFilter
~FastICAImageFilter() override
Definition: otbFastICAImageFilter.h:165
otb::FastICAInternalOptimizerVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbFastICAInternalOptimizerVectorImageFilter.h:52
otb::FastICAImageFilter::m_GivenTransformationMatrix
bool m_GivenTransformationMatrix
Definition: otbFastICAImageFilter.h:197
otbFastICAImageFilter.hxx
otb::StreamingStatisticsVectorImageFilter
This class streams the whole input image through the PersistentStatisticsImageFilter.
Definition: otbStreamingStatisticsVectorImageFilter.h:297
otb::FastICAImageFilter::NonLinearityType
std::function< double(double)> NonLinearityType
Definition: otbFastICAImageFilter.h:92
otb::MatrixImageFilter
Apply a matrix multiplication over the channels of an image.
Definition: otbMatrixImageFilter.h:50
otb::FastICAImageFilter::m_NonLinearityDerivative
NonLinearityType m_NonLinearityDerivative
Definition: otbFastICAImageFilter.h:205
otb::FastICAImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbFastICAImageFilter.h:54
otb::FastICAImageFilter::SetStdDevValues
void SetStdDevValues(const VectorType &vec)
Definition: otbFastICAImageFilter.h:120
otb::FastICAImageFilter::SetMeanValues
void SetMeanValues(const VectorType &vec)
Definition: otbFastICAImageFilter.h:111
otb::FastICAImageFilter::MatrixType
PCAFilterType::MatrixType MatrixType
Definition: otbFastICAImageFilter.h:79
otb::PCAImageFilter::RealType
CovarianceEstimatorFilterType::RealType RealType
Definition: otbPCAImageFilter.h:84
otb::FastICAImageFilter::RealType
PCAFilterType::RealType RealType
Definition: otbFastICAImageFilter.h:77
otb::FastICAInternalOptimizerVectorImageFilter
Internal optimisation of the FastICA unmixing filter.
Definition: otbFastICAInternalOptimizerVectorImageFilter.h:46
otb::MatrixImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMatrixImageFilter.h:67
otb::FastICAImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbFastICAImageFilter.h:52
otb::PCAImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPCAImageFilter.h:59
otb::FastICAImageFilter::m_IsTransformationForward
bool m_IsTransformationForward
Definition: otbFastICAImageFilter.h:198
otb::FastICAImageFilter::TransformFilterType
MatrixImageFilter< TInputImage, TOutputImage > TransformFilterType
Definition: otbFastICAImageFilter.h:83
otbPCAImageFilter.h
otb::FastICAImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbFastICAImageFilter.h:53
otb::FastICAImageFilter::m_NumberOfIterations
unsigned int m_NumberOfIterations
Definition: otbFastICAImageFilter.h:202
otb::FastICAImageFilter::m_Mu
double m_Mu
Definition: otbFastICAImageFilter.h:206
otb::FastICAImageFilter::TransformDirectionEnumType
Transform::TransformDirection TransformDirectionEnumType
Definition: otbFastICAImageFilter.h:67
otb::FastICAImageFilter::SetPCATransformationMatrix
void SetPCATransformationMatrix(const MatrixType &mat, bool isForward=true)
Definition: otbFastICAImageFilter.h:129
otb::FastICAImageFilter::VectorType
PCAFilterType::VectorType VectorType
Definition: otbFastICAImageFilter.h:78
otb::FastICAImageFilter::m_ConvergenceThreshold
double m_ConvergenceThreshold
Definition: otbFastICAImageFilter.h:203
otb::FastICAImageFilter::PCAFilterPointerType
PCAFilterType::Pointer PCAFilterPointerType
Definition: otbFastICAImageFilter.h:75