1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef otbMNFImageFilter_h
#define otbMNFImageFilter_h
#include "otbPCAImageFilter.h"
namespace otb {
/** \class MNFImageFilter
* \brief Performs a Maximum Noise Fraction analysis of a vector image.
*
* The internal structure of this filter is a filter-to-filter like structure.
* The estimation of the covariance matrix is streamed
*
* The high pass filter which has to be used for the noise estimation is templated
* for a better scalability.
*
* TODO? Utiliser une 2e entree pour donner directement une image de bruit ?
*
* \sa otbStreamingStatisticsVectorImageFilter
* \sa PCAImageFiler
*
* \ingroup OTBDimensionalityReduction
*/
template <class TInputImage, class TOutputImage,
class TNoiseImageFilter,
Transform::TransformDirection TDirectionOfTransformation >
class ITK_EXPORT MNFImageFilter
: public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:
/** Standard typedefs */
typedef MNFImageFilter Self;
typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkNewMacro(Self);
/** Creation through object factory macro */
itkTypeMacro(MNFImageFilter, ImageToImageFilter);
/** Dimension */
itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
typedef Transform::TransformDirection TransformDirectionEnumType;
itkStaticConstMacro(DirectionOfTransformation, TransformDirectionEnumType, TDirectionOfTransformation);
/** Template parameters typedefs */
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
/** Filter types and related */
typedef StreamingStatisticsVectorImageFilter< InputImageType > CovarianceEstimatorFilterType;
typedef typename CovarianceEstimatorFilterType::Pointer CovarianceEstimatorFilterPointerType;
typedef typename CovarianceEstimatorFilterType::RealType RealType;
typedef typename CovarianceEstimatorFilterType::RealPixelType VectorType;
typedef typename CovarianceEstimatorFilterType::MatrixObjectType MatrixObjectType;
typedef typename MatrixObjectType::ComponentType MatrixType;
typedef typename MatrixType::InternalMatrixType InternalMatrixType;
typedef typename InternalMatrixType::element_type MatrixElementType;
typedef MatrixImageFilter< InputImageType, OutputImageType > TransformFilterType;
typedef typename TransformFilterType::Pointer TransformFilterPointerType;
typedef TNoiseImageFilter NoiseImageFilterType;
typedef typename NoiseImageFilterType::Pointer NoiseImageFilterPointerType;
typedef NormalizeVectorImageFilter< InputImageType, OutputImageType > NormalizeFilterType;
typedef typename NormalizeFilterType::Pointer NormalizeFilterPointerType;
/**
* Set/Get the number of required largest principal components.
*/
itkGetMacro(NumberOfPrincipalComponentsRequired, unsigned int);
itkSetMacro(NumberOfPrincipalComponentsRequired, unsigned int);
itkGetConstMacro(Normalizer, NormalizeFilterType*);
itkGetMacro(Normalizer, NormalizeFilterType*);
itkGetMacro(NoiseCovarianceEstimator, CovarianceEstimatorFilterType *);
itkGetMacro(Transformer, TransformFilterType *);
itkGetMacro(NoiseImageFilter, NoiseImageFilterType *);
/** Normalization only impact the use of variance. The data is always centered */
itkGetMacro(UseNormalization, bool);
itkSetMacro(UseNormalization, bool);
itkGetConstMacro(MeanValues, VectorType);
void SetMeanValues ( const VectorType & vec )
{
m_MeanValues = vec;
m_GivenMeanValues = true;
}
itkGetConstMacro(StdDevValues, VectorType);
void SetStdDevValues ( const VectorType & vec )
{
m_StdDevValues = vec;
m_UseNormalization = true;
m_GivenStdDevValues = true;
}
itkGetConstMacro(CovarianceMatrix, MatrixType);
void SetCovarianceMatrix ( const MatrixType & cov )
{
m_CovarianceMatrix = cov;
m_GivenCovarianceMatrix = true;
}
itkGetConstMacro(NoiseCovarianceMatrix, MatrixType);
void SetNoiseCovarianceMatrix ( const MatrixType & mat )
{
m_NoiseCovarianceMatrix = mat;
m_GivenNoiseCovarianceMatrix = true;
}
itkGetConstMacro(TransformationMatrix, MatrixType);
void SetTransformationMatrix( const MatrixType & transf, bool isForward = true )
{
m_TransformationMatrix = transf;
m_GivenTransformationMatrix = true;
m_IsTransformationMatrixForward = isForward;
}
itkGetConstMacro(EigenValues, VectorType);
protected:
MNFImageFilter();
~MNFImageFilter() ITK_OVERRIDE { }
/** GenerateOutputInformation
* Propagate vector length info and modify if needed
* NumberOfPrincipalComponentsRequired
*
* In REVERSE mode, the covariance matrix or the transformation matrix
* (which may not be square) has to be given,
* otherwize, GenerateOutputInformation throws an itk::ExceptionObject
*/
void GenerateOutputInformation() ITK_OVERRIDE;
/** GenerateData
* Through a filter of filter structure
*/
void GenerateData () ITK_OVERRIDE;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
/** Internal methods */
void ForwardGenerateOutputInformation();
void ReverseGenerateOutputInformation();
virtual void ForwardGenerateData();
virtual void ReverseGenerateData();
/** Specific functionality of MNF */
virtual void GenerateTransformationMatrix();
/** Internal attributes */
unsigned int m_NumberOfPrincipalComponentsRequired;
bool m_UseNormalization;
bool m_GivenMeanValues;
bool m_GivenStdDevValues;
bool m_GivenCovarianceMatrix;
bool m_GivenNoiseCovarianceMatrix;
bool m_GivenTransformationMatrix;
bool m_IsTransformationMatrixForward;
VectorType m_MeanValues;
VectorType m_StdDevValues;
MatrixType m_CovarianceMatrix;
MatrixType m_NoiseCovarianceMatrix;
MatrixType m_TransformationMatrix;
VectorType m_EigenValues;
NormalizeFilterPointerType m_Normalizer;
NoiseImageFilterPointerType m_NoiseImageFilter;
CovarianceEstimatorFilterPointerType m_CovarianceEstimator;
CovarianceEstimatorFilterPointerType m_NoiseCovarianceEstimator;
TransformFilterPointerType m_Transformer;
private:
MNFImageFilter( const Self & ); // not implemented
void operator=( const Self & ); // not implemented
}; // end of class
} // end of namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbMNFImageFilter.txx"
#endif
#endif
|