diff --git a/Code/BasicFilters/otbShiftScaleVectorImageFilter.h b/Code/BasicFilters/otbShiftScaleVectorImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..4387177dae64692fcd487e63682edd8c3a369f4f --- /dev/null +++ b/Code/BasicFilters/otbShiftScaleVectorImageFilter.h @@ -0,0 +1,211 @@ +/*========================================================================= + + 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 __otbShiftScaleImageFilter_h +#define __otbShiftScaleImageFilter_h + +#include "itkUnaryFunctorImageFilter.h" +#include "itkVariableLengthVector.h" + +namespace otb +{ +namespace Functor +{ +/** \class VectorShiftScale + * \brief This functor performs a per band linear transform of its input. + * + * For each band, the following formula is applied : + * + * \f[ output = \frac{input - shift}{scale} \f] + * + * Standard casting is applied between input and output type. + * + * Shifts and scales can be set via the SetShiftValues() and SetScaleValues() methods. + * + * TInput and TOutput type are supposed to be of type itk::VariableLengthVector. + * + */ +template<class TInput, class TOutput> +class VectorShiftScale +{ +public: +public: + /// Real type typedef + typedef typename itk::NumericTraits<typename TInput::ValueType>::RealType RealType; + + /// Constructor + VectorShiftScale() {} + + /// Constructor + virtual ~VectorShiftScale() {} + + /// Accessors + void SetShiftValues(TInput value) + { + m_Shift = value; + } + void SetScaleValues(TInput value) + { + m_Scale = value; + } + TInput GetShiftValues() + { + return m_Shift; + } + TInput GetScaleValues() + { + return m_Scale; + } + + bool operator !=(const VectorShiftScale& other) const + { + if (m_Shift.Size() == other.GetShiftValues().Size()) + { + for (unsigned int i = 0; i < m_Shift.Size(); ++i) + { + if (m_Shift[i] != other.GetShiftValues()[i]) + { + return true; + } + } + } + if (m_Scale.Size() == other.GetScaleValues().Size()) + { + for (unsigned int i = 0; i < m_Scale.Size(); ++i) + { + if (m_Scale[i] != other.GetScaleValues()[i]) + { + return true; + } + } + } + return false; + } + + bool operator==(const VectorShiftScale & other) const + { + return !(*this != other); + } + + // main computation method + inline TOutput operator()(const TInput & x) const + { + // output instantiation + TOutput result; + result.SetSize(x.GetSize()); + + // consistency checking + if (result.GetSize() != m_Scale.GetSize() + || result.GetSize() != m_Shift.GetSize()) + { + itkGenericExceptionMacro(<< "Pixel size different from scale or shift size !"); + } + + // transformation + for (unsigned int i = 0; i < x.GetSize(); ++i) + { + if ( m_Scale[i] > 1e-10) + { + const RealType invertedScale = 1 / m_Scale[i]; + result[i] = static_cast<typename TOutput::ValueType> (invertedScale * (x[i] - m_Shift[i]) ); + } + else + { + result[i] = static_cast<typename TOutput::ValueType> (x[i] - m_Shift[i]); + } + } + return result; + } + +private: + TInput m_Shift; + TOutput m_Scale; +}; +} // End namespace Functor + +/** \class ShiftScaleVectorImageFilter + * \brief This filter performs a shift and scaling of a vector image on a per band basis. + * + * \ingroup IntensityImageFilters + * \ingroup MultiThreaded + */ +template <class TInputImage, class TOutputImage = TInputImage> +class ITK_EXPORT ShiftScaleVectorImageFilter : + public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, + Functor::VectorShiftScale<ITK_TYPENAME TInputImage::PixelType, + ITK_TYPENAME TOutputImage::PixelType> > +{ +public: + /** Standard class typedefs. */ + typedef ShiftScaleVectorImageFilter Self; + typedef Functor::VectorShiftScale< ITK_TYPENAME TInputImage::PixelType, + ITK_TYPENAME TOutputImage::PixelType> + FunctorType; + typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, + FunctorType > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename TOutputImage::PixelType OutputPixelType; + typedef typename TInputImage::PixelType InputPixelType; + typedef typename InputPixelType::ValueType InputValueType; + typedef typename OutputPixelType::ValueType OutputValueType; + typedef typename itk::NumericTraits<InputValueType>::RealType InputRealType; + typedef typename itk::NumericTraits<OutputValueType>::RealType OutputRealType; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Runtime information support. */ + itkTypeMacro(ShiftScaleImageFilter, + itk::UnaryFunctorImageFilter); + + itkGetMacro(Scale, InputPixelType); + itkSetMacro(Scale, InputPixelType); + + itkGetMacro(Shift, InputPixelType); + itkSetMacro(Shift, InputPixelType); + + /** Process to execute before entering the multithreaded section */ + void BeforeThreadedGenerateData(void); + + /** Generate output information */ + void GenerateOutputInformation(void); + + /** Generate input requested region */ + void GenerateInputRequestedRegion(void); + +protected: + ShiftScaleVectorImageFilter() {} + virtual ~ShiftScaleVectorImageFilter() {} + +private: + ShiftScaleVectorImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + InputPixelType m_Scale; + InputPixelType m_Shift; + +}; + +} // end namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbShiftScaleVectorImageFilter.txx" +#endif + +#endif diff --git a/Code/BasicFilters/otbShiftScaleVectorImageFilter.txx b/Code/BasicFilters/otbShiftScaleVectorImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..826a99b669fd9ded2d619c3ef5b080733eb59629 --- /dev/null +++ b/Code/BasicFilters/otbShiftScaleVectorImageFilter.txx @@ -0,0 +1,71 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + Some parts of this code are derived from ITK. See ITKCopyright.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 __otbVectorRescaleIntensityImageFilter_txx +#define __otbVectorRescaleIntensityImageFilter_txx + +#include "otbShiftScaleVectorImageFilter.h" + +namespace otb +{ +/** + * Generate output information. + */ +template <class TInputImage, class TOutputImage> +void +ShiftScaleVectorImageFilter<TInputImage, TOutputImage> +::GenerateOutputInformation(void) +{ + this->Superclass::GenerateOutputInformation(); + this->GetOutput()->SetNumberOfComponentsPerPixel( + this->GetInput()->GetNumberOfComponentsPerPixel() + ); +} +/** + * Generate input requested region. + */ +template <class TInputImage, class TOutputImage> +void +ShiftScaleVectorImageFilter<TInputImage, TOutputImage> +::GenerateInputRequestedRegion(void) +{ + if (this->GetInput()) + { + typename TInputImage::Pointer input = const_cast<TInputImage *>(this->GetInput()); + typename TInputImage::RegionType inputRegion; + this->CallCopyOutputRegionToInputRegion(inputRegion, this->GetOutput()->GetRequestedRegion()); + input->SetRequestedRegion(inputRegion); + } +} +/** + * Process to execute before entering the multithreaded section. + */ +template <class TInputImage, class TOutputImage> +void +ShiftScaleVectorImageFilter<TInputImage, TOutputImage> +::BeforeThreadedGenerateData() +{ + // set up the functor values + this->GetFunctor().SetScaleValues(m_Scale); + this->GetFunctor().SetShiftValues(m_Shift); +} + +} // end namespace otb +#endif diff --git a/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.h b/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.h index 3caeb00321d67454dabcf32a03f495a429cc2ac7..371ff0dffa6750142a066ddca9761f918fec0858 100644 --- a/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.h +++ b/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.h @@ -33,8 +33,8 @@ namespace otb { -/** \class PersistentStatisticsVectorImageFilter - * \brief Compute min. max, covariance of a large image using streaming +/** \class PersistentStreamingStatisticsVectorImageFilter + * \brief Compute covariance & correlation of a large image using streaming * * This filter persists its temporary data. It means that if you Update it n times on n different * requested regions, the output statistics will be the statitics of the whole set of n regions. @@ -49,13 +49,13 @@ namespace otb * \ingroup MathematicalStatisticsImageFilters * */ -template<class TInputImage> -class ITK_EXPORT PersistentStatisticsVectorImageFilter : +template<class TInputImage, class TPrecision > +class ITK_EXPORT PersistentStreamingStatisticsVectorImageFilter : public PersistentImageFilter<TInputImage, TInputImage> { public: /** Standard Self typedef */ - typedef PersistentStatisticsVectorImageFilter Self; + typedef PersistentStreamingStatisticsVectorImageFilter Self; typedef PersistentImageFilter<TInputImage, TInputImage> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -64,56 +64,53 @@ public: itkNewMacro(Self); /** Runtime information support. */ - itkTypeMacro(PersistentStatisticsVectorImageFilter, PersistentImageFilter); + itkTypeMacro(PersistentStreamingStatisticsVectorImageFilter, PersistentImageFilter); /** Image related typedefs. */ - typedef TInputImage ImageType; - typedef typename TInputImage::Pointer InputImagePointer; - typedef typename TInputImage::RegionType RegionType; - typedef typename TInputImage::SizeType SizeType; - typedef typename TInputImage::IndexType IndexType; - typedef typename TInputImage::PixelType PixelType; - typedef typename TInputImage::InternalPixelType InternalPixelType; + typedef TInputImage ImageType; + typedef typename ImageType::Pointer InputImagePointer; + typedef typename ImageType::RegionType RegionType; + typedef typename ImageType::SizeType SizeType; + typedef typename ImageType::IndexType IndexType; + typedef typename ImageType::PixelType PixelType; + typedef typename ImageType::InternalPixelType InternalPixelType; - itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension); + typedef TPrecision PrecisionType; + typedef PrecisionType RealType; /** Image related typedefs. */ itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension); - /** Type to use for computations. */ - typedef typename itk::NumericTraits<InternalPixelType>::RealType RealType; - typedef itk::VariableLengthVector<RealType> RealPixelType; - /** Smart Pointer type to a DataObject. */ typedef typename itk::DataObject::Pointer DataObjectPointer; - /** Type of DataObjects used for scalar outputs */ - typedef typename itk::VariableSizeMatrix<RealType> MatrixType; - typedef typename std::vector<MatrixType> ArrayMatrixType; - typedef typename itk::Array<long> ArrayLongPixelType; - typedef typename std::vector<RealPixelType> ArrayRealPixelType; - typedef typename std::vector<PixelType> ArrayPixelType; - typedef itk::SimpleDataObjectDecorator<RealPixelType> RealPixelObjectType; + /** Type to use for computations. */ + typedef itk::VariableSizeMatrix<PrecisionType> MatrixType; + typedef itk::VariableLengthVector<PrecisionType> RealPixelType; + + /** Type of DataObjects used for outputs */ + typedef itk::SimpleDataObjectDecorator<IndexType> IndexObjectType; typedef itk::SimpleDataObjectDecorator<PixelType> PixelObjectType; + typedef itk::SimpleDataObjectDecorator<RealPixelType> RealPixelObjectType; typedef itk::SimpleDataObjectDecorator<MatrixType> MatrixObjectType; - /** Return the computed Minimum. */ + /** Return the computed Min */ PixelType GetMinimum() const { - return this->GetMinimumOutput()->Get(); + return this->GetMinOutput()->Get(); } PixelObjectType* GetMinimumOutput(); const PixelObjectType* GetMinimumOutput() const; - /** Return the computed Maximum. */ + /** Return the computed Max index */ PixelType GetMaximum() const { - return this->GetMaximumOutput()->Get(); + return this->GetMaxOutput()->Get(); } PixelObjectType* GetMaximumOutput(); const PixelObjectType* GetMaximumOutput() const; - /** Return the computed Mean. */ + /** Return the computed Mean. */ RealPixelType GetMean() const { return this->GetMeanOutput()->Get(); @@ -121,7 +118,7 @@ public: RealPixelObjectType* GetMeanOutput(); const RealPixelObjectType* GetMeanOutput() const; - /** Return the compute Sum. */ + /** Return the computed Sum. */ RealPixelType GetSum() const { return this->GetSumOutput()->Get(); @@ -129,6 +126,14 @@ public: RealPixelObjectType* GetSumOutput(); const RealPixelObjectType* GetSumOutput() const; + /** Return the computed Covariance. */ + MatrixType GetCorrelation() const + { + return this->GetCorrelation()->Get(); + } + MatrixObjectType* GetCorrelationOutput(); + const MatrixObjectType* GetCorrelationOutput() const; + /** Return the computed Covariance. */ MatrixType GetCovariance() const { @@ -142,45 +147,64 @@ public: */ virtual DataObjectPointer MakeOutput(unsigned int idx); + virtual void Reset(void); + + virtual void Synthetize(void); + + itkSetMacro(EnableMinMax, bool); + itkGetMacro(EnableMinMax, bool); + + itkSetMacro(EnableFirstOrderStats, bool); + itkGetMacro(EnableFirstOrderStats, bool); + + itkSetMacro(EnableSecondOrderStats, bool); + itkGetMacro(EnableSecondOrderStats, bool); + +protected: + PersistentStreamingStatisticsVectorImageFilter(); + + virtual ~PersistentStreamingStatisticsVectorImageFilter() {} + /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ virtual void AllocateOutputs(); + virtual void GenerateOutputInformation(); - virtual void Synthetize(void); - virtual void Reset(void); -protected: - PersistentStatisticsVectorImageFilter(); - virtual ~PersistentStatisticsVectorImageFilter() {} + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + /** Multi-thread version GenerateData. */ void ThreadedGenerateData(const RegionType& outputRegionForThread, int threadId); private: - PersistentStatisticsVectorImageFilter(const Self &); //purposely not implemented + PersistentStreamingStatisticsVectorImageFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - ArrayRealPixelType m_ThreadSum; - ArrayLongPixelType m_Count; - ArrayPixelType m_ThreadMin; - ArrayPixelType m_ThreadMax; - ArrayMatrixType m_XX; + bool m_EnableMinMax; + bool m_EnableFirstOrderStats; + bool m_EnableSecondOrderStats; + + std::vector<PixelType> m_ThreadMin; + std::vector<PixelType> m_ThreadMax; + std::vector<RealPixelType> m_ThreadFirstOrderAccumulators; + std::vector<MatrixType> m_ThreadSecondOrderAccumulators; -}; // end of class PersistentStatisticsVectorImageFilter +}; // end of class PersistentStreamingStatisticsVectorImageFilter /**===========================================================================*/ /** \class StreamingStatisticsVectorImageFilter * \brief This class streams the whole input image through the PersistentStatisticsImageFilter. * - * This way, it allows to compute the first order global statistics of this image. It calls the - * Reset() method of the PersistentStatisticsImageFilter before streaming the image and the - * Synthetize() method of the PersistentStatisticsImageFilter after having streamed the image + * This way, it allows to compute the first and second order global statistics of this image. It calls the + * Reset() method of the PersistentStreamingStatisticsVectorImageFilter before streaming the image and the + * Synthetize() method of the PersistentStreamingStatisticsVectorImageFilter after having streamed the image * to compute the statistics. The accessor on the results are wrapping the accessors of the - * internal PersistentStatisticsImageFilter. + * internal PersistentStreamingStatisticsVectorImageFilter. * - * \sa PersistentStatisticsVectorImageFilter + * \sa PersistentStreamingStatisticsVectorImageFilter * \sa PersistentImageFilter * \sa PersistentFilterStreamingDecorator * \sa StreamingImageVirtualWriter @@ -189,15 +213,15 @@ private: * \ingroup MathematicalStatisticsImageFilters */ -template<class TInputImage> +template<class TInputImage, class TPrecision = typename itk::NumericTraits<typename TInputImage::InternalPixelType>::RealType> class ITK_EXPORT StreamingStatisticsVectorImageFilter : - public PersistentFilterStreamingDecorator<PersistentStatisticsVectorImageFilter<TInputImage> > + public PersistentFilterStreamingDecorator<PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> > { public: /** Standard Self typedef */ typedef StreamingStatisticsVectorImageFilter Self; typedef PersistentFilterStreamingDecorator - <PersistentStatisticsVectorImageFilter<TInputImage> > Superclass; + <PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -209,18 +233,13 @@ public: typedef TInputImage InputImageType; typedef typename Superclass::FilterType StatFilterType; - typedef typename StatFilterType::PixelType PixelType; - typedef typename StatFilterType::RealType RealType; - typedef typename StatFilterType::RealPixelType RealPixelType; - typedef typename StatFilterType::MatrixType MatrixType; - typedef typename StatFilterType::ArrayMatrixType ArrayMatrixType; - typedef typename StatFilterType::ArrayLongPixelType ArrayLongPixelType; - typedef typename StatFilterType::ArrayRealPixelType ArrayRealPixelType; - typedef typename StatFilterType::ArrayPixelType ArrayPixelType; - - /** Type of DataObjects used for scalar outputs */ + + /** Type of DataObjects used for outputs */ + typedef typename StatFilterType::PixelType PixelType; + typedef typename StatFilterType::RealType RealType; + typedef typename StatFilterType::RealPixelType RealPixelType; typedef typename StatFilterType::RealPixelObjectType RealPixelObjectType; - typedef typename StatFilterType::PixelObjectType PixelObjectType; + typedef typename StatFilterType::MatrixType MatrixType; typedef typename StatFilterType::MatrixObjectType MatrixObjectType; void SetInput(InputImageType * input) @@ -232,30 +251,30 @@ public: return this->GetFilter()->GetInput(); } - /** Return the computed Minimum. */ - PixelType GetMinimum() const + /** Return the computed Mean. */ + RealPixelType GetMinimum() const { return this->GetFilter()->GetMinimumOutput()->Get(); } - PixelObjectType* GetMinimumOutput() + RealPixelObjectType* GetMinimumOutput() { return this->GetFilter()->GetMinimumOutput(); } - const PixelObjectType* GetMinimumOutput() const + const RealPixelObjectType* GetMinimumOutput() const { return this->GetFilter()->GetMinimumOutput(); } - /** Return the computed Maximum. */ - PixelType GetMaximum() const + /** Return the computed Mean. */ + RealPixelType GetMaximum() const { return this->GetFilter()->GetMaximumOutput()->Get(); } - PixelObjectType* GetMaximumOutput() + RealPixelObjectType* GetMaximumOutput() { return this->GetFilter()->GetMaximumOutput(); } - const PixelObjectType* GetMaximumOutput() const + const RealPixelObjectType* GetMaximumOutput() const { return this->GetFilter()->GetMaximumOutput(); } @@ -274,7 +293,7 @@ public: return this->GetFilter()->GetMeanOutput(); } - /** Return the compute Sum. */ + /** Return the computed Mean. */ RealPixelType GetSum() const { return this->GetFilter()->GetSumOutput()->Get(); @@ -302,9 +321,33 @@ public: return this->GetFilter()->GetCovarianceOutput(); } + /** Return the computed Covariance. */ + MatrixType GetCorrelation() const + { + return this->GetFilter()->GetCorrelationOutput()->Get(); + } + MatrixObjectType* GetCorrelationOutput() + { + return this->GetFilter()->GetCorrelationOutput(); + } + const MatrixObjectType* GetCorrelationOutput() const + { + return this->GetFilter()->GetCorrelationOutput(); + } + + otbSetObjectMemberMacro(Filter, EnableMinMax, bool); + otbGetObjectMemberMacro(Filter, EnableMinMax, bool); + + otbSetObjectMemberMacro(Filter, EnableFirstOrderStats, bool); + otbGetObjectMemberMacro(Filter, EnableFirstOrderStats, bool); + + otbSetObjectMemberMacro(Filter, EnableSecondOrderStats, bool); + otbGetObjectMemberMacro(Filter, EnableSecondOrderStats, bool); + protected: /** Constructor */ - StreamingStatisticsVectorImageFilter() {}; + StreamingStatisticsVectorImageFilter() {} + /** Destructor */ virtual ~StreamingStatisticsVectorImageFilter() {} diff --git a/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.txx b/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.txx index 6dbd12acabe9001ca11e25c036c7befcca9e0a5c..630c1282791331f3c59978f75248816d85a0ca04 100644 --- a/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.txx +++ b/Code/BasicFilters/otbStreamingStatisticsVectorImageFilter.txx @@ -31,40 +31,27 @@ for details. namespace otb { -template<class TInputImage> -PersistentStatisticsVectorImageFilter<TInputImage> -::PersistentStatisticsVectorImageFilter() +template<class TInputImage, class TPrecision> +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> +::PersistentStreamingStatisticsVectorImageFilter() + : m_EnableMinMax(true), + m_EnableFirstOrderStats(true), + m_EnableSecondOrderStats(true) { // first output is a copy of the image, DataObject created by // superclass - // - // allocate the data objects for the outputs which are - // just decorators around pixel types - - for (int i = 1; i < 3; ++i) - { - typename PixelObjectType::Pointer output = static_cast<PixelObjectType*>(this->MakeOutput(i).GetPointer()); - this->itk::ProcessObject::SetNthOutput(i, output.GetPointer()); - } // allocate the data objects for the outputs which are - // just decorators around real types - - for (int i = 3; i < 5; ++i) + // just decorators around vector/matrix types + for (unsigned int i = 1; i < 7; ++i) { - typename RealPixelObjectType::Pointer output = static_cast<RealPixelObjectType*>(this->MakeOutput(i).GetPointer()); - this->itk::ProcessObject::SetNthOutput(i, output.GetPointer()); + this->itk::ProcessObject::SetNthOutput(i, this->MakeOutput(i).GetPointer()); } - - // allocate the data objects for the outputs which are - // just decorators around matrix types - typename MatrixObjectType::Pointer output = static_cast<MatrixObjectType*>(this->MakeOutput(5).GetPointer()); - this->itk::ProcessObject::SetNthOutput(5, output.GetPointer()); } -template<class TInputImage> +template<class TInputImage, class TPrecision> itk::DataObject::Pointer -PersistentStatisticsVectorImageFilter<TInputImage> +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::MakeOutput(unsigned int output) { switch (output) @@ -74,13 +61,17 @@ PersistentStatisticsVectorImageFilter<TInputImage> break; case 1: case 2: + // min/max return static_cast<itk::DataObject*>(PixelObjectType::New().GetPointer()); break; case 3: case 4: + // mean / sum return static_cast<itk::DataObject*>(RealPixelObjectType::New().GetPointer()); break; case 5: + case 6: + // covariance / correlation return static_cast<itk::DataObject*>(MatrixObjectType::New().GetPointer()); break; default: @@ -88,92 +79,107 @@ PersistentStatisticsVectorImageFilter<TInputImage> return static_cast<itk::DataObject*>(TInputImage::New().GetPointer()); break; } - } -template<class TInputImage> -typename PersistentStatisticsVectorImageFilter<TInputImage>::PixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::PixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetMinimumOutput() { return static_cast<PixelObjectType*>(this->itk::ProcessObject::GetOutput(1)); } -template<class TInputImage> -const typename PersistentStatisticsVectorImageFilter<TInputImage>::PixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +const typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::PixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetMinimumOutput() const { return static_cast<const PixelObjectType*>(this->itk::ProcessObject::GetOutput(1)); } -template<class TInputImage> -typename PersistentStatisticsVectorImageFilter<TInputImage>::PixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::PixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetMaximumOutput() { return static_cast<PixelObjectType*>(this->itk::ProcessObject::GetOutput(2)); } -template<class TInputImage> -const typename PersistentStatisticsVectorImageFilter<TInputImage>::PixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +const typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::PixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetMaximumOutput() const { return static_cast<const PixelObjectType*>(this->itk::ProcessObject::GetOutput(2)); } -template<class TInputImage> -typename PersistentStatisticsVectorImageFilter<TInputImage>::RealPixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::RealPixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetMeanOutput() { return static_cast<RealPixelObjectType*>(this->itk::ProcessObject::GetOutput(3)); } -template<class TInputImage> -const typename PersistentStatisticsVectorImageFilter<TInputImage>::RealPixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +const typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::RealPixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetMeanOutput() const { return static_cast<const RealPixelObjectType*>(this->itk::ProcessObject::GetOutput(3)); } -template<class TInputImage> -typename PersistentStatisticsVectorImageFilter<TInputImage>::RealPixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::RealPixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetSumOutput() { return static_cast<RealPixelObjectType*>(this->itk::ProcessObject::GetOutput(4)); } -template<class TInputImage> -const typename PersistentStatisticsVectorImageFilter<TInputImage>::RealPixelObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> +template<class TInputImage, class TPrecision> +const typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::RealPixelObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GetSumOutput() const { return static_cast<const RealPixelObjectType*>(this->itk::ProcessObject::GetOutput(4)); } -template<class TInputImage> -typename PersistentStatisticsVectorImageFilter<TInputImage>::MatrixObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> -::GetCovarianceOutput() +template<class TInputImage, class TPrecision> +typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::MatrixObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> +::GetCorrelationOutput() { return static_cast<MatrixObjectType*>(this->itk::ProcessObject::GetOutput(5)); } -template<class TInputImage> -const typename PersistentStatisticsVectorImageFilter<TInputImage>::MatrixObjectType* -PersistentStatisticsVectorImageFilter<TInputImage> -::GetCovarianceOutput() const +template<class TInputImage, class TPrecision> +const typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::MatrixObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> +::GetCorrelationOutput() const { return static_cast<const MatrixObjectType*>(this->itk::ProcessObject::GetOutput(5)); } -template<class TInputImage> +template<class TInputImage, class TPrecision> +typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::MatrixObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> +::GetCovarianceOutput() +{ + return static_cast<MatrixObjectType*>(this->itk::ProcessObject::GetOutput(6)); +} + +template<class TInputImage, class TPrecision> +const typename PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision>::MatrixObjectType* +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> +::GetCovarianceOutput() const +{ + return static_cast<const MatrixObjectType*>(this->itk::ProcessObject::GetOutput(6)); +} + +template<class TInputImage, class TPrecision> void -PersistentStatisticsVectorImageFilter<TInputImage> +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::GenerateOutputInformation() { Superclass::GenerateOutputInformation(); @@ -189,9 +195,9 @@ PersistentStatisticsVectorImageFilter<TInputImage> } } -template<class TInputImage> +template<class TInputImage, class TPrecision> void -PersistentStatisticsVectorImageFilter<TInputImage> +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::AllocateOutputs() { // This is commented to prevent the streaming of the whole image for the first stream strip @@ -201,9 +207,9 @@ PersistentStatisticsVectorImageFilter<TInputImage> // Nothing that needs to be allocated for the remaining outputs } -template<class TInputImage> +template<class TInputImage, class TPrecision> void -PersistentStatisticsVectorImageFilter<TInputImage> +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::Reset() { TInputImage * inputPtr = const_cast<TInputImage *>(this->GetInput()); @@ -212,255 +218,206 @@ PersistentStatisticsVectorImageFilter<TInputImage> unsigned int numberOfThreads = this->GetNumberOfThreads(); unsigned int numberOfComponent = inputPtr->GetNumberOfComponentsPerPixel(); - // Variable Initialization - PixelType tempPixel; - tempPixel.SetSize(numberOfComponent); - tempPixel.Fill(itk::NumericTraits<InternalPixelType>::NonpositiveMin()); - this->GetMaximumOutput()->Set(tempPixel); - - tempPixel.Fill(itk::NumericTraits<InternalPixelType>::max()); - this->GetMinimumOutput()->Set(tempPixel); + if (m_EnableMinMax) + { + PixelType tempPixel; + tempPixel.SetSize(numberOfComponent); - RealPixelType tempRealPixel; - tempRealPixel.SetSize(numberOfComponent); - tempRealPixel.Fill(itk::NumericTraits<RealType>::max()); - this->GetMeanOutput()->Set(tempRealPixel); + tempPixel.Fill(itk::NumericTraits<InternalPixelType>::max()); + this->GetMinimumOutput()->Set(tempPixel); - tempRealPixel.Fill(itk::NumericTraits<RealType>::Zero); - this->GetMeanOutput()->Set(tempRealPixel); + tempPixel.Fill(itk::NumericTraits<InternalPixelType>::NonpositiveMin()); + this->GetMaximumOutput()->Set(tempPixel); - MatrixType tempMatrix; - tempMatrix.SetSize(numberOfComponent, numberOfComponent); - tempMatrix.Fill(itk::NumericTraits<RealType>::Zero); + PixelType tempTemporiesPixel; + tempTemporiesPixel.SetSize(numberOfComponent); + tempTemporiesPixel.Fill(itk::NumericTraits<InternalPixelType>::max()); + m_ThreadMin = std::vector<PixelType>(numberOfThreads, tempTemporiesPixel); - // Initialize the tempories - m_Count.SetSize(numberOfThreads); - m_Count.Fill(itk::NumericTraits<long>::Zero); + tempTemporiesPixel.Fill(itk::NumericTraits<InternalPixelType>::NonpositiveMin()); + m_ThreadMax = std::vector<PixelType>(numberOfThreads, tempTemporiesPixel); + } - PixelType tempTemporiesPixel; - tempTemporiesPixel.SetSize(numberOfComponent); - tempTemporiesPixel.Fill(itk::NumericTraits<InternalPixelType>::max()); - m_ThreadMin = ArrayPixelType(numberOfThreads, tempTemporiesPixel); + if (m_EnableSecondOrderStats) + { + m_EnableFirstOrderStats = true; + } - tempTemporiesPixel.Fill(itk::NumericTraits<InternalPixelType>::NonpositiveMin()); - m_ThreadMax = ArrayPixelType(numberOfThreads, tempTemporiesPixel); + if (m_EnableFirstOrderStats) + { + RealPixelType zeroRealPixel; + zeroRealPixel.SetSize(numberOfComponent); + zeroRealPixel.Fill(itk::NumericTraits<PrecisionType>::Zero); + this->GetMeanOutput()->Set(zeroRealPixel); + this->GetSumOutput()->Set(zeroRealPixel); + + m_ThreadFirstOrderAccumulators.resize(numberOfThreads); + std::fill(m_ThreadFirstOrderAccumulators.begin(), m_ThreadFirstOrderAccumulators.end(), zeroRealPixel); + } - RealPixelType tempTemporiesRealPixel; - tempTemporiesRealPixel.SetSize(numberOfComponent); - tempTemporiesRealPixel.Fill(itk::NumericTraits<RealType>::Zero); - m_ThreadSum = ArrayRealPixelType(numberOfThreads, tempTemporiesRealPixel); + if (m_EnableSecondOrderStats) + { + MatrixType zeroMatrix; + zeroMatrix.SetSize(numberOfComponent, numberOfComponent); + zeroMatrix.Fill(itk::NumericTraits<PrecisionType>::Zero); + this->GetCovarianceOutput()->Set(zeroMatrix); + this->GetCorrelationOutput()->Set(zeroMatrix); + + m_ThreadSecondOrderAccumulators.resize(numberOfThreads); + std::fill(m_ThreadSecondOrderAccumulators.begin(), m_ThreadSecondOrderAccumulators.end(), zeroMatrix); + } - m_XX = ArrayMatrixType(numberOfThreads, tempMatrix); } -template<class TInputImage> +template<class TInputImage, class TPrecision> void -PersistentStatisticsVectorImageFilter<TInputImage> +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::Synthetize() { - int i; - long count; - - int numberOfThreads = this->GetNumberOfThreads(); - unsigned int numberOfComponent = this->GetInput()->GetNumberOfComponentsPerPixel(); - - PixelType minimumVector; - minimumVector.SetSize(numberOfComponent); - minimumVector.Fill(itk::NumericTraits<InternalPixelType>::max()); - - PixelType maximumVector; - maximumVector.SetSize(numberOfComponent); - maximumVector.Fill(itk::NumericTraits<InternalPixelType>::NonpositiveMin()); - - RealPixelType sumVector; - sumVector.SetSize(numberOfComponent); - sumVector.Fill(itk::NumericTraits<RealType>::Zero); - - RealPixelType meanVector; - meanVector.SetSize(numberOfComponent); - MatrixType crossedMatrix; - crossedMatrix.SetSize(numberOfComponent, numberOfComponent); - crossedMatrix.Fill(itk::NumericTraits<RealType>::Zero); - count = 0; - - // Find the min/max over all threads and accumulate count, sum and - // sum of squares - for (i = 0; i < numberOfThreads; ++i) + TInputImage * inputPtr = const_cast<TInputImage *>(this->GetInput()); + const unsigned int nbPixels = inputPtr->GetLargestPossibleRegion().GetNumberOfPixels(); + const unsigned int numberOfComponent = inputPtr->GetNumberOfComponentsPerPixel(); + + PixelType minimum; + minimum.SetSize(numberOfComponent); + minimum.Fill(itk::NumericTraits<InternalPixelType>::max()); + PixelType maximum; + maximum.SetSize(numberOfComponent); + maximum.Fill(itk::NumericTraits<InternalPixelType>::NonpositiveMin()); + + RealPixelType streamFirstOrderAccumulator(numberOfComponent); + streamFirstOrderAccumulator.Fill(itk::NumericTraits<PrecisionType>::Zero); + MatrixType streamSecondOrderAccumulator(numberOfComponent, numberOfComponent); + streamSecondOrderAccumulator.Fill(itk::NumericTraits<PrecisionType>::Zero); + + // Accumulate results from all threads + const unsigned int numberOfThreads = this->GetNumberOfThreads(); + for (unsigned int threadId = 0; threadId < numberOfThreads; ++threadId) { - count += m_Count[i]; - /** TODO - * To modify using + method operator. If we use it now -> exceptionmacro (no GetClassName...) - * crossedMatrix += m_XX[i]; - **/ - if ((m_XX[i].Rows() != crossedMatrix.Rows()) || (m_XX[i].Cols() != crossedMatrix.Cols())) + if (m_EnableMinMax) { - itkExceptionMacro(<< "Matrix with size (" << m_XX[i].Rows() << "," << - m_XX[i].Cols() << ") cannot be subtracted from matrix with size (" << - crossedMatrix.Rows() << "," << crossedMatrix.Cols()); - } + const PixelType& threadMin = m_ThreadMin [threadId]; + const PixelType& threadMax = m_ThreadMax [threadId]; - for (unsigned int r = 0; r < m_XX[i].Rows(); ++r) - { - for (unsigned int c = 0; c < m_XX[i].Cols(); ++c) + for (unsigned int j = 0; j < numberOfComponent; ++j) { - crossedMatrix(r, c) += m_XX[i](r, c); + if (threadMin[j] < minimum[j]) + { + minimum[j] = threadMin[j]; + } + if (threadMax[j] > maximum[j]) + { + maximum[j] = threadMax[j]; + } } } - //**** END TODO **** - for (unsigned int j = 0; j < numberOfComponent; ++j) - { - sumVector[j] += m_ThreadSum[i][j]; - if (m_ThreadMin[i][j] < minimumVector[j]) - { - minimumVector[j] = m_ThreadMin[i][j]; - } - if (m_ThreadMax[i][j] > maximumVector[j]) - { - maximumVector[j] = m_ThreadMax[i][j]; - } - } - } // end for( i = 0; i < numberOfThreads; ++i) + if (m_EnableFirstOrderStats) + streamFirstOrderAccumulator += m_ThreadFirstOrderAccumulators [threadId]; - for (unsigned int j = 0; j < numberOfComponent; ++j) - { - // compute statistics - meanVector[j] = sumVector[j] / static_cast<RealType>(count); + if (m_EnableSecondOrderStats) + streamSecondOrderAccumulator += m_ThreadSecondOrderAccumulators[threadId]; } - // Compute Matrix Covariance - MatrixType pixelSumMatrix; - pixelSumMatrix.SetSize(static_cast<unsigned int>(numberOfComponent), 1); - pixelSumMatrix.Fill(itk::NumericTraits<RealType>::Zero); - for (unsigned int j = 0; j < numberOfComponent; ++j) + // Final calculations + if (m_EnableMinMax) { - pixelSumMatrix(j, 0) = sumVector[j]; + this->GetMinimumOutput()->Set(minimum); + this->GetMaximumOutput()->Set(maximum); } - MatrixType covMatrix, covMatrixTemp, tempTranspose; - covMatrix.SetSize(static_cast<unsigned int>(numberOfComponent), static_cast<unsigned int>(numberOfComponent)); - covMatrixTemp.SetSize(static_cast<unsigned int>(numberOfComponent), static_cast<unsigned int>(numberOfComponent)); - tempTranspose.SetSize(1, static_cast<unsigned int>(numberOfComponent)); - - covMatrix = crossedMatrix / static_cast<RealType>(count); - pixelSumMatrix /= static_cast<RealType>(count); - tempTranspose = pixelSumMatrix.GetTranspose(); - covMatrixTemp = pixelSumMatrix * tempTranspose; - /** TODO - * To modify using - method operator. If we use it now -> exceptionmacro (no GetClassName...) - *covMatrix -= covMatrixTemp; - **/ - if ((covMatrix.Rows() != covMatrixTemp.Rows()) || (covMatrix.Cols() != covMatrixTemp.Cols())) + if (m_EnableFirstOrderStats) { - itkExceptionMacro(<< "Matrix with size (" << covMatrix.Rows() << "," << - covMatrix.Cols() << ") cannot be subtracted from matrix with size (" << - covMatrixTemp.Rows() << "," << covMatrixTemp.Cols()); + this->GetMeanOutput()->Set(streamFirstOrderAccumulator / nbPixels); + this->GetSumOutput()->Set(streamFirstOrderAccumulator); } - for (unsigned int r = 0; r < covMatrix.Rows(); ++r) + if (m_EnableSecondOrderStats) { - for (unsigned int c = 0; c < covMatrix.Cols(); ++c) + MatrixType cor = streamSecondOrderAccumulator / nbPixels; + this->GetCorrelationOutput()->Set(cor); + + const RealPixelType& mean = this->GetMeanOutput()->Get(); + const double regul = static_cast<double>(nbPixels) / (nbPixels - 1); + MatrixType cov = cor; + for (unsigned int r = 0; r < numberOfComponent; ++r) { - covMatrix(r, c) -= covMatrixTemp(r, c); + for (unsigned int c = 0; c < numberOfComponent; ++c) + { + cov(r, c) = regul * (cov(r, c) - mean[r] * mean[c]); + } } + this->GetCovarianceOutput()->Set(cov); } - //**** END TODO ****/ - - // Set the outputs - this->GetMinimumOutput()->Set(minimumVector); - this->GetMaximumOutput()->Set(maximumVector); - this->GetMeanOutput()->Set(meanVector); - this->GetSumOutput()->Set(sumVector); - this->GetCovarianceOutput()->Set(covMatrix); } -template<class TInputImage> +template<class TInputImage, class TPrecision> void -PersistentStatisticsVectorImageFilter<TInputImage> +PersistentStreamingStatisticsVectorImageFilter<TInputImage, TPrecision> ::ThreadedGenerateData(const RegionType& outputRegionForThread, int threadId) { - /** - * Grab the input - */ - InputImagePointer inputPtr = const_cast<TInputImage *>(this->GetInput()); - // support progress methods/callbacks + // Support progress methods/callbacks itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); - MatrixType pixelVector, pixelTransposeVector, pixelSumVector, tempMatrix; - - pixelVector.SetSize(this->GetInput()->GetNumberOfComponentsPerPixel(), 1); - pixelVector.Fill(itk::NumericTraits<RealType>::Zero); - pixelTransposeVector.SetSize(1, this->GetInput()->GetNumberOfComponentsPerPixel()); - pixelTransposeVector.Fill(itk::NumericTraits<RealType>::Zero); - pixelSumVector.SetSize(this->GetInput()->GetNumberOfComponentsPerPixel(), - this->GetInput()->GetNumberOfComponentsPerPixel()); - pixelSumVector.Fill(itk::NumericTraits<RealType>::Zero); - tempMatrix.SetSize(this->GetInput()->GetNumberOfComponentsPerPixel(), this->GetInput()->GetNumberOfComponentsPerPixel()); + // Grab the input + InputImagePointer inputPtr = const_cast<TInputImage *>(this->GetInput()); + PixelType& threadMin = m_ThreadMin [threadId]; + PixelType& threadMax = m_ThreadMax [threadId]; + RealPixelType& threadFirstOrder = m_ThreadFirstOrderAccumulators [threadId]; + MatrixType& threadSecondOrder = m_ThreadSecondOrderAccumulators[threadId]; itk::ImageRegionConstIteratorWithIndex<TInputImage> it(inputPtr, outputRegionForThread); - it.GoToBegin(); - // do the work - while (!it.IsAtEnd()) + + for (it.GoToBegin(); !it.IsAtEnd(); ++it, progress.CompletedPixel()) { - IndexType index = it.GetIndex(); - PixelType vectorValue = it.Get(); - for (unsigned int j = 0; j < vectorValue.GetSize(); ++j) - { - InternalPixelType value = vectorValue[j]; + const PixelType& vectorValue = it.Get(); - RealType realValue = static_cast<RealType>(value); - if (value < m_ThreadMin[threadId][j]) - { - m_ThreadMin[threadId][j] = value; - } - if (value > m_ThreadMax[threadId][j]) + if (m_EnableMinMax) + { + for (unsigned int j = 0; j < vectorValue.GetSize(); ++j) { - m_ThreadMax[threadId][j] = value; + if (vectorValue[j] < threadMin[j]) + { + threadMin[j] = vectorValue[j]; + } + if (vectorValue[j] > threadMax[j]) + { + threadMax[j] = vectorValue[j]; + } } - m_ThreadSum[threadId][j] += realValue; - pixelVector(j, 0) = realValue; } - ++it; - progress.CompletedPixel(); - pixelTransposeVector = pixelVector.GetTranspose(); - /** TODO - * To modify using + method operator. If we use it now -> exceptionmacro (no GetClassName...) - * m_XX[threadId]+=pixelVector*pixelTransposeVector; - **/ - tempMatrix = pixelVector * pixelTransposeVector; - if ((m_XX[threadId].Rows() != tempMatrix.Rows()) || (m_XX[threadId].Cols() != tempMatrix.Cols())) + if (m_EnableFirstOrderStats) { - itkExceptionMacro(<< "Matrix with size (" << m_XX[threadId].Rows() << "," << - m_XX[threadId].Cols() << ") cannot be subtracted from matrix with size (" << - tempMatrix.Rows() << "," << tempMatrix.Cols()); + threadFirstOrder += vectorValue; } - for (unsigned int r = 0; r < m_XX[threadId].Rows(); ++r) + if (m_EnableSecondOrderStats) { - for (unsigned int c = 0; c < m_XX[threadId].Cols(); ++c) + for (unsigned int r = 0; r < threadSecondOrder.Rows(); ++r) { - m_XX[threadId](r, c) += tempMatrix(r, c); + for (unsigned int c = 0; c < threadSecondOrder.Cols(); ++c) + { + threadSecondOrder(r, c) += vectorValue[r] * vectorValue[c]; + } } } - //**** END TODO **** - m_Count[threadId]++; + } } -template <class TImage> +template <class TImage, class TPrecision> void -PersistentStatisticsVectorImageFilter<TImage> +PersistentStreamingStatisticsVectorImageFilter<TImage, TPrecision> ::PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os, indent); - os << indent << "Minimum: " << this->GetMinimumOutput()->Get() << std::endl; - os << indent << "Maximum: " << this->GetMaximumOutput()->Get() << std::endl; - os << indent << "Sum: " << this->GetSumOutput()->Get() << std::endl; - os << indent << "Mean: " << this->GetMeanOutput()->Get() << std::endl; - os << indent << "Covariance: " << this->GetCovarianceOutput()->Get() << std::endl; - + os << indent << "Min: " << this->GetMinimumOutput()->Get() << std::endl; + os << indent << "Max: " << this->GetMaximumOutput()->Get() << std::endl; + os << indent << "Mean: " << this->GetMeanOutput()->Get() << std::endl; + os << indent << "Covariance: " << this->GetCovarianceOutput()->Get() << std::endl; + os << indent << "Correlation: " << this->GetCorrelationOutput()->Get() << std::endl; } } // end namespace otb diff --git a/Code/BasicFilters/otbVectorRescaleIntensityImageFilter.h b/Code/BasicFilters/otbVectorRescaleIntensityImageFilter.h index 49f9dadf9728639e4b711b417360ec582dcda0fa..c513765e9afa305784188dda38c2ce754b4804e1 100644 --- a/Code/BasicFilters/otbVectorRescaleIntensityImageFilter.h +++ b/Code/BasicFilters/otbVectorRescaleIntensityImageFilter.h @@ -85,7 +85,7 @@ public: bool operator !=(const VectorAffineTransform& other) const { - if (m_OutputMaximum.Size() == other.GetOutputMinimum().Size()) + if (m_OutputMinimum.Size() == other.GetOutputMinimum().Size()) { for (unsigned int i = 0; i < m_OutputMinimum.Size(); ++i) { diff --git a/Code/Common/otbImageRegionSquareTileSplitter.txx b/Code/Common/otbImageRegionSquareTileSplitter.txx index 6870b8dd034b2cef25ba00ab21b28721a2aa40bd..a964c82dd4f6ced85a42ac04a6f77a2b77baee63 100644 --- a/Code/Common/otbImageRegionSquareTileSplitter.txx +++ b/Code/Common/otbImageRegionSquareTileSplitter.txx @@ -33,8 +33,8 @@ ImageRegionSquareTileSplitter<VImageDimension> unsigned int theoricalNbPixelPerTile = region.GetNumberOfPixels() / requestedNumber; unsigned int theoricalTileDimension = static_cast<unsigned int> (vcl_sqrt(static_cast<double>(theoricalNbPixelPerTile)) ); - // Take the previous multiple of m_TileSizeAlignment (eventually generate more splits than requested) - m_TileDimension = theoricalTileDimension / m_TileSizeAlignment * m_TileSizeAlignment; + // Take the next multiple of m_TileSizeAlignment (eventually generate more splits than requested) + m_TileDimension = (theoricalTileDimension + m_TileSizeAlignment - 1) / m_TileSizeAlignment * m_TileSizeAlignment; // Minimal tile size is m_TileSizeAlignment * m_TileSizeAlignment if (m_TileDimension < m_TileSizeAlignment) diff --git a/Code/Common/otbRemoteSensingRegion.h b/Code/Common/otbRemoteSensingRegion.h index befd72d3d98a103d183e7ed997a467a175763a42..e6f5376d0f57f48d8f5c209f153da3cf8f23533c 100644 --- a/Code/Common/otbRemoteSensingRegion.h +++ b/Code/Common/otbRemoteSensingRegion.h @@ -397,6 +397,7 @@ TransformPhysicalRegionToIndexRegion(const RemoteSensingRegionType& region, cons return outputRegion; } + } // end namespace otb #endif diff --git a/Code/FeatureExtraction/otbLineSegmentDetector.h b/Code/FeatureExtraction/otbLineSegmentDetector.h index 696460ece1dd2338a9cde50c6348740ed323f382..900d9ca5cb98caa234012e21a705d7779438f7a0 100644 --- a/Code/FeatureExtraction/otbLineSegmentDetector.h +++ b/Code/FeatureExtraction/otbLineSegmentDetector.h @@ -166,9 +166,6 @@ public: virtual void SetInput(const InputImageType *input); virtual const InputImageType * GetInput(void); - itkSetMacro(ImageSize, SizeType); - itkGetMacro(ImageSize, SizeType); - /** Custom Get methods to access intermediate data*/ LabelImagePointerType GetMap() { @@ -187,8 +184,8 @@ protected: LineSegmentDetector(); virtual ~LineSegmentDetector() {} - /** Before Generate Data method*/ - virtual void BeforeGenerateData(); + virtual void GenerateInputRequestedRegion(); + /** Generate Data method*/ virtual void GenerateData(); @@ -265,12 +262,6 @@ private: double m_Prec; double m_DirectionsAllowed; unsigned int m_MinimumRegionSize; - unsigned int m_NumberOfImagePixels; - - /** The image size has to be the LargestPosssibleRegion in the case - * (streaming uses (streaming decorator). - */ - SizeType m_ImageSize; /** Gradient filter */ GradientFilterPointerType m_GradientFilter; diff --git a/Code/FeatureExtraction/otbLineSegmentDetector.txx b/Code/FeatureExtraction/otbLineSegmentDetector.txx index ce6551dd8e39aa20b41b0f7fb20e98b1f02479d9..5ae1b2cde48098281b316957c2287d4d19a0ded7 100644 --- a/Code/FeatureExtraction/otbLineSegmentDetector.txx +++ b/Code/FeatureExtraction/otbLineSegmentDetector.txx @@ -63,8 +63,6 @@ LineSegmentDetector<TInputImage, TPrecision> /** Image to store the pixels used 0:NOTUSED 127:NOTINIT 255:USED*/ m_UsedPointImage = LabelImageType::New(); - - m_ImageSize.Fill(0); } template <class TInputImage, class TPrecision> @@ -92,17 +90,23 @@ LineSegmentDetector<TInputImage, TPrecision> template <class TInputImage, class TPrecision> void LineSegmentDetector<TInputImage, TPrecision> -::BeforeGenerateData() +::GenerateInputRequestedRegion(void) { - if (this->GetInput()->GetRequestedRegion() != this->GetInput()->GetLargestPossibleRegion()) + // call the superclass' implementation of this method + Superclass::GenerateInputRequestedRegion(); + + // get pointers to the inputs + typename InputImageType::Pointer input = + const_cast<InputImageType *> (this->GetInput()); + + if ( !input ) { - itkExceptionMacro(<< "No streamed filter. ERROR : requested region is not the largest possible region."); + return; } - /** Allocate memory for the temporary label Image*/ - m_UsedPointImage->SetRegions(this->GetInput()->GetLargestPossibleRegion()); - m_UsedPointImage->Allocate(); - m_UsedPointImage->FillBuffer(0); + // The input is necessarily the largest possible region. + // For a streamed implementation, use the StreamingLineSegmentDetector filter + input->SetRequestedRegionToLargestPossibleRegion(); } template <class TInputImage, class TPrecision> @@ -110,7 +114,15 @@ void LineSegmentDetector<TInputImage, TPrecision> ::GenerateData() { - this->BeforeGenerateData(); + if (this->GetInput()->GetRequestedRegion() != this->GetInput()->GetLargestPossibleRegion()) + { + itkExceptionMacro(<< "Not streamed filter. ERROR : requested region is not the largest possible region."); + } + + /** Allocate memory for the temporary label Image*/ + m_UsedPointImage->SetRegions(this->GetInput()->GetLargestPossibleRegion()); + m_UsedPointImage->Allocate(); + m_UsedPointImage->FillBuffer(0); /** Cast the MagnitudeOutput Image in */ typedef itk::CastImageFilter<InputImageType, OutputImageType> castFilerType; @@ -143,20 +155,13 @@ typename LineSegmentDetector<TInputImage, TPrecision> LineSegmentDetector<TInputImage, TPrecision> ::SortImageByModulusValue(MagnitudeImagePointerType modulusImage) { - if (m_ImageSize[0] == 0 && m_ImageSize[1] == 0) m_ImageSize = this->GetInput()->GetLargestPossibleRegion().GetSize(); - - m_NumberOfImagePixels = static_cast<unsigned int>(m_ImageSize[1] * m_ImageSize[0]); + RegionType largestRegion = this->GetInput()->GetLargestPossibleRegion(); // Compute the minimum region size - double logNT = 5. * - (vcl_log10(static_cast<double>(m_ImageSize[0])) + vcl_log10(static_cast<double>(m_ImageSize[1]))) / 2.; + double logNT = 5. * vcl_log10( static_cast<double>(largestRegion.GetNumberOfPixels()) ) / 2.; double log1_p = vcl_log10(m_DirectionsAllowed); double rapport = logNT / log1_p; - m_MinimumRegionSize = -1 * static_cast<unsigned int>(rapport); - - // Definition of the min & the max of an image - OutputPixelType min = itk::NumericTraits<TPrecision>::Zero; - OutputPixelType max = itk::NumericTraits<TPrecision>::Zero; + m_MinimumRegionSize = static_cast<unsigned int>(-rapport); // Computing the min & max of the image typedef itk::MinimumMaximumImageCalculator<OutputImageType> MinMaxCalculatorFilter; @@ -164,9 +169,9 @@ LineSegmentDetector<TInputImage, TPrecision> minmaxCalculator->SetImage(modulusImage); minmaxCalculator->ComputeMinimum(); - min = minmaxCalculator->GetMinimum(); + OutputPixelType min = minmaxCalculator->GetMinimum(); minmaxCalculator->ComputeMaximum(); - max = minmaxCalculator->GetMaximum(); + OutputPixelType max = minmaxCalculator->GetMaximum(); /** Compute the threshold on the gradient*/ m_Threshold = m_Threshold * ((max - min) / 255.); // threshold normalized with min & max of the values @@ -188,10 +193,11 @@ LineSegmentDetector<TInputImage, TPrecision> id[0]++; size[0]--; if (modulusImage->GetRequestedRegion().GetSize()[0] + modulusImage->GetRequestedRegion().GetIndex()[0] == - m_ImageSize[0]) size[0]--; + largestRegion.GetSize(0)) + size[0]--; } else if (modulusImage->GetRequestedRegion().GetSize()[0] + modulusImage->GetRequestedRegion().GetIndex()[0] == - m_ImageSize[0]) + largestRegion.GetSize(0)) { size[0]--; } @@ -201,10 +207,10 @@ LineSegmentDetector<TInputImage, TPrecision> id[1]++; size[1]--; if (modulusImage->GetRequestedRegion().GetSize()[1] + modulusImage->GetRequestedRegion().GetIndex()[1] == - m_ImageSize[1]) size[1]--; + largestRegion.GetSize(1)) size[1]--; } else if (modulusImage->GetRequestedRegion().GetSize()[1] + modulusImage->GetRequestedRegion().GetIndex()[1] == - m_ImageSize[1]) + largestRegion.GetSize(1)) { size[1]--; } @@ -642,11 +648,10 @@ LineSegmentDetector<TInputImage, TPrecision> typedef itk::ConstNeighborhoodIterator<OutputImageType> NeighborhoodIteratorType; typename NeighborhoodIteratorType::SizeType radius; radius.Fill(1); - NeighborhoodIteratorType itNeigh(radius, m_MagnitudeFilter->GetOutput(), - m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); - NeighborhoodIteratorType itNeighDir(radius, m_OrientationFilter->GetOutput(), - m_OrientationFilter->GetOutput()-> - GetRequestedRegion()); + NeighborhoodIteratorType itNeigh(radius, m_MagnitudeFilter->GetOutput(), + m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); + NeighborhoodIteratorType itNeighDir(radius, m_OrientationFilter->GetOutput(), + m_OrientationFilter->GetOutput()-> GetRequestedRegion()); /** Vector where to store the point belonging to the current region*/ unsigned int neighSize = itNeigh.GetSize()[0] * itNeigh.GetSize()[1]; @@ -684,7 +689,9 @@ LineSegmentDetector<TInputImage, TPrecision> ++s; } } /** End Searching loop*/ - if (region.size() > m_MinimumRegionSize && region.size() < static_cast<unsigned int>(m_NumberOfImagePixels / 4)) + + unsigned int nbPixels = this->GetInput()->GetLargestPossibleRegion().GetNumberOfPixels(); + if (region.size() > m_MinimumRegionSize && region.size() < nbPixels / 4) { return EXIT_SUCCESS; } @@ -764,9 +771,11 @@ LineSegmentDetector<TInputImage, TPrecision> /* Length & Width of the rectangle **/ typedef std::vector<MagnitudePixelType> MagnitudeVector; + RegionType largestRegion = this->GetInput()->GetLargestPossibleRegion(); unsigned int Diagonal = - static_cast<unsigned int>(vnl_math_hypot(static_cast<double>(m_ImageSize[1]), static_cast<double>( - m_ImageSize[0])) + 2); + static_cast<unsigned int>(vnl_math_hypot(static_cast<double>(largestRegion.GetSize(1)), static_cast<double>( + largestRegion.GetSize(0))) + 2); + MagnitudeVector sum_l(2*Diagonal, itk::NumericTraits<MagnitudePixelType>::Zero); MagnitudeVector sum_w(2*Diagonal, itk::NumericTraits<MagnitudePixelType>::Zero); @@ -827,9 +836,10 @@ LineSegmentDetector<TInputImage, TPrecision> RectangleType rec(8, 0.); // Definition of a // rectangle : 8 components - if (vcl_abs(wl - - wr) - vcl_sqrt(static_cast<double>(m_ImageSize[1] * m_ImageSize[1] + m_ImageSize[0] * m_ImageSize[0])) < - 1e-10) + if (vcl_abs(wl - wr) + - vcl_sqrt( static_cast<double> (largestRegion.GetSize(0) * largestRegion.GetSize(0) + + largestRegion.GetSize(1) * largestRegion.GetSize(1))) + < 1e-10 ) { rec[0] = (x + lb * dx > 0) ? x + lb * dx : 0.; rec[1] = (y + lb * dy > 0) ? y + lb * dy : 0.; @@ -867,8 +877,8 @@ LineSegmentDetector<TInputImage, TPrecision> typedef itk::ConstNeighborhoodIterator<OutputImageType> NeighborhoodIteratorType; typename NeighborhoodIteratorType::SizeType radius; radius.Fill(0); - NeighborhoodIteratorType itNeigh(radius, m_MagnitudeFilter->GetOutput(), - m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); + NeighborhoodIteratorType itNeigh(radius, m_MagnitudeFilter->GetOutput(), + m_MagnitudeFilter->GetOutput()->GetRequestedRegion()); /** Computing the center of the rectangle*/ IndexVectorIteratorType it = region.begin(); @@ -983,8 +993,8 @@ LineSegmentDetector<TInputImage, TPrecision> } /** Compute the NFA from the rectangle computed below*/ - double logNT = 5. * - (vcl_log10(static_cast<double>(m_ImageSize[1])) + vcl_log10(static_cast<double>(m_ImageSize[0]))) / 2.; + RegionType largestRegion = const_cast<Self*>(this)->GetInput()->GetLargestPossibleRegion(); + double logNT = 5. * vcl_log10( static_cast<double>(largestRegion.GetNumberOfPixels()) ) / 2.; nfa_val = NFA(pts, NbAligned, m_DirectionsAllowed, logNT); diff --git a/Code/FeatureExtraction/otbStreamingLineSegmentDetector.h b/Code/FeatureExtraction/otbStreamingLineSegmentDetector.h index fb44c6d631cc3019388375d8e30b898fbee094c3..34c2a9aa04de8cf308d07e56e042d29ef8fb7bb5 100644 --- a/Code/FeatureExtraction/otbStreamingLineSegmentDetector.h +++ b/Code/FeatureExtraction/otbStreamingLineSegmentDetector.h @@ -124,21 +124,21 @@ protected: void GenerateInputRequestedRegion(); + void BeforeThreadedGenerateData(); + /** Multi-thread version GenerateData. */ void ThreadedGenerateData(const RegionType& outputRegionForThread, int threadId); + void AfterThreadedGenerateData(); + private: PersistentLineSegmentDetector(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - // region extractor - ExtractorListType m_ExtractorList; - // store requested region for each threads - RegionListType m_RegionList; - // line detector filters - LineDetectorListType m_LineDetectorList; - // store each thread output + /** the "Folder" node of the output vector data */ + DataNodePointerType m_Folder; + /** store each thread output */ VectorDataListType m_VectorDataList; /** tolerance to fuse 2 lines in 2 threads. */ double m_ThreadDistanceThreshold; diff --git a/Code/FeatureExtraction/otbStreamingLineSegmentDetector.txx b/Code/FeatureExtraction/otbStreamingLineSegmentDetector.txx index f16486bc5d0f1eb51a0f41e518ec8b684b1af0ca..96e73883c96367cfbb3badc22fb44dc0a71bb639 100644 --- a/Code/FeatureExtraction/otbStreamingLineSegmentDetector.txx +++ b/Code/FeatureExtraction/otbStreamingLineSegmentDetector.txx @@ -40,6 +40,11 @@ PersistentLineSegmentDetector<TInputImage, TPrecision> this->SetNumberOfRequiredOutputs(3); this->itk::ProcessObject::SetNthOutput(1, this->MakeOutput(1).GetPointer()); this->itk::ProcessObject::SetNthOutput(2, this->MakeOutput(2).GetPointer()); + + // Set the number of threads to 1 by default to avoid oversegmentation + // There also seem to be a bug in the underlying LineSegmentDetector + // for small regions (probably when a stream does not contain segment) + this->SetNumberOfThreads(1); } template<class TInputImage, class TPrecision> @@ -116,31 +121,12 @@ PersistentLineSegmentDetector<TInputImage, TPrecision> { int nbThread = this->GetNumberOfThreads(); - m_ExtractorList.clear(); - m_RegionList.clear(); - m_LineDetectorList.clear(); m_VectorDataList.clear(); - m_VectorDataList.resize(nbThread); - m_RegionList.resize(nbThread); - - for (int p = 0; p < nbThread; ++p) - { - m_ExtractorList.push_back(ExtractorType::New()); - m_LineDetectorList.push_back(LineDetectorType::New()); - m_LineDetectorList[p]->SetImageSize(this->GetInput()->GetLargestPossibleRegion().GetSize()); - } - -} -template<class TInputImage, class TPrecision> -void -PersistentLineSegmentDetector<TInputImage, TPrecision> -::Synthetize() -{ // merge all lines in a single vector data VectorDataType* outputVData = this->GetOutputVectorData(); - + // Retrieving root node DataNodePointerType root = outputVData->GetDataTree()->GetRoot()->Get(); // Create the document node @@ -148,28 +134,21 @@ PersistentLineSegmentDetector<TInputImage, TPrecision> document->SetNodeType(otb::DOCUMENT); DataNodePointerType folder = DataNodeType::New(); folder->SetNodeType(otb::FOLDER); + m_Folder = folder; // Adding the layer to the data tree outputVData->GetDataTree()->Add(document, root); outputVData->GetDataTree()->Add(folder, document); - for (unsigned int threadId = 0; threadId < m_VectorDataList.size(); ++threadId) - { - TreeIteratorType itCurrentVData(m_VectorDataList[threadId]->GetDataTree()); - itCurrentVData.GoToBegin(); - while (!itCurrentVData.IsAtEnd()) - { - if (itCurrentVData.Get()->IsLineFeature()) - { - outputVData->GetDataTree()->Add(itCurrentVData.Get(), folder); - } - itCurrentVData ++; - } - } - - this->GetOutputVectorData()->SetMetaDataDictionary(m_VectorDataList[0]->GetMetaDataDictionary()); } +template<class TInputImage, class TPrecision> +void +PersistentLineSegmentDetector<TInputImage, TPrecision> +::Synthetize() +{ +} + template<class TInputImage, class TPrecision> void PersistentLineSegmentDetector<TInputImage, TPrecision> @@ -187,42 +166,84 @@ PersistentLineSegmentDetector<TInputImage, TPrecision> if (this->GetInput()) { - ImagePointerType image = const_cast<ImageType *>(this->GetInput()); - image->SetRequestedRegion(this->GetOutput()->GetRequestedRegion()); + ImagePointerType input = const_cast<ImageType *>(this->GetInput()); + + RegionType region = this->GetOutput()->GetRequestedRegion(); + region.PadByRadius(1); + region.Crop(input->GetLargestPossibleRegion()); + input->SetRequestedRegion(region); } } +template<class TInputImage, class TPrecision> +void +PersistentLineSegmentDetector<TInputImage, TPrecision> +::BeforeThreadedGenerateData() +{ +} + template<class TInputImage, class TPrecision> void PersistentLineSegmentDetector<TInputImage, TPrecision> ::ThreadedGenerateData(const RegionType& outputRegionForThread, int threadId) { - ImagePointerType inputPtr = const_cast<TInputImage *>(this->GetInput()); - - RegionType region = outputRegionForThread; - region.PadByRadius((unsigned int)(1)); - region.Crop(inputPtr->GetLargestPossibleRegion()); - - inputPtr->SetRequestedRegion(region); - inputPtr->PropagateRequestedRegion(); - inputPtr->UpdateOutputData(); - - m_ExtractorList[threadId]->SetInput(this->GetInput()); - m_ExtractorList[threadId]->SetExtractionRegion(region); - //m_ExtractorList[threadId]->SetExtractionRegion(outputRegionForThread); - m_ExtractorList[threadId]->UpdateOutputInformation(); - - m_LineDetectorList[threadId]->SetInput(m_ExtractorList[threadId]->GetOutput()); - m_LineDetectorList[threadId]->Update(); - - m_RegionList[threadId] = outputRegionForThread; - m_VectorDataList[threadId] = m_LineDetectorList[threadId]->GetOutput(); + try + { + ImagePointerType inputPtr = const_cast<TInputImage *>(this->GetInput()); + + RegionType region = outputRegionForThread; + region.PadByRadius((unsigned int)(1)); + region.Crop(inputPtr->GetLargestPossibleRegion()); + + inputPtr->SetRequestedRegion(region); + inputPtr->PropagateRequestedRegion(); + inputPtr->UpdateOutputData(); + + typename ExtractorType::Pointer extractFilter = ExtractorType::New(); + extractFilter->SetInput(this->GetInput()); + extractFilter->SetExtractionRegion(region); + extractFilter->Update(); + + typename LineDetectorType::Pointer lineDetector = LineDetectorType::New(); + lineDetector->SetInput(extractFilter->GetOutput()); + lineDetector->Update(); + + m_VectorDataList[threadId] = lineDetector->GetOutput(); + } + catch (itk::ExceptionObject& e) + { + std::cout << "Exception : " << e; + throw; + } } +template<class TInputImage, class TPrecision> +void +PersistentLineSegmentDetector<TInputImage, TPrecision> +::AfterThreadedGenerateData() +{ + // merge all lines in a single vector data + VectorDataType* outputVData = this->GetOutputVectorData(); + outputVData->GetDataTree(); -// end of class PersistentLineSegmentDetector + for (unsigned int threadId = 0; threadId < m_VectorDataList.size(); ++threadId) + { + TreeIteratorType itCurrentVData(m_VectorDataList[threadId]->GetDataTree()); + itCurrentVData.GoToBegin(); + while (!itCurrentVData.IsAtEnd()) + { + if (itCurrentVData.Get()->IsLineFeature()) + { + outputVData->GetDataTree()->Add(itCurrentVData.Get(), m_Folder); + } + itCurrentVData ++; + } + } + + this->GetOutputVectorData()->SetMetaDataDictionary(m_VectorDataList[0]->GetMetaDataDictionary()); +} -/**===========================================================================*/ +// end of class PersistentLineSegmentDetector template<class TInputImage, class TPrecision> StreamingLineSegmentDetector<TInputImage, TPrecision> @@ -236,18 +257,5 @@ StreamingLineSegmentDetector<TInputImage, TPrecision> { } -/** - * The aim here is to gathered each thread output into a vector data. - * For that we have to fuse different thread output, in particular for line that throw thread. - * For that, for each thread and each detected line, we look if one of its extrema is over a thread lower limit (RegionList.GetSize()[1]). - * If yes, we store the line. If no, we add it to the vector data. - * At the next loop (ie. next thread), for each line, we check that it doesn't have a point in common with lines that end at the end of - * the previous thread. - * If yes we compute the extrema (one point ineach thread). - * If not, we add it to the vector data, else we store it. - * And so on. - * m_ThreadDistanceThreshold allows a tolerance over the commmon point spatial distance when 2 lines are fused. - */ - } // end namespace otb #endif diff --git a/Code/IO/otbImageFileReader.txx b/Code/IO/otbImageFileReader.txx index 19a4d04aa1e667c4387ac0225e78bc3e9786738b..55796a65413c44546a8affde339fb80e89fc8486 100644 --- a/Code/IO/otbImageFileReader.txx +++ b/Code/IO/otbImageFileReader.txx @@ -40,7 +40,7 @@ #include "otbTileMapImageIO.h" //FIXME find a better way #include "otbGDALImageIO.h" //FIXME find a better way -#include "projection/ossimTileMapModel.h" +#include "ossimTileMapModel.h" #include <itksys/SystemTools.hxx> #include <fstream> @@ -427,7 +427,7 @@ ImageFileReader<TOutputImage> typename TileMapImageIO::Pointer imageIO = dynamic_cast<TileMapImageIO*>(this->GetImageIO()); if (imageIO.IsNotNull()) { - dynamic_cast<ossimTileMapModel*>(projection)->setDepth(imageIO->GetDepth()); + dynamic_cast<ossimplugins::ossimTileMapModel*>(projection)->setDepth(imageIO->GetDepth()); } } hasMetaData = projection->saveState(geom_kwl); diff --git a/Code/Learning/otbConfusionMatrixCalculator.h b/Code/Learning/otbConfusionMatrixCalculator.h index c5c918adf799fd4c2b2d9369ab90f78031414302..9999aabbf763d9ea00d91b1729d595f95f3988f0 100644 --- a/Code/Learning/otbConfusionMatrixCalculator.h +++ b/Code/Learning/otbConfusionMatrixCalculator.h @@ -31,11 +31,20 @@ namespace otb * reference/produced labels. * * For a 2 classes problem, the confusion matrix is organized as follows: - * \f[ \left( \begin{array}{cc} True positives & False positives \\ False negatives & true Negatives \end{array} \right) \f] + * \f[ \left( \begin{array}{cc} True positives & False negatives \\ False positives & true Negatives \end{array} \right) \f] * * Please note that when accessing the confusion matrix values, the first index is the row index, and the second is the column index, - * so that accessing the false positive rate is done by calling GetConfusionMatrix()[1, 0]. + * so that accessing the false positive rate is done by calling GetConfusionMatrix()[1, 0] for the case of 2 classes problem. * + * Some measurement are computed by this class : + * If we consider true positive (TP), true negative (TN), false positive (FP) and false negative (FP) rate then in the 2 classes case: + * \f[ precision = \frac{TP}{\left( TP + FP \right) } \f] + * \f[ recall = \frac{TP}{\left( TP + FN \right) } \f] + * \f[ FScore = \frac{2 * precision * recall}{\left( precision + recall \right) } \f] + * + * In case of multiclasses problem, these measurements are extended by considering one class versus others. + * + * Moreover overall accuracy and \f[ \kappa \f] index are computed. */ template <class TRefListLabel, class TProdListLabel> class ITK_EXPORT ConfusionMatrixCalculator : @@ -43,10 +52,10 @@ class ITK_EXPORT ConfusionMatrixCalculator : { public: /** Standard class typedefs */ - typedef ConfusionMatrixCalculator Self; - typedef itk::ProcessObject Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef ConfusionMatrixCalculator Self; + typedef itk::ProcessObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; /** Run-time type information (and related methods). */ itkTypeMacro(ConfusionMatrixCalculator, itk::ProcessObject); @@ -55,27 +64,35 @@ public: itkNewMacro(Self); /** List to store the corresponding labels */ - typedef TRefListLabel RefListLabelType; - typedef typename RefListLabelType::Pointer RefListLabelPointerType; + typedef TRefListLabel RefListLabelType; + typedef typename RefListLabelType::Pointer RefListLabelPointerType; - typedef TProdListLabel ProdListLabelType; - typedef typename ProdListLabelType::Pointer ProdListLabelPointerType; + typedef TProdListLabel ProdListLabelType; + typedef typename ProdListLabelType::Pointer ProdListLabelPointerType; typedef int ClassLabelType; /** Type for the confusion matrix */ - typedef itk::VariableSizeMatrix<double> ConfusionMatrixType; + typedef itk::VariableSizeMatrix<double> ConfusionMatrixType; + + /** Type for the measurement */ + typedef itk::VariableLengthVector<double> MeasurementType; virtual void Update(); /** Accessors */ - itkSetObjectMacro(ReferenceLabels, RefListLabelType); itkGetConstObjectMacro(ReferenceLabels, RefListLabelType); itkSetObjectMacro(ProducedLabels, ProdListLabelType); itkGetConstObjectMacro(ProducedLabels, ProdListLabelType); itkGetMacro(KappaIndex, double); itkGetMacro(OverallAccuracy, double); + itkGetMacro(Precisions, MeasurementType); + itkGetMacro(Recalls, MeasurementType); + itkGetMacro(FScores, MeasurementType); + itkGetMacro(Precision, double); + itkGetMacro(Recall, double); + itkGetMacro(FScore, double); itkGetMacro(NumberOfClasses, unsigned short); itkGetMacro(NumberOfSamples, unsigned long); itkGetMacro(ConfusionMatrix, ConfusionMatrixType); @@ -100,6 +117,24 @@ private: double m_KappaIndex; double m_OverallAccuracy; + MeasurementType m_FalseNegativeValues; + MeasurementType m_TrueNegativeValues; + MeasurementType m_FalsePositiveValues; + MeasurementType m_TruePositiveValues; + + MeasurementType m_Precisions; + MeasurementType m_Recalls; + MeasurementType m_FScores; + + double m_FalseNegativeValue; + double m_TrueNegativeValue; + double m_FalsePositiveValue; + double m_TruePositiveValue; + + double m_Precision; + double m_Recall; + double m_FScore; + std::map<ClassLabelType, int> m_MapOfClasses; unsigned short m_NumberOfClasses; diff --git a/Code/Learning/otbConfusionMatrixCalculator.txx b/Code/Learning/otbConfusionMatrixCalculator.txx index 074de0ff87b399bc9ee479cbaa0e0ba8689c2fb8..7abc44980ece0d71464f94f94ed435b16d6089b8 100644 --- a/Code/Learning/otbConfusionMatrixCalculator.txx +++ b/Code/Learning/otbConfusionMatrixCalculator.txx @@ -26,7 +26,14 @@ namespace otb template<class TRefListLabel, class TProdListLabel> ConfusionMatrixCalculator<TRefListLabel, TProdListLabel> ::ConfusionMatrixCalculator() : - m_KappaIndex(0.0), m_OverallAccuracy(0.0), m_NumberOfClasses(0) + m_KappaIndex(0.0), + m_OverallAccuracy(0.0), + m_FalseNegativeValue(0.0), + m_TrueNegativeValue(0.0), + m_FalsePositiveValue(0.0), + m_TruePositiveValue(0.0), + m_NumberOfClasses(0) + { this->SetNumberOfRequiredInputs(2); this->SetNumberOfRequiredOutputs(1); @@ -89,6 +96,15 @@ ConfusionMatrixCalculator<TRefListLabel, TProdListLabel> m_ConfusionMatrix = ConfusionMatrixType(m_NumberOfClasses, m_NumberOfClasses); m_ConfusionMatrix.Fill(0); + m_FalseNegativeValues = MeasurementType(m_NumberOfClasses); + m_TrueNegativeValues = MeasurementType(m_NumberOfClasses); + m_FalsePositiveValues = MeasurementType(m_NumberOfClasses); + m_TruePositiveValues = MeasurementType(m_NumberOfClasses); + m_FalseNegativeValues.Fill(0); + m_FalsePositiveValues.Fill(0); + m_TruePositiveValues.Fill(0); + m_TrueNegativeValues.Fill(0); + refIterator = m_ReferenceLabels->Begin(); prodIterator = m_ProducedLabels->Begin(); @@ -112,10 +128,16 @@ ConfusionMatrixCalculator<TRefListLabel, TProdListLabel> for (unsigned int i = 0; i < m_NumberOfClasses; ++i) { this->m_OverallAccuracy += m_ConfusionMatrix(i, i); + this->m_TruePositiveValues[i] = m_ConfusionMatrix(i, i); + } + if (m_NumberOfClasses == 2) + { + this->m_TruePositiveValue = this->m_TruePositiveValues[0]; } this->m_OverallAccuracy /= static_cast<double>(m_NumberOfSamples); + double luckyRate = 0.; for (unsigned int i = 0; i < m_NumberOfClasses; ++i) { @@ -125,8 +147,61 @@ ConfusionMatrixCalculator<TRefListLabel, TProdListLabel> { sum_ij += m_ConfusionMatrix(i, j); sum_ji += m_ConfusionMatrix(j, i); + if (i != j) + { + this->m_FalseNegativeValues[i] += m_ConfusionMatrix(i, j); + this->m_FalsePositiveValues[i] += m_ConfusionMatrix(j, i); + } } luckyRate += sum_ij * sum_ji; + this->m_TrueNegativeValues[i] = m_NumberOfSamples; + } + this->m_TrueNegativeValues -= this->m_FalseNegativeValues + + this->m_FalsePositiveValues + + this->m_TruePositiveValues; + + if (m_NumberOfClasses == 2) + { + this->m_FalseNegativeValue = m_ConfusionMatrix(0, 1); + this->m_FalsePositiveValue = m_ConfusionMatrix(1, 0); + this->m_TrueNegativeValue = m_ConfusionMatrix(1, 1); + /*std::cout << "TP= " << this->m_TruePositiveValue << std::endl; + std::cout << "FN= " << this->m_FalseNegativeValue << std::endl; + std::cout << "FP= " << this->m_FalsePositiveValue << std::endl; + std::cout << "TN= " << this->m_TrueNegativeValue << std::endl; */ + } + else + { + /*std::cout << "TP= " << this->m_TruePositiveValues << std::endl; + std::cout << "FN= " << this->m_FalseNegativeValues << std::endl; + std::cout << "FP= " << this->m_FalsePositiveValues << std::endl; + std::cout << "TN= " << this->m_TrueNegativeValues << std::endl; */ + } + + m_Precisions = MeasurementType(m_NumberOfClasses); + m_Recalls = MeasurementType(m_NumberOfClasses); + m_FScores = MeasurementType(m_NumberOfClasses); + m_Precisions.Fill(0); + m_Recalls.Fill(0); + m_FScores.Fill(0); + + if (m_NumberOfClasses != 2) + { + for (unsigned int i = 0; i < m_NumberOfClasses; ++i) + { + this->m_Precisions[i] = this->m_TruePositiveValues[i] / (this->m_TruePositiveValues[i] + + this->m_FalsePositiveValues[i]); + this->m_Recalls[i] = this->m_TruePositiveValues[i] / (this->m_TruePositiveValues[i] + + this->m_FalseNegativeValues[i]); + this->m_FScores[i] = 2 * this->m_Recalls[i] * this->m_Precisions[i] + / (this->m_Recalls[i] + this->m_Precisions[i]); + } + } + else + { + this->m_Precision = this->m_TruePositiveValue / (this->m_TruePositiveValue + this->m_FalsePositiveValue); + this->m_Recall = this->m_TruePositiveValue / (this->m_TruePositiveValue + this->m_FalseNegativeValue); + this->m_FScore = 2 * this->m_Recall * this->m_Precision / (this->m_Recall + this->m_Precision); } luckyRate /= vcl_pow(m_NumberOfSamples, 2.0); diff --git a/Code/Learning/otbListSampleGenerator.h b/Code/Learning/otbListSampleGenerator.h index cbb5190a8aaa372e9646ee19279a73515dcd2810..19d2bf4d969c7bf342283a361fcefd4627d59ee2 100644 --- a/Code/Learning/otbListSampleGenerator.h +++ b/Code/Learning/otbListSampleGenerator.h @@ -61,6 +61,9 @@ public: itkNewMacro(Self); typedef TImage ImageType; + typedef typename ImageType::Pointer ImagePointerType; + typedef typename ImageType::IndexType ImageIndexType; + typedef typename ImageType::RegionType ImageRegionType; typedef TVectorData VectorDataType; typedef typename VectorDataType::Pointer VectorDataPointerType; diff --git a/Code/Learning/otbListSampleGenerator.txx b/Code/Learning/otbListSampleGenerator.txx index 74a62fdcf4b1c74523de911e85989f6260eb8eef..b5d08818136ab34518cb49f92248886ef393bc1f 100644 --- a/Code/Learning/otbListSampleGenerator.txx +++ b/Code/Learning/otbListSampleGenerator.txx @@ -22,9 +22,40 @@ #include "itkImageRegionConstIteratorWithIndex.h" #include "otbRemoteSensingRegion.h" +#include "otbVectorDataProjectionFilter.h" namespace otb { + +/*template <class TVectorData> +void printVectorData(TVectorData * vectorData, string msg = "") +{ + typedef TVectorData VectorDataType; + typedef itk::PreOrderTreeIterator<typename VectorDataType::DataTreeType> TreeIteratorType; + + TreeIteratorType itVector(vectorData->GetDataTree()); + itVector.GoToBegin(); + + if (!msg.empty()) + { + std::cout<< msg << std::endl; + } + + while (!itVector.IsAtEnd()) + { + if (itVector.Get()->IsPolygonFeature()) + { + std::cout << itVector.Get()->GetNodeTypeAsString() << std::endl; + for (unsigned int itPoints = 0; itPoints < itVector.Get()->GetPolygonExteriorRing()->GetVertexList()->Size(); itPoints++) + { + std::cout << "vertex[" << itPoints << "]: " << itVector.Get()->GetPolygonExteriorRing()->GetVertexList()->GetElement(itPoints) <<std::endl; + } + std::cout << "Polygon bounding region:\n" << itVector.Get()->GetPolygonExteriorRing()->GetBoundingRegion() << std::endl; + } + ++itVector; + } +}*/ + template<class TImage, class TVectorData> ListSampleGenerator<TImage, TVectorData> ::ListSampleGenerator() : @@ -74,6 +105,9 @@ ListSampleGenerator<TImage, TVectorData> ::SetInputVectorData(const VectorDataType * vectorData) { this->ProcessObject::SetNthInput(1, const_cast<VectorDataType *>(vectorData)); + + //printVectorData(vectorData); + } template <class TImage, class TVectorData> @@ -89,6 +123,7 @@ ListSampleGenerator<TImage, TVectorData> return static_cast<const VectorDataType *>(this->ProcessObject::GetInput(1)); } + /** * */ @@ -117,9 +152,9 @@ void ListSampleGenerator<TImage, TVectorData> ::GenerateData() { - typename VectorDataType::ConstPointer vectorData = this->GetInputVectorData(); + ImagePointerType image = const_cast<ImageType*>(this->GetInput()); - typename ImageType::Pointer image = const_cast<ImageType*>(this->GetInput()); + VectorDataPointerType vectorData = const_cast<VectorDataType*>(this->GetInputVectorData()); //Gather some information about the relative size of the classes //we would like to have the same number of samples per class @@ -144,14 +179,16 @@ ListSampleGenerator<TImage, TVectorData> { if (itVector.Get()->IsPolygonFeature()) { - typename ImageType::RegionType polygonRegion = otb::TransformPhysicalRegionToIndexRegion(itVector.Get()->GetPolygonExteriorRing()->GetBoundingRegion(), image.GetPointer()); + //std::cout << "Image region from polygon:\n" << polygonRegion << std::endl; + //std::cout << "Image largest possible region:\n" << image->GetLargestPossibleRegion() << std::endl; image->SetRequestedRegion(polygonRegion); image->PropagateRequestedRegion(); image->UpdateOutputData(); + //std::cout << "Image region requested:\n" << image->GetRequestedRegion() << std::endl; typedef itk::ImageRegionConstIteratorWithIndex<ImageType> IteratorType; IteratorType it(image, polygonRegion); @@ -160,6 +197,7 @@ ListSampleGenerator<TImage, TVectorData> { itk::ContinuousIndex<double, 2> point; image->TransformIndexToPhysicalPoint(it.GetIndex(), point); + //std::cout << it.GetIndex() << " -> " << point << std::endl; if (itVector.Get()->GetPolygonExteriorRing()->IsInside(point)) { double randomValue = m_RandomGenerator->GetUniformVariate(0.0, 1.0); @@ -188,6 +226,7 @@ ListSampleGenerator<TImage, TVectorData> assert(m_TrainingListSample->Size() == m_TrainingListLabel->Size()); assert(m_ValidationListSample->Size() == m_ValidationListLabel->Size()); + } template <class TImage, class TVectorData> @@ -200,6 +239,7 @@ ListSampleGenerator<TImage, TVectorData> //Compute pixel area: typename ImageType::Pointer image = const_cast<ImageType*>(this->GetInput()); double pixelArea = vcl_abs(image->GetSpacing()[0] * image->GetSpacing()[1]); + std::cout<< "Pixel area: " << pixelArea << std::endl; typename VectorDataType::ConstPointer vectorData = this->GetInputVectorData(); TreeIteratorType itVector(vectorData->GetDataTree()); @@ -210,6 +250,7 @@ ListSampleGenerator<TImage, TVectorData> { m_ClassesSize[itVector.Get()->GetFieldAsInt(m_ClassKey)] += itVector.Get()->GetPolygonExteriorRing()->GetArea() / pixelArea; // in pixel + std::cout << "Area = "<<itVector.Get()->GetPolygonExteriorRing()->GetArea() << std::endl; } ++itVector; } diff --git a/Code/Learning/otbSVMModelEstimator.txx b/Code/Learning/otbSVMModelEstimator.txx index 64d19dd197b1b7a070cc1061585e43fe1f24974d..1c892041118e2237dd352437995950f6b144b8ba 100644 --- a/Code/Learning/otbSVMModelEstimator.txx +++ b/Code/Learning/otbSVMModelEstimator.txx @@ -166,7 +166,8 @@ SVMModelEstimator<InputPixelType, LabelPixelType> m_InitialCrossValidationAccuracy = crossValidationFunction->GetValue(initialParameters); m_FinalCrossValidationAccuracy = m_InitialCrossValidationAccuracy; - otbMsgDebugMacro(<< "Initial accuracy : " << m_InitialCrossValidationAccuracy); + otbMsgDebugMacro(<< "Initial accuracy : " << m_InitialCrossValidationAccuracy + << ", Parameters Optimization" << m_ParametersOptimization); if (m_ParametersOptimization) { diff --git a/Code/Learning/otbSVMSampleListModelEstimator.h b/Code/Learning/otbSVMSampleListModelEstimator.h index f74ad67b90803617f189200431d60ffe3f207e58..3f996d9dfd7a244eed2a55d0c8d4f34a7794df3b 100644 --- a/Code/Learning/otbSVMSampleListModelEstimator.h +++ b/Code/Learning/otbSVMSampleListModelEstimator.h @@ -106,13 +106,13 @@ class ITK_EXPORT SVMSampleListModelEstimator : { public: /** Standard class typedefs. */ - typedef SVMSampleListModelEstimator Self; + typedef SVMSampleListModelEstimator Self; typedef SVMModelEstimator<typename TInputSampleList::MeasurementType, - typename TTrainingSampleList::MeasurementType> - Superclass; + typename TTrainingSampleList::MeasurementType> + Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); diff --git a/Code/Learning/otbSVMSampleListModelEstimator.txx b/Code/Learning/otbSVMSampleListModelEstimator.txx index cac9fb7ec8aed087c1c7dc122e58235544fc42f4..4ded92b3a500a6d552209eaa275c2c9ff4ce995b 100644 --- a/Code/Learning/otbSVMSampleListModelEstimator.txx +++ b/Code/Learning/otbSVMSampleListModelEstimator.txx @@ -69,11 +69,15 @@ SVMSampleListModelEstimator<TInputSampleList, TTrainingSampleList, TMeasurementF // Check if size of the two inputs are same if (inputSampleListSize != trainingSampleListSize) - throw itk::ExceptionObject( + { + /*throw itk::ExceptionObject( __FILE__, __LINE__, "Input pointset size is not the same as the training pointset size.", - ITK_LOCATION); + ITK_LOCATION); */ + itkExceptionMacro(<< "Input pointset size is not the same as the training pointset size (" + << inputSampleListSize << " vs "<< trainingSampleListSize << ")."); + } // Declaration of the iterators on the input and training images InputSampleListIteratorType inIt = inputSampleList->Begin(); diff --git a/Code/Projections/otbTileMapTransform.h b/Code/Projections/otbTileMapTransform.h index f5f1605d6b33c13b9001c355d120047bafa2df2d..2335eb393bccc670520bd79600412cdffc0079a2 100644 --- a/Code/Projections/otbTileMapTransform.h +++ b/Code/Projections/otbTileMapTransform.h @@ -30,7 +30,7 @@ #include "base/ossimEllipsoid.h" #include "base/ossimEllipsoidFactory.h" #include "base/ossimString.h" -#include "ossim/projection/ossimTileMapModel.h" +#include "ossimTileMapModel.h" #include "otbMapProjection.h" // The keyword "Try" is exported by OSSIM's headers but clashes with Boost // Spirit. It needs to be undefined. @@ -60,7 +60,7 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; typedef typename Superclass::ScalarType ScalarType; - typedef ossimTileMapModel OssimTileMapTransformType; + typedef ossimplugins::ossimTileMapModel OssimTileMapTransformType; typedef itk::Point<ScalarType, NInputDimensions> InputPointType; typedef itk::Point<ScalarType, NOutputDimensions> OutputPointType; diff --git a/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h b/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h index 89ae7bdcb18a0270d6588d9c5cd1bc1d3aa24779..ddae0b79699c47852f79e3b7604515ed0bc9ac99 100644 --- a/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h @@ -27,13 +27,26 @@ namespace otb namespace Functor { /** \class otbMuellerToCircularPolarisationFunctor - * \brief Evaluate the Circular Polarisation image - * (3 channels : LL, RR and LR) from the Mueller image + * \brief Evaluate the Circular Polarisation image from the Mueller image. + * + * The input Mueller image has 16 channels, one for each matrix element. + * The order of the channels corresponds to : + * \f$ \begin{pmatrix} + * {channel #0 }&{channel #1 }&{channel #2 }&{channel #3 } \\ + * {channel #4 }&{channel #5 }&{channel #6 }&{channel #7 } \\ + * {channel #8 }&{channel #9 }&{channel #10}&{channel #11} \\ + * {channel #12}&{channel #13}&{channel #14}&{channel #15} \\ + * \end{pmatrix} + * + * Output value are: + * channel #0 : \f$ LL = M_{11}+M_{14}+M_{41}+M_{44} \f$ \\ + * channel #1 : \f$ RR = M_{11}-M_{14}+M_{41}+M_{44} \f$ \\ + * channel #2 : \f$ LR = M_{11}-M_{44}\f$ \\ * * \ingroup Functor * \ingroup SARPolarimetry * - * \sa MuellerToMLCImageFilter + * \sa MuellerToReciprocalCovarianceFunctor * \sa MuellerToPolarisationDegreeAndPowerImageFilter * */ @@ -81,16 +94,23 @@ private: /** \class otbMuellerToCircularPolarisationImageFilter * \brief Compute the circular polarisation image (3 channels : LL, RR and LR) * from the Mueller image (16 real channels) + * For more details, please refer to the class MuellerToCircularPolarisationFunctor. + * + * \ingroup SARPolarimetry + * \sa MuellerToCircularPolarisationFunctor + * */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::MuellerToCircularPolarisationFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > +template <class TInputImage, class TOutputImage> class ITK_EXPORT MuellerToCircularPolarisationImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> + public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::MuellerToCircularPolarisationFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > { public: /** Standard class typedefs. */ typedef MuellerToCircularPolarisationImageFilter Self; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; + typedef typename Functor::MuellerToCircularPolarisationFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; + typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.h b/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.h deleted file mode 100644 index 984cb2d356c330c36827ba81fe39555e530b01d1..0000000000000000000000000000000000000000 --- a/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.h +++ /dev/null @@ -1,145 +0,0 @@ -/*========================================================================= - - 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 __MuellerToCovarianceImageFilter_h -#define __MuellerToCovarianceImageFilter_h - -#include "otbUnaryFunctorImageFilter.h" - -namespace otb - { - -namespace Functor { - -/** \class otbMuellerToCovarianceFunctor - * \brief Evaluate the MLC image from the Mueller image - * - * Output value are: - * channel #0 : \f$ M_{11} + M_{22} + 2*M_{12} \f$ - * channel #1 : \f$ M_{11} - M_{22} \f$ - * channel #2 : \f$ M_{11} + M_{22} - 2*M_{12} \f$ - * channel #3 : \f$ M_{13} + M_{23} + i*(M_{14}+M_{24}) \f$ - * channel #4 : \f$ M_{3Coherency3} - M_{44} - 2*i*M_{34} \f$ - * channel #5 : \f$ M_{13} - M_{23} - i*(M_{14}-M_{24}) \f$ - * - * Where \f$ M_{ij} are the coefficients of the input Mueeler matrix. - * Input pixel must have 10 channels (one for each Mueller matrix coeffcients). - * The returned output pixel have 6 channles. - * - * \ingroup Functor - * \ingroup SARPolarimetry - * - * \sa MuellerToCircularPolarisationImageFilter - * \sa MuellerToPolarisationDegreeAndPowerImageFilter - * - */ - -template< class TInput, class TOutput> -class MuellerToCovarianceFunctor -{ -public: - typedef std::complex<double> ComplexType; - typedef typename TOutput::ValueType OutputValueType; - - - inline TOutput operator()( const TInput & Mueller ) const - { - TOutput result; - result.SetSize(m_NumberOfComponentsPerPixel); - - // Keep the upper diagonal of the matrix - const double M11 = static_cast<double>(Mueller[0]); - const double M12 = static_cast<double>(Mueller[1]); - const double M13 = static_cast<double>(Mueller[2]); - const double M14 = static_cast<double>(Mueller[3]); - const double M22 = static_cast<double>(Mueller[5]); - const double M23 = static_cast<double>(Mueller[6]); - const double M24 = static_cast<double>(Mueller[7]); - const double M33 = static_cast<double>(Mueller[10]); - const double M34 = static_cast<double>(Mueller[11]); - const double M44 = static_cast<double>(Mueller[15]); - - const ComplexType hhhh(M11+M22+2.*M12, 0.0); - const ComplexType hvhv(M11-M22, 0.0); - const ComplexType vvvv(M11+M22-2.*M12, 0.0); - const ComplexType hhhv(M13+M23, -1.*(M14+M24)); - const ComplexType hhvv(M33-M44, -2.*M34); - const ComplexType hvvv(M13-M23, -1.*(M14-M24)); - - result[0] = static_cast<OutputValueType>( hhhh ); - result[1] = static_cast<OutputValueType>( 2.* hhhv ); - result[2] = static_cast<OutputValueType>( hhvv ); - result[3] = static_cast<OutputValueType>( 4.* hvhv ); - result[4] = static_cast<OutputValueType>( 2.* hvvv ); - result[5] = static_cast<OutputValueType>( vvvv ); - - return result; - } - - unsigned int GetOutputSize() - { - return m_NumberOfComponentsPerPixel; - } - - /** Constructor */ - MuellerToCovarianceFunctor() : m_NumberOfComponentsPerPixel(6) {} - - /** Destructor */ - virtual ~MuellerToCovarianceFunctor() {} - - private: - unsigned int m_NumberOfComponentsPerPixel; -}; -} - - -/** \class otbMuellerToCovarianceImageFilter - * \brief Compute the MLC image - * from the Mueller image (16 real channels) - */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::MuellerToCovarianceFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > -class ITK_EXPORT MuellerToCovarianceImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> -{ -public: - /** Standard class typedefs. */ - typedef MuellerToCovarianceImageFilter Self; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Runtime information support. */ - itkTypeMacro(MuellerToCovarianceImageFilter, UnaryFunctorImageFilter); - - -protected: - MuellerToCovarianceImageFilter() {} - virtual ~MuellerToCovarianceImageFilter() {} - -private: - MuellerToCovarianceImageFilter(const Self&); // purposely not implemented - void operator=(const Self&); // purposely not implemented -}; - -} // end namespace otb - -#endif diff --git a/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h b/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h index 5e434d0501b1e74650856e9eebd3d1080f3e1b6a..a6c1b10b45ef3b82e12a63d8e0d4f436a43c6d9f 100644 --- a/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h @@ -34,11 +34,40 @@ namespace Functor { * \brief Evaluate the min and max polarisation degree and min and max power * from the Mueller image * + * The order of the channels of the input image corresponds to : + * \f$ \begin{pmatrix} + * {channel #0 }&{channel #1 }&{channel #2 }&{channel #3 } \\ + * {channel #4 }&{channel #5 }&{channel #6 }&{channel #7 } \\ + * {channel #8 }&{channel #9 }&{channel #10}&{channel #11} \\ + * {channel #12}&{channel #13}&{channel #14}&{channel #15} \\ + * \end{pmatrix} + * + * The class process step by step while \f$ \tau <= 45 \f$ and for each \f$ \tau \f$, while \f$ \psi <= 90 \f : + * \begin{itemize} + * \item Define the incident Stokes vector: + * \f$ Si_{0} = 1 \f$ \\ + * \f$ Si_{1} = \cos{\psi * \frac{\pi}{90}} * \cos{\tau * \frac{\pi}{90}} \f$ \\ + * \f$ Si_{2} = \sin{\psi * \frac{\pi}{90}} * \cos{\tau * \frac{\pi}{90}} \f$ \\ + * \f$ Si_{3} = \sin{\tau * \frac{\pi}{90}}\f$ \\ + * \item Evaluate the received Stokes vector + * \f$ Sr = Si * MuellerMatrix \f$ \\ + * \item Evaluate power \f$ P \f$ and polarisation degree \f$ DegP \f$ \\ + * \f$ P = \max{0, Sr_0} \f$ \\ + * \f$ DegP = \sqrt{Sr_{1}^{2} + Sr_{2}^{2} + Sr_{3}^{2}} / Sr_{0} \f$ \\ + * \item Keep le smaller and the bigger power (\f$ P_{min}, P_{max} \f$) and \f$\f$ ) and polarisation degree (\f$ DegP_{min}, DegP_{max} \f$) ). + * \end{itemize} + * + * Output value are: + * channel #0 : \f$ P_{min} \f$ \\ + * channel #1 : \f$ P_{max} \f$ \\ + * channel #2 : \f$ DegP_{min} \f$ \\ + * channel #3 : \f$ DegP_{max} \f$ \\ + * * \ingroup Functor * \ingroup SARPolarimetry * * \sa MuellerToCircularPolarisationImageFilter - * \sa MuellerToMLCImageFilter + * \sa MuellerToReciprocalCovarianceFunctor * */ template< class TInput, class TOutput> @@ -58,10 +87,10 @@ public: StokesVectorType Si; StokesVectorType Sr; - double m_PowerMin(itk::NumericTraits<double>::max()); - double m_PowerMax(itk::NumericTraits<double>::min()); - double m_PolarisationDegreeMin(itk::NumericTraits<double>::max()); - double m_PolarisationDegreeMax(itk::NumericTraits<double>::min()); + double l_PowerMin(itk::NumericTraits<double>::max()); + double l_PowerMax(itk::NumericTraits<double>::min()); + double l_PolarisationDegreeMin(itk::NumericTraits<double>::max()); + double l_PolarisationDegreeMax(itk::NumericTraits<double>::min()); TOutput result; result.SetSize(m_NumberOfComponentsPerPixel); @@ -111,32 +140,32 @@ public: deg_pol = vcl_sqrt(Sr[1] * Sr[1] + Sr[2] * Sr[2] + Sr[3] * Sr[3]) / Sr[0]; } - if (P > m_PowerMax) + if (P > l_PowerMax) { - m_PowerMax = P; + l_PowerMax = P; } else { - m_PowerMin = P; + l_PowerMin = P; } - if (deg_pol > m_PolarisationDegreeMax) + if (deg_pol > l_PolarisationDegreeMax) { - m_PolarisationDegreeMax = deg_pol; + l_PolarisationDegreeMax = deg_pol; } else { - m_PolarisationDegreeMin = deg_pol; + l_PolarisationDegreeMin = deg_pol; } psi += 5.0; } tau += 5.0; } - result[0] = m_PowerMin; - result[1] = m_PowerMax; - result[2] = m_PolarisationDegreeMin; - result[3] = m_PolarisationDegreeMax; + result[0] = l_PowerMin; + result[1] = l_PowerMax; + result[2] = l_PolarisationDegreeMin; + result[3] = l_PolarisationDegreeMax; return result; @@ -162,18 +191,25 @@ private: /** \class otbMuellerToPolarisationDegreeAndPowerImageFilter - * \brief Compute the circular polarisation image (3 channels : LL, RR and LR) + * \brief Compute the polarization degree and power (4 channels : Power min and max, Polarization degree min and max) * from the Mueller image (16 real channels) + * For more details, please refer to the class MuellerToPolarisationDegreeAndPowerFunctor. + * + * \ingroup SARPolarimetry + * \sa MuellerToPolarisationDegreeAndPowerFunctor + * */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::MuellerToPolarisationDegreeAndPowerFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > +template <class TInputImage, class TOutputImage> class ITK_EXPORT MuellerToPolarisationDegreeAndPowerImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> + public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::MuellerToPolarisationDegreeAndPowerFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > { public: /** Standard class typedefs. */ typedef MuellerToPolarisationDegreeAndPowerImageFilter Self; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; + typedef typename Functor::MuellerToPolarisationDegreeAndPowerFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; + typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilter.h b/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..b75735edf06f13675f966e272da6c0456d54ce33 --- /dev/null +++ b/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilter.h @@ -0,0 +1,161 @@ +/*========================================================================= + + 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 __MuellerToReciprocalCovarianceImageFilter_h +#define __MuellerToReciprocalCovarianceImageFilter_h + +#include "otbUnaryFunctorImageFilter.h" + +namespace otb + { + +namespace Functor { + +/** \class otbMuellerToReciprocalCovarianceFunctor + * \brief Evaluate the MLC image from the Mueller image + * + * Output value are: + * channel #0 : \f$ M_{11} + M_{22} + 2*M_{12} \f$ \\ + * channel #1 : \f$ M_{11} - M_{22} \f$ \\ + * channel #2 : \f$ M_{11} + M_{22} - 2*M_{12} \f$ \\ + * channel #3 : \f$ M_{13} + M_{23} + i*(M_{14}+M_{24}) \f$ \\ + * channel #4 : \f$ M_{33} - M_{44} - 2*i*M_{34} \f$ \\ + * channel #5 : \f$ M_{13} - M_{23} - i*(M_{14}-M_{24}) \f$ \\ + * + * Where \f$ M_{ij} are the coefficients of the input Mueller matrix. + * Input pixel must have 10 channels (one for each Mueller matrix coeffcients). + * The order of the channels corresponds to : + * \f$ \begin{pmatrix} + * {channel #0 }&{channel #1 }&{channel #2 }&{channel #3 } \\ + * {channel #4 }&{channel #5 }&{channel #6 }&{channel #7 } \\ + * {channel #8 }&{channel #9 }&{channel #10}&{channel #11} \\ + * {channel #12}&{channel #13}&{channel #14}&{channel #15} \\ + * \end{pmatrix} + * + * The output image has 6 channels : the diagonal and the upper element of the reciprocal matrix. + * Element are stored from left to right, line by line. + * + * \ingroup Functor + * \ingroup SARPolarimetry + * + * \sa MuellerToCircularPolarisationImageFilter + * \sa MuellerToPolarisationDegreeAndPowerImageFilter + * + */ + +template< class TInput, class TOutput> +class MuellerToReciprocalCovarianceFunctor +{ +public: + typedef std::complex<double> ComplexType; + typedef typename TOutput::ValueType OutputValueType; + + + inline TOutput operator()( const TInput & Mueller ) const + { + TOutput result; + result.SetSize(m_NumberOfComponentsPerPixel); + + // Keep the upper diagonal of the matrix + const double M11 = static_cast<double>(Mueller[0]); + const double M12 = static_cast<double>(Mueller[1]); + const double M13 = static_cast<double>(Mueller[2]); + const double M14 = static_cast<double>(Mueller[3]); + const double M22 = static_cast<double>(Mueller[5]); + const double M23 = static_cast<double>(Mueller[6]); + const double M24 = static_cast<double>(Mueller[7]); + const double M33 = static_cast<double>(Mueller[10]); + const double M34 = static_cast<double>(Mueller[11]); + const double M44 = static_cast<double>(Mueller[15]); + + const ComplexType hhhh(M11+M22+2.*M12, 0.0); + const ComplexType hvhv(M11-M22, 0.0); + const ComplexType vvvv(M11+M22-2.*M12, 0.0); + const ComplexType hhhv(M13+M23, M14+M24); + const ComplexType hhvv(-M33-M44, -2.*M34); + const ComplexType hvvv(M13-M23, M14-M24); + + result[0] = static_cast<OutputValueType>( hhhh ); + result[1] = static_cast<OutputValueType>( 2.* hhhv ); + result[2] = static_cast<OutputValueType>( hhvv ); + result[3] = static_cast<OutputValueType>( 4.* hvhv ); + result[4] = static_cast<OutputValueType>( 2.* hvvv ); + result[5] = static_cast<OutputValueType>( vvvv ); + + return result; + } + + unsigned int GetOutputSize() + { + return m_NumberOfComponentsPerPixel; + } + + /** Constructor */ + MuellerToReciprocalCovarianceFunctor() : m_NumberOfComponentsPerPixel(6) {} + + /** Destructor */ + virtual ~MuellerToReciprocalCovarianceFunctor() {} + + private: + unsigned int m_NumberOfComponentsPerPixel; +}; +} + + +/** \class otbMuellerToReciprocalCovarianceImageFilter + * \brief Compute the MLC image + * from the Mueller image (16 real channels) + * For more details, lease refer to the class MuellerToReciprocalCovarianceFunctor. + * + * \ingroup SARPolarimetry + * \sa MuellerToReciprocalCovarianceFunctor + * + */ +template <class TInputImage, class TOutputImage> +class ITK_EXPORT MuellerToReciprocalCovarianceImageFilter : + public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::MuellerToReciprocalCovarianceFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > +{ +public: + /** Standard class typedefs. */ + typedef MuellerToReciprocalCovarianceImageFilter Self; + typedef Functor::MuellerToReciprocalCovarianceFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; + typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Runtime information support. */ + itkTypeMacro(MuellerToReciprocalCovarianceImageFilter, UnaryFunctorImageFilter); + + +protected: + MuellerToReciprocalCovarianceImageFilter() {} + virtual ~MuellerToReciprocalCovarianceImageFilter() {} + +private: + MuellerToReciprocalCovarianceImageFilter(const Self&); // purposely not implemented + void operator=(const Self&); // purposely not implemented +}; + +} // end namespace otb + +#endif diff --git a/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h b/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h index 7af729534c5482e7560efd2bef5fe4e6f64e5b57..a93d40889e582c591f87b636ab45de27534e5038 100644 --- a/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h +++ b/Code/SARPolarimetry/otbMultiChannelsPolarimetricSynthesisFilter.h @@ -28,9 +28,14 @@ namespace otb { /** \class MultiChannelsPolarimetricSynthesisFilter - * \brief TODO + * \brief This class computes the polarimetric synthesis from two to four radar images, depening on the polarimetric architecture. * + * It has the same behaviour as the PolarimetricSynthesisImageFilter expect the fact that it + * considers a VectorImage as input which each channels is HH, HV, VH and VV (in this particular order). * + * \ingroup SARPolarimetry + * \sa PolarimetricSynthesisFilter + * \sa PolarimetricSynthesisFunctor * */ diff --git a/Code/SARPolarimetry/otbPolarimetricData.h b/Code/SARPolarimetry/otbPolarimetricData.h index 938ba50fb5dacc99b06e2ae26b672e3eb22efdf7..0a0a58bb1478bf02b5a7a20bbca6b6636e616642 100644 --- a/Code/SARPolarimetry/otbPolarimetricData.h +++ b/Code/SARPolarimetry/otbPolarimetricData.h @@ -26,6 +26,7 @@ namespace otb { /** * This enumeration describes the different architectures we can find in polarimetry. + * HH_HV_VH_VV (0), HH_HV_VV (1), HH_VH_VV (2), HH_HV(3), VH_VV (4), HH_VV (5). */ typedef enum { diff --git a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h index 53551f4eefe9689dc13305c32b4f0b7de5653117..7dc21ad92bfabbfadd2b5abe1713faeceaf5277b 100644 --- a/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h +++ b/Code/SARPolarimetry/otbPolarimetricSynthesisFilter.h @@ -34,14 +34,14 @@ namespace otb * depening on the polarimetric architecture: * * - HH_HV : two channels are available: \f$ S_{HH} \f$ and \f$ S_{HV} \f$ . - * Emit polarisation is fixed to horizontal orientation: \f$ \psi_{i}=0 \f$ and \f$ \chi_{i}=0 \f$ . + * Emit polarisation is fixed to horizontal orientation: \f$ \psi_{i}=0 \f$ and \f$ \chi_{i}=0 \f$ . \\ * - VV_VH : two channels are available: \f$ S_{VV} \f$ and \f$ S_{VH} \f$ . - * Emit polarisation is fixed to vertical orientation: \f$ \psi_{i}=90^\circ \f$ and \f$ \chi_{i}=0 \f$ . + * Emit polarisation is fixed to vertical orientation: \f$ \psi_{i}=90^\circ \f$ and \f$ \chi_{i}=0 \f$ . \\ * - HH_HV_VV : three channels are available: \f$ S_{HH} \f$ , \f$ S_{HV} \f$ and \f$ S_{VV} \f$ . - * we make the assumption that cross polarisation are reciprocal ( \f$ S_{HV} = S_{VH} \f$ ). - * - HH_HV_VH_VV: four channels are available \f$ S_{HH} \f$ , \f$ S_{HV} \f$ , \f$ S_{VH} \f$ and \f$ S_{VV} \f$ . + * we make the assumption that cross polarisation are reciprocal ( \f$ S_{HV} = S_{VH} \f$ ). \\ + * - HH_HV_VH_VV: four channels are available \f$ S_{HH} \f$ , \f$ S_{HV} \f$ , \f$ S_{VH} \f$ and \f$ S_{VV} \f$ . \\ * - * To resolve the synthesis, four parameters are required: \f$ \psi_{i} \f$ , \f$ \chi_{i} \f$ , \f$ \psi_{r} \f$ and \f$ \chi_{r} \f$ . + * To resolve the synthesis, four parameters are required: \f$ \psi_{i} \f$ , \f$ \chi_{i} \f$ , \f$ \psi_{r} \f$ and \f$ \chi_{r} \f$ . \\ * These parameters depend on the polarimetric architecture describe below. * * The result of the synthesis is a scalar image. Three modes are available: @@ -57,6 +57,7 @@ namespace otb * * \ingroup SARPolarimetry * \sa PolarimetricSynthesisFunctor + * \sa MultiChannelsPolarimetricSynthesisFilter * */ diff --git a/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h b/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h index 8df737d0dad779143301498841c15157ea6d8fa3..5226aef5249ad2180b38dfbcc9f92de7cf7d6af1 100644 --- a/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h +++ b/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h @@ -31,8 +31,7 @@ namespace Functor * * This functor calculate the polarimetric synthesis * using the electroMagneticField vectors as follow: - * \f$ \sigma(\psi_{i},\chi_{i},\psi_{r},\chi_{r}) = \\ - \vec(E_{r})\cdot\left[ S \right] \vec(E_{i}) \f$ + * \f$ \sigma(\psi_{i},\chi_{i},\psi_{r},\chi_{r}) = \vec(E_{r})\cdot\left[ S \right] \vec(E_{i}) \f$ * * \ingroup Functor * \ingroup SARPolarimetry diff --git a/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h b/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h index ccea573ea45926ebec295fc813f50018f4dce881..184e6340e50b822628cb15f38ecd6694a5e40ae9 100644 --- a/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h +++ b/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.h @@ -30,24 +30,27 @@ namespace Functor { * \brief Evaluate the Mueller matrix from the reciprocal coherency matrix image * * Outpus are: - * channel #0 : \f$ 0.5*\mathcal{Re}( Coherency[0]+Coherency[3]+Coherency[5]) \f$ - * channel #1 : \f$ 0.5*\mathcal{Re}( Coherency[0]+Coherency[3]-Coherency[5]) \f$ - * channel #2 : \f$ 0.5*\mathcal{Re}( Coherency[0]-Coherency[3]+Coherency[5]) \f$ - * channel #3 : \f$ 0.5*\mathcal{Re}(-Coherency[0]+Coherency[3]+Coherency[5]) \f$ - * channel #4 : \f$ \mathcal{Re}(Coherency[1]) \f$ - * channel #5 : \f$ \mathcal{Re}(Coherency[2]) \f$ - * channel #6 : \f$ \mathcal{Im}(Coherency[4]) \f$ - * channel #7 : \f$ \mathcal{Re}(Coherency[4]) \f$ - * channel #8 : \f$ \mathcal{Im}(Coherency[2]) \f$ - * channel #9 : \f$ \mathcal{Im}(Coherency[1]) \f$ + * channel #0 : \f$ 0.5*\mathcal{Re}( Coherency[0]+Coherency[3]+Coherency[5]) \f$ \\ + * channel #1 : \f$ 0.5*\mathcal{Re}( Coherency[0]+Coherency[3]-Coherency[5]) \f$ \\ + * channel #2 : \f$ 0.5*\mathcal{Re}( Coherency[0]-Coherency[3]+Coherency[5]) \f$ \\ + * channel #3 : \f$ 0.5*\mathcal{Re}(-Coherency[0]+Coherency[3]+Coherency[5]) \f$ \\ + * channel #4 : \f$ \mathcal{Re}(Coherency[1]) \f$ \\ + * channel #5 : \f$ \mathcal{Re}(Coherency[2]) \f$ \\ + * channel #6 : \f$ \mathcal{Im}(Coherency[4]) \f$ \\ + * channel #7 : \f$ \mathcal{Re}(Coherency[4]) \f$ \\ + * channel #8 : \f$ \mathcal{Im}(Coherency[2]) \f$ \\ + * channel #9 : \f$ \mathcal{Im}(Coherency[1]) \f$ \\ * * Where Coherency is the input pixel and contains: - * channel #0 : \f$ (S_{hh}+S_{vv}).(S_{hh}+S_{vv})^{*} \f$ - * channel #1 : \f$ (S_{hh}+S_{vv}).(S_{hh}-S_{vv})^{*} \f$ - * channel #2 : \f$ (S_{hh}+S_{vv}).(2*S_{hv})^{*} \f$ - * channel #3 : \f$ (S_{hh}-S_{vv}).(S_{hh}-S_{vv})^{*} \f$ - * channel #4 : \f$ (S_{hh}-S_{vv}).(2*S_{hv})^{*} \f$ - * channel #5 : \f$ (2*S_{hv}).(2*S_{hv})^{*} \f$ + * channel #0 : \f$ (S_{hh}+S_{vv}).(S_{hh}+S_{vv})^{*} \f$ \\ + * channel #1 : \f$ (S_{hh}+S_{vv}).(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #2 : \f$ (S_{hh}+S_{vv}).(2*S_{hv})^{*} \f$ \\ + * channel #3 : \f$ (S_{hh}-S_{vv}).(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #4 : \f$ (S_{hh}-S_{vv}).(2*S_{hv})^{*} \f$ \\ + * channel #5 : \f$ (2*S_{hv}).(2*S_{hv})^{*} \f$ \\ + * + * The output pixel has 10 channels : the diagonal and the upper element of the matrix. + * Element are stored from left to right, line by line. * * \ingroup SARPolarimetry */ @@ -99,18 +102,26 @@ private: /** \class otbReciprocalCoherencyToMuellerImageFilter - * \brief Compute the Mueller matrix image (9 real channels) + * \brief Compute the Mueller matrix image (10 real channels) * from the Reciprocal coherency image (6 complex channels) + * + * For more datails, please refer to ReciprocalCoherencyToMuellerFunctor. + * + * \ingroup SARPolarimetry + * \sa ReciprocalCoherencyToMuellerFunctor + * */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::ReciprocalCoherencyToMuellerFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > +template <class TInputImage, class TOutputImage> class ITK_EXPORT ReciprocalCoherencyToMuellerImageFilter : - public otb::UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> + public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalCoherencyToMuellerFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > { public: /** Standard class typedefs. */ typedef ReciprocalCoherencyToMuellerImageFilter Self; - typedef otb::UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; + typedef typename Functor::ReciprocalCoherencyToMuellerFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; + typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -125,6 +136,7 @@ protected: ReciprocalCoherencyToMuellerImageFilter() {} virtual ~ReciprocalCoherencyToMuellerImageFilter() {} + private: ReciprocalCoherencyToMuellerImageFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented diff --git a/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h b/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h index 4ab3d2e9e4fcb6f2fc63ba8f970dbd8d4353be0c..cdac1d58e3a6dcba1712ca355634bcebbddb8e93 100644 --- a/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h +++ b/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h @@ -30,9 +30,9 @@ namespace Functor { * \brief Evaluate the Coherency Degree coefficient from from the MLC image * * Output value are: - * channel #0 : \f$ abs(S_{hh}*S_{vv}}^{*}) / sqrt(S_{hh}*S_{hh}}^{*}) / sqrt(S_{vv}*S_{vv}}^{*}) \f$ - * channel #1 : \f$ abs(S_{hv}*S_{vv}}^{*}) / sqrt(S_{hv}*S_{hv}}^{*}) / sqrt(S_{vv}*S_{vv}}^{*}) \f$ - * channel #2 : \f$ abs(S_{hh}*S_{hv}}^{*}) / sqrt(S_{hh}*S_{hh}}^{*}) / sqrt(S_{hv}*S_{hv}}^{*}) \f$ + * channel #0 : \f$ abs(S_{hh}*S_{vv}}^{*}) / sqrt(S_{hh}*S_{hh}}^{*}) / sqrt(S_{vv}*S_{vv}}^{*}) \f$ \\ + * channel #1 : \f$ abs(S_{hv}*S_{vv}}^{*}) / sqrt(S_{hv}*S_{hv}}^{*}) / sqrt(S_{vv}*S_{vv}}^{*}) \f$ \\ + * channel #2 : \f$ abs(S_{hh}*S_{hv}}^{*}) / sqrt(S_{hh}*S_{hh}}^{*}) / sqrt(S_{hv}*S_{hv}}^{*}) \f$ \\ * * * \infgroup Functor @@ -109,16 +109,23 @@ private: /** \class otbReciprocalCovarianceToCoherencyDegreeImageFilter * \brief Compute the Coherency Degree coefficient * from the MLC image (6 complex channels) + * For more details, lease refer to the class ReciprocalCovarianceToCoherencyDegreeFunctor. + * + * \ingroup SARPolarimetry + * \sa ReciprocalCovarianceToCoherencyDegreeFunctor + * */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::ReciprocalCovarianceToCoherencyDegreeFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > +template <class TInputImage, class TOutputImage> class ITK_EXPORT ReciprocalCovarianceToCoherencyDegreeImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> + public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalCovarianceToCoherencyDegreeFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > { public: /** Standard class typedefs. */ typedef ReciprocalCovarianceToCoherencyDegreeImageFilter Self; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; + typedef typename Functor::ReciprocalCovarianceToCoherencyDegreeFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; + typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h b/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h index 65f6c95fabd9ff4cdec5a3c3c0a1bd33f466ab1e..38a5ed4b403c7358e446a7f8fb8ef53dbecfe532 100644 --- a/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h +++ b/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h @@ -30,12 +30,15 @@ namespace Functor { * \brief Evaluate the Coherency matrix from the Covariance image * * Output value are: - * channel #0 : \f$ 0.5 * (S_{hh}+S_{vv}.(S_{hh}+S_{vv})^{*} \f$ - * channel #1 : \f$ 0.5 * (S_{hh}+S_{vv}.(S_{hh}-S_{vv})^{*} \f$ - * channel #2 : \f$ (S_{hh}+S_{vv}.(S_{hv})^{*} \f$ - * channel #3 : \f$ 0.5 * (S_{hh}-S_{vv}.(S_{hh}-S_{vv})^{*} \f$ - * channel #4 : \f$ (S_{hh}-S_{vv}.(S_{hv})^{*} \f$ - * channel #5 : \f$ 2.0*S_{hv}.S_{hv}^{*} \f$ + * channel #0 : \f$ 0.5 * (S_{hh}+S_{vv}.(S_{hh}+S_{vv})^{*} \f$ \\ + * channel #1 : \f$ 0.5 * (S_{hh}+S_{vv}.(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #2 : \f$ (S_{hh}+S_{vv}.(S_{hv})^{*} \f$ \\ + * channel #3 : \f$ 0.5 * (S_{hh}-S_{vv}.(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #4 : \f$ (S_{hh}-S_{vv}.(S_{hv})^{*} \f$ \\ + * channel #5 : \f$ 2.0*S_{hv}.S_{hv}^{*} \f$ \\ + * + * The output pixel has 6 channels : the diagonal and the upper element of the reciprocal matrix. + * Element are stored from left to right, line by line. * * \infgroup Functor * \ingroup SARPolarimetry @@ -104,16 +107,23 @@ private: /** \class otbReciprocalCovarianceToReciprocalCoherencyImageFilter * \brief Compute the Coherency image (6 complex channels) * from the Covariance image (6 complex channels) + * + * For more details, please refer to the class ReciprocalCovarianceToReciprocalCoherencyFunctor. + * + * \ingroup SARPolarimetry + * \sa ReciprocalCovarianceToReciprocalCoherencyFunctor */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > +template <class TInputImage, class TOutputImage> class ITK_EXPORT ReciprocalCovarianceToReciprocalCoherencyImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> + public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > { public: /** Standard class typedefs. */ typedef ReciprocalCovarianceToReciprocalCoherencyImageFilter Self; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; + typedef Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctorType; + typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctorType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h b/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h index dde56ad11960624c6f0858aa488ab665cfd8b008..bcd5c0a293770d8eba91257aeed4f93d34c16e34 100644 --- a/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h +++ b/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h @@ -30,12 +30,22 @@ namespace otb namespace Functor { /** \class otbHAlphaFunctor - * \brief Evaluate the H-Alpha parameters from the reciprocal coherency matrix image + * \brief Evaluate the H-Alpha parameters from the reciprocal coherency matrix image. + * + * To process, we diagonalise the complex coherency matrix (size 3*3). We call \f$ SortedEigenValues \f$ the list that contains the + * eigen values of the matrix sorted in decrease order. \f$ SortedEigenVector \f$ the corresponding list + * of eigen vector. * * Output value are: - * channel #0 : entropy - * channel #1 : \f$ \alpha \f$ parameter - * channel #2 : anisotropy + * channel #0 : \f$ entropy = -\sum_{i=0}^{2}{p[i].\log{p[i]}} / \log{3} \f$ \\ + * channel #1 : \f$ \alpha = \sum_{i=0}^{2}{p[i].\alpha_{i} \f$ \\ + * channel #2 : \f$ anisotropy = \frac {SortedEigenValues[1] - SortedEigenValues[2]}{SortedEigenValues[1] + SortedEigenValues[2]} \f$ \\ + * + * Where: + * \f$ p[i] = \max{SortedEigenValues[i], 0} / \sum_{i=0}^{2, SortedEigenValues[i]>0}{SortedEigenValues[i]} \f$ \\ + * Then, \f$ if p[i] < 0, p[i]=0, if p[i] > 1, p[i]=1. \f$ \\ + * \f$ \alpha_{i} = \left| SortedEigenVector[i] \right|* \frac{180}{\pi}\f$ \\ + * Then, \f$ if \alpha_{i} > 90, \alpha_{i}=90. \f$ \\ * * \ingroup SARPolarimetry * @@ -78,8 +88,8 @@ public: const VNLVectorType eigenValues(syst.W); // Entropy estimation - double totalEigenValues(0.0); - double p[3]; + double totalEigenValues(0.0); + double p[3]; double entropy; double alpha; double anisotropy; @@ -192,16 +202,23 @@ private: /** \class otbHAlphaImageFilter * \brief Compute the H-Alpha image (3 channels) * from the Reciprocal coherency image (6 complex channels) + * + * For more details, please refer to the class ReciprocalHAlphaFunctor. + * + * \ingroup SARPOlarimetry + * \sa ReciprocalHAlphaFunctor */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::ReciprocalHAlphaFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > +template <class TInputImage, class TOutputImage> class ITK_EXPORT ReciprocalHAlphaImageFilter : - public otb::UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> + public otb::UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalHAlphaFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > { public: /** Standard class typedefs. */ typedef ReciprocalHAlphaImageFilter Self; - typedef otb::UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; + typedef typename Functor::ReciprocalHAlphaFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; + typedef otb::UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h b/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h index 24e02335cbc683e0eb577012f1da76419a67a7aa..9ad961437caaf99737b3841426473f430f4d4e7e 100644 --- a/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h +++ b/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h @@ -31,23 +31,26 @@ namespace Functor { * Extract from Antennas for radar and communications Harold Mott p 317. * * Output value are: - * channel #0 : \f$ 0.25 * (C_{1}+C_{3}+4*C_{2}-2*C_{6}-4*C_{5}-4*C_{9}) \f$ - * channel #1 : \f$ 0.25 * (C_{1}-C_{3}+2*C_{5}+2*C_{9} - 0.5\mathcal{i}.(C_{4}+C_{7}+C_{8}) \f$ - * channel #2 : \f$ 0.25 * (C_{1}+C_{3}-4*C_{2}-2*C_{6} - \mathcal{i}.(C_{4}+C_{8}) \f$ - * channel #3 : \f$ 0.25 * (C_{1}+C_{3}+2*C_{6} \f$ - * channel #4 : \f$ 0.25 * (C_{1}-C_{3}+2*C_{5}-2*C_{9} - 0.5\mathcal{i}.(C_{4}-C_{7}+C_{8}) \f$ - * channel #5 : \f$ 0.25 * (C_{1}+C_{3}+4*C_{2}-2*C_{6}+4*C_{5}+4*C_{9}) \f$ + * channel #0 : \f$ 0.25 * (C_{1}+C_{3}+4*C_{2}-2*C_{6}-4*C_{5}-4*C_{9}) \f$ \\ + * channel #1 : \f$ 0.25 * (C_{1}-C_{3}+2*C_{5}+2*C_{9} - 0.5\mathcal{i}.(C_{4}+C_{7}+C_{8}) \f$ \\ + * channel #2 : \f$ 0.25 * (C_{1}+C_{3}-4*C_{2}-2*C_{6} - \mathcal{i}.(C_{4}+C_{8}) \f$ \\ + * channel #3 : \f$ 0.25 * (C_{1}+C_{3}+2*C_{6} \f$ \\ + * channel #4 : \f$ 0.25 * (C_{1}-C_{3}+2*C_{5}-2*C_{9} - 0.5\mathcal{i}.(C_{4}-C_{7}+C_{8}) \f$ \\ + * channel #5 : \f$ 0.25 * (C_{1}+C_{3}+4*C_{2}-2*C_{6}+4*C_{5}+4*C_{9}) \f$ \\ * * Where: - * \f$ C_{1} = S_{hh}*S_{hh}}^{*} = \mathcal{Re}(input[0]) \f$ - * \f$ C_{2} = S_{hv}*S_{hv}}^{*} = \mathcal{Re}(input[3]) \f$ - * \f$ C_{3} = S_{vv}*S_{vv}}^{*} = \mathcal{Re}(input[5]) \f$ - * \f$ C_{4} = \mathcal{Re}(S_{hh}*S_{hv}}^{*}) = \mathcal{Re}(input[1]) \f$ - * \f$ C_{5} = \mathcal{Im}(S_{hh}*S_{hv}}^{*}) = \mathcal{Im}(input[1]) \f$ - * \f$ C_{6} = \mathcal{Re}(S_{hh}*S_{vv}}^{*}) = \mathcal{Re}(input[2]) \f$ - * \f$ C_{7} = \mathcal{Im}(S_{hh}*S_{vv}}^{*}) = \mathcal{Im}(input[2]) \f$ - * \f$ C_{8} = \mathcal{Re}(S_{hv}*S_{vv}}^{*}) = \mathcal{Re}(input[4]) \f$ - * \f$ C_{9} = \mathcal{Im}(S_{hv}*S_{vv}}^{*} = \mathcal{Im}(input[4])) \f$ + * \f$ C_{1} = S_{hh}*S_{hh}}^{*} = \mathcal{Re}(input[0]) \f$ \\ + * \f$ C_{2} = S_{hv}*S_{hv}}^{*} = \mathcal{Re}(input[3]) \f$ \\ + * \f$ C_{3} = S_{vv}*S_{vv}}^{*} = \mathcal{Re}(input[5]) \f$ \\ + * \f$ C_{4} = \mathcal{Re}(S_{hh}*S_{hv}}^{*}) = \mathcal{Re}(input[1]) \f$ \\ + * \f$ C_{5} = \mathcal{Im}(S_{hh}*S_{hv}}^{*}) = \mathcal{Im}(input[1]) \f$ \\ + * \f$ C_{6} = \mathcal{Re}(S_{hh}*S_{vv}}^{*}) = \mathcal{Re}(input[2]) \f$ \\ + * \f$ C_{7} = \mathcal{Im}(S_{hh}*S_{vv}}^{*}) = \mathcal{Im}(input[2]) \f$ \\ + * \f$ C_{8} = \mathcal{Re}(S_{hv}*S_{vv}}^{*}) = \mathcal{Re}(input[4]) \f$ \\ + * \f$ C_{9} = \mathcal{Im}(S_{hv}*S_{vv}}^{*} = \mathcal{Im}(input[4])) \f$ \\ + * + * The output pixel has 6 channels : the diagonal and the upper element of the reciprocal matrix. + * Element are stored from left to right, line by line. * * \infgroup Functor * \ingroup SARPolarimetry @@ -118,16 +121,22 @@ private: /** \class otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter * \brief Compute the reciprocal Covariance circular matrix image from the reciprocal Covariance linear matrix image. + * For more details, please refer to the class ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor. + * + * \ingroup SARPolarimetry + * \sa ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor */ -template <class TInputImage, class TOutputImage, class TFunction = Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor< - ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > + template <class TInputImage, class TOutputImage> class ITK_EXPORT ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter : - public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> + public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor< + ITK_TYPENAME TInputImage::PixelType, ITK_TYPENAME TOutputImage::PixelType> > { public: /** Standard class typedefs. */ typedef ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter Self; - typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, TFunction> Superclass; + typedef typename Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor< + typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; + typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Code/SARPolarimetry/otbSinclairImageFilter.h b/Code/SARPolarimetry/otbSinclairImageFilter.h index 52b583b5f71068166bc1ef4868ffff2a3d872dca..d584232febee665cceb0c66ddfcf148f9f6c896d 100644 --- a/Code/SARPolarimetry/otbSinclairImageFilter.h +++ b/Code/SARPolarimetry/otbSinclairImageFilter.h @@ -26,12 +26,24 @@ namespace otb { /** \class SinclairImageFilter - * \brief Convert the Sinclair matrix + * \brief Computes the Covariance matrix for the sinclair one. * * This class is parameterized over the type of the input images and - * the type of the output image. It is also parameterized by the + * the type of the output image. It is also parameterized by the * operation to be applied, using a Functor style. * + * The output image has 10 channels : the diagonal and the upper element of the matrix. + * Element are stored from left to right, line by line. + * + * The class is templated by the 4 input image (HH, HV, VH and VV) and the used functor. + * Available functors are : + * \begin{itemize} + * \item SinclairToCircularCovarianceMatrixFunctor (default one) + * \item SinclairToCoherencyMatrixFunctor + * \item SinclairToCovarianceMatrixFunctor + * \item SinclairToMuelleMatrixrFunctor + * \end{itemize} + * * \ingroup SARPolarimetry * * \sa SinclairImageFilter diff --git a/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h b/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h index 0da324822d685ef522a9dc7d0825783a82a865f6..033442c1ac8e4a95cb06372bc4a9e43f644a83d9 100644 --- a/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h +++ b/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h @@ -29,9 +29,20 @@ namespace otb * \brief Convert the Sinclair reciprocal matrix. * * This class is parameterized over the type of the input images and - * the type of the output image. It is also parameterized by the + * the type of the output image. It is also parameterized by the * operation to be applied, using a Functor style. * + * The output image has 6 channels : the diagonal and the upper element of the reciprocal matrix. + * Element a sotored from left to right, line by line. + * + * The class is templated by the 4 input image (HH, HV, VH and VV) and the used functor. + * Available functors are : + * \begin{itemize} + * \item SinclairToReciprocalCovarianceMatrixFunctor (default one) + * \item SinclairToReciprocalCircularCovarianceMatrixFunctor + * \item SinclairToReciprocalCoherencyMatrixFunctor + * \end{itemize} + * * \ingroup SARPolarimetry * * \sa SinclairImageFilter diff --git a/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h index e5ee98e624ecd92f16d6c8921f1629ac49d74342..0f3f8314ed30625cb6b877ac53c54d83b4708c33 100644 --- a/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToCircularCovarianceMatrixFunctor.h @@ -30,24 +30,27 @@ namespace Functor * with Sinclair matrix information. * * Output value are: - * channel #0 : \f$ S_{ll}.S_{ll}^{*} \f$ - * channel #1 : \f$ S_{ll}.S_{lr}^{*} \f$ - * channel #2 : \f$ S_{ll}.S_{rl}^{*} \f$ - * channel #3 : \f$ S_{ll}.S_{rr}^{*} \f$ - * channel #4 : \f$ S_{lr}.S_{lr}^{*} \f$ - * channel #5 : \f$ S_{lr}.S_{rl}^{*} \f$ - * channel #6 : \f$ S_{lr}.S_{rr}^{*} \f$ - * channel #7 : \f$ S_{rl}.S_{rl}^{*} \f$ - * channel #8 : \f$ S_{rl}.S_{rr}^{*} \f$ - * channel #9 : \f$ S_{rr}.S_{rr}^{*} \f$ + * channel #0 : \f$ S_{ll}.S_{ll}^{*} \f$ \\ + * channel #1 : \f$ S_{ll}.S_{lr}^{*} \f$ \\ + * channel #2 : \f$ S_{ll}.S_{rl}^{*} \f$ \\ + * channel #3 : \f$ S_{ll}.S_{rr}^{*} \f$ \\ + * channel #4 : \f$ S_{lr}.S_{lr}^{*} \f$ \\ + * channel #5 : \f$ S_{lr}.S_{rl}^{*} \f$ \\ + * channel #6 : \f$ S_{lr}.S_{rr}^{*} \f$ \\ + * channel #7 : \f$ S_{rl}.S_{rl}^{*} \f$ \\ + * channel #8 : \f$ S_{rl}.S_{rr}^{*} \f$ \\ + * channel #9 : \f$ S_{rr}.S_{rr}^{*} \f$ \\ * * With: - * \f$ S_{ll} = 0.5 * (-S_{hh}-i*S_{hv}-i*S_{vh}+S_{vv}) \f$ - * \f$ S_{lr} = 0.5 * (-S_{hh}+i*S_{hv}-i*S_{vh}+S_{vv}) \f$ - * \f$ S_{rl} = 0.5 * (-S_{hh}-i*S_{hv}+i*S_{vh}-S_{vv}) \f$ - * \f$ S_{rr} = 0.5 * (-S_{hh}+i*S_{hv}+i*S_{vh}+S_{vv}) \f$ + * \f$ S_{ll} = 0.5 * (-S_{hh}-i*S_{hv}-i*S_{vh}+S_{vv}) \f$ \\ + * \f$ S_{lr} = 0.5 * (-S_{hh}+i*S_{hv}-i*S_{vh}+S_{vv}) \f$ \\ + * \f$ S_{rl} = 0.5 * (-S_{hh}-i*S_{hv}+i*S_{vh}-S_{vv}) \f$ \\ + * \f$ S_{rr} = 0.5 * (-S_{hh}+i*S_{hv}+i*S_{vh}+S_{vv}) \f$ \\ * Extract from Antennas for radar and communications Harold Mott p 317. * + * The output pixel has 10 channels : the diagonal and the upper element of the matrix. + * Element are stored from left to right, line by line. + * * \ingroup Functor * \ingroup SARPolarimetry * diff --git a/Code/SARPolarimetry/otbSinclairToCoherencyMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToCoherencyMatrixFunctor.h index 8c34e3acca38cc2a687cf030ef9ff46b08fad541..fa41a40e179b8f6a563193d4342c2ada96f066e3 100644 --- a/Code/SARPolarimetry/otbSinclairToCoherencyMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToCoherencyMatrixFunctor.h @@ -29,16 +29,19 @@ namespace Functor * with Sinclair matrix information. * * Output value are: - * channel #0 : \f$ (S_{hh}+S_{vv}).(S_{hh}+S_{vv})^{*} \f$ - * channel #1 : \f$ (S_{hh}+S_{vv}).(S_{hh}-S_{vv})^{*} \f$ - * channel #2 : \f$ (S_{hh}+S_{vv}).(S_{hv}+S_{vh})^{*} \f$ - * channel #3 : \f$ (S_{hh}+S_{vv}).(j(S_{hv}-S_{vh}))^{*} \f$ - * channel #4 : \f$ (S_{hh}-S_{vv}).(S_{hh}-S_{vv})^{*} \f$ - * channel #5 : \f$ (S_{hh}-S_{vv}).(S_{hv}+S_{vh})^{*} \f$ - * channel #6 : \f$ (S_{hh}-S_{vv}).(j(S_{hv}-S_{vh}))^{*} \f$ - * channel #7 : \f$ (S_{hv}+S_{vh}).(S_{hv}+S_{vh})^{*} \f$ - * channel #8 : \f$ (S_{hv}+S_{vh}).(j(S_{hv}-S_{vh}))^{*} \f$ - * channel #9 : \f$ j(S_{hv}-S_{vh}).(j(S_{hv}-S_{vh}))^{*} \f$ + * channel #0 : \f$ (S_{hh}+S_{vv}).(S_{hh}+S_{vv})^{*} \f$ \\ + * channel #1 : \f$ (S_{hh}+S_{vv}).(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #2 : \f$ (S_{hh}+S_{vv}).(S_{hv}+S_{vh})^{*} \f$ \\ + * channel #3 : \f$ (S_{hh}+S_{vv}).(j(S_{hv}-S_{vh}))^{*} \f$ \\ + * channel #4 : \f$ (S_{hh}-S_{vv}).(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #5 : \f$ (S_{hh}-S_{vv}).(S_{hv}+S_{vh})^{*} \f$ \\ + * channel #6 : \f$ (S_{hh}-S_{vv}).(j(S_{hv}-S_{vh}))^{*} \f$ \\ + * channel #7 : \f$ (S_{hv}+S_{vh}).(S_{hv}+S_{vh})^{*} \f$ \\ + * channel #8 : \f$ (S_{hv}+S_{vh}).(j(S_{hv}-S_{vh}))^{*} \f$ \\ + * channel #9 : \f$ j(S_{hv}-S_{vh}).(j(S_{hv}-S_{vh}))^{*} \f$ \\ + * + * The output pixel has 10 channels : the diagonal and the upper element of the matrix. + * Element are stored from left to right, line by line. * * \ingroup Functor * \ingroup SARPolarimetry diff --git a/Code/SARPolarimetry/otbSinclairToCovarianceMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToCovarianceMatrixFunctor.h index 13908530183e668699d97f5ce65be134969c4f02..b4ece464e43410785ed37729719a61e24e1a2287 100644 --- a/Code/SARPolarimetry/otbSinclairToCovarianceMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToCovarianceMatrixFunctor.h @@ -29,16 +29,19 @@ namespace Functor * with Sinclair matrix information. * * Output value are: - * channel #0 : \f$ S_{hh}.S_{hh}^{*} \f$ - * channel #1 : \f$ S_{hh}.S_{hv}^{*} \f$ - * channel #2 : \f$ S_{hh}.S_{vh}^{*} \f$ - * channel #3 : \f$ S_{hh}.S_{vv}^{*} \f$ - * channel #4 : \f$ S_{hv}.S_{hv}^{*} \f$ - * channel #5 : \f$ S_{hv}.S_{vh}^{*} \f$ - * channel #6 : \f$ S_{hv}.S_{vv}^{*} \f$ - * channel #7 : \f$ S_{vh}.S_{vh}^{*} \f$ - * channel #8 : \f$ S_{vh}.S_{vv}^{*} \f$ - * channel #9 : \f$ S_{vv}.S_{vv}^{*} \f$ + * channel #0 : \f$ S_{hh}.S_{hh}^{*} \f$ \\ + * channel #1 : \f$ S_{hh}.S_{hv}^{*} \f$ \\ + * channel #2 : \f$ S_{hh}.S_{vh}^{*} \f$ \\ + * channel #3 : \f$ S_{hh}.S_{vv}^{*} \f$ \\ + * channel #4 : \f$ S_{hv}.S_{hv}^{*} \f$ \\ + * channel #5 : \f$ S_{hv}.S_{vh}^{*} \f$ \\ + * channel #6 : \f$ S_{hv}.S_{vv}^{*} \f$ \\ + * channel #7 : \f$ S_{vh}.S_{vh}^{*} \f$ \\ + * channel #8 : \f$ S_{vh}.S_{vv}^{*} \f$ \\ + * channel #9 : \f$ S_{vv}.S_{vv}^{*} \f$ \\ + * + * The output pixel has 10 channels : the diagonal and the upper element of the matrix. + * Element are stored from left to right, line by line. * * \ingroup Functor * \ingroup SARPolarimetry diff --git a/Code/SARPolarimetry/otbSinclairToMuellerMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToMuellerMatrixFunctor.h index a961fef9a92dafa541afc0fbd702b3c3a2b4d00d..4d92ae725fdf6c19fc5a0ffe25178bd008eebcd3 100644 --- a/Code/SARPolarimetry/otbSinclairToMuellerMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToMuellerMatrixFunctor.h @@ -30,30 +30,37 @@ namespace Functor * Harold Mott p 503 * * Output value are: - * channel #0 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} + T_{xy}.T_{xy}^{*} + T_{yx}.T_{yx}^{*} + T_{yy}.T_{yy}^{*} ) \f$ - * channel #1 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} - T_{xy}.T_{xy}^{*} + T_{yx}.T_{yx}^{*} - T_{yy}.T_{yy}^{*} ) \f$ - * channel #2 : \f$ \mathcal{Re}( T_{xx}.T_{xy}^{*} + T_{yx}.T_{yy}^{*} ) \f$ - * channel #3 : \f$ \mathcal{Im}( T_{xx}.T_{xy}^{*} + T_{yx}.T_{yy}^{*} ) \f$ - * channel #4 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} + T_{xy}.T_{xy}^{*} - T_{yx}.T_{yx}^{*} - T_{yy}.T_{yy}^{*} ) \f$ - * channel #5 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} - T_{xy}.T_{xy}^{*} - T_{yx}.T_{yx}^{*} + T_{yy}.T_{yy}^{*} ) \f$ - * channel #6 : \f$ \mathcal{Re}( T_{xx}.T_{xy}^{*} - T_{yx}.T_{yy}^{*} ) \f$ - * channel #7 : \f$ \mathcal{Im}( T_{xx}.T_{xy}^{*} - T_{yx}.T_{yy}^{*} ) \f$ - * channel #8 : \f$ \mathcal{Re}( T_{xx}.T_{yx}^{*} + T_{xy}.T_{yy}^{*} ) \f$ - * channel #9 : \f$ \mathcal{Im}( T_{xx}.T_{yx}^{*} - T_{xy}.T_{yy}^{*} ) \f$ - * channel #10 : \f$ \mathcal{Re}( T_{xx}.T_{yy}^{*} + T_{xy}.T_{yx}^{*} ) \f$ - * channel #11 : \f$ \mathcal{Im}( T_{xx}.T_{yy}^{*} - T_{xy}.T_{yx}^{*} ) \f$ - * channel #12 : \f$ \mathcal{Re}( T_{xx}.T_{yx}^{*} + T_{xy}.T_{yy}^{*} ) \f$ - * channel #13 : \f$ \mathcal{Im}( T_{xx}.T_{yx}^{*} - T_{xy}.T_{yy}^{*} ) \f$ - * channel #14 : \f$ \mathcal{Re}( T_{xx}.T_{yy}^{*} + T_{xy}.T_{yx}^{*} ) \f$ - * channel #15 : \f$ \mathcal{Im}( T_{xx}.T_{yy}^{*} - T_{xy}.T_{yx}^{*} ) \f$ + * channel #0 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} + T_{xy}.T_{xy}^{*} + T_{yx}.T_{yx}^{*} + T_{yy}.T_{yy}^{*} ) \f$ \\ + * channel #1 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} - T_{xy}.T_{xy}^{*} + T_{yx}.T_{yx}^{*} - T_{yy}.T_{yy}^{*} ) \f$ \\ + * channel #2 : \f$ \mathcal{Re}( T_{xx}.T_{xy}^{*} + T_{yx}.T_{yy}^{*} ) \f$ \\ + * channel #3 : \f$ \mathcal{Im}( T_{xx}.T_{xy}^{*} + T_{yx}.T_{yy}^{*} ) \f$ \\ + * channel #4 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} + T_{xy}.T_{xy}^{*} - T_{yx}.T_{yx}^{*} - T_{yy}.T_{yy}^{*} ) \f$ \\ + * channel #5 : \f$ 0.5 * \mathcal{Re}( T_{xx}.T_{xx}^{*} - T_{xy}.T_{xy}^{*} - T_{yx}.T_{yx}^{*} + T_{yy}.T_{yy}^{*} ) \f$ \\ + * channel #6 : \f$ \mathcal{Re}( T_{xx}.T_{xy}^{*} - T_{yx}.T_{yy}^{*} ) \f$ \\ + * channel #7 : \f$ \mathcal{Im}( T_{xx}.T_{xy}^{*} - T_{yx}.T_{yy}^{*} ) \f$ \\ + * channel #8 : \f$ \mathcal{Re}( T_{xx}.T_{yx}^{*} + T_{xy}.T_{yy}^{*} ) \f$ \\ + * channel #9 : \f$ \mathcal{Im}( T_{xx}.T_{yx}^{*} - T_{xy}.T_{yy}^{*} ) \f$ \\ + * channel #10 : \f$ \mathcal{Re}( T_{xx}.T_{yy}^{*} + T_{xy}.T_{yx}^{*} ) \f$ \\ + * channel #11 : \f$ \mathcal{Im}( T_{xx}.T_{yy}^{*} - T_{xy}.T_{yx}^{*} ) \f$ \\ + * channel #12 : \f$ \mathcal{Re}( T_{xx}.T_{yx}^{*} + T_{xy}.T_{yy}^{*} ) \f$ \\ + * channel #13 : \f$ \mathcal{Im}( T_{xx}.T_{yx}^{*} - T_{xy}.T_{yy}^{*} ) \f$ \\ + * channel #14 : \f$ \mathcal{Re}( T_{xx}.T_{yy}^{*} + T_{xy}.T_{yx}^{*} ) \f$ \\ + * channel #15 : \f$ \mathcal{Im}( T_{xx}.T_{yy}^{*} - T_{xy}.T_{yx}^{*} ) \f$ \\ * * With : - * \f$ T_{xx} = -S_{hh} \f$ - * \f$ T_{xy} = -S_{hv} \f$ - * \f$ T_{yx} = -S_{vh} \f$ - * \f$ T_{yy} = -S_{vv} \f$ + * \f$ T_{xx} = -S_{hh} \f$ \\ + * \f$ T_{xy} = -S_{hv} \f$ \\ + * \f$ T_{yx} = -S_{vh} \f$ \\ + * \f$ T_{yy} = -S_{vv} \f$ \\ * - * Output is a not a complex. + * Output is a not a complex. The output pixel has 16 channels : each element of the Mueller matrix. + * The order of the channels corresponds to : + * \f$ \begin{pmatrix} + * {channel #0 }&{channel #1 }&{channel #2 }&{channel #3 } \\ + * {channel #4 }&{channel #5 }&{channel #6 }&{channel #7 } \\ + * {channel #8 }&{channel #9 }&{channel #10}&{channel #11} \\ + * {channel #12}&{channel #13}&{channel #14}&{channel #15} \\ + * \end{pmatrix} * * \ingroup Functor * \ingroup SARPolarimetry diff --git a/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h index e6d199a96daf044fa0a60dbd1382ae2f1437ec7a..3712e2015cb56c5f3a937ecf27d5a4959402b5c1 100644 --- a/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h @@ -30,15 +30,18 @@ namespace Functor * with Sinclair matrix information. * * Output value are: - * channel #0 : \f$ S_{ll}.S_{ll}^{*} \f$ - * channel #1 : \f$ S_{ll}.S_{lr}^{*} \f$ - * channel #2 : \f$ S_{ll}.S_{rr}^{*} \f$ - * channel #3 : \f$ S_{lr}.S_{lr}^{*} \f$ - * channel #4 : \f$ S_{lr}.S_{rr}^{*} \f$ - * channel #5 : \f$ S_{rr}.S_{rr}^{*} \f$ + * channel #0 : \f$ S_{ll}.S_{ll}^{*} \f$ \\ + * channel #1 : \f$ S_{ll}.S_{lr}^{*} \f$ \\ + * channel #2 : \f$ S_{ll}.S_{rr}^{*} \f$ \\ + * channel #3 : \f$ S_{lr}.S_{lr}^{*} \f$ \\ + * channel #4 : \f$ S_{lr}.S_{rr}^{*} \f$ \\ + * channel #5 : \f$ S_{rr}.S_{rr}^{*} \f$ \\ * * This is a adaptation of the SinclairToCircularCovarianceMatrixFunctor, where \f$ S_{hv}=S_{vh} \f$. * + * The output pixel has 6 channels : the diagonal and the upper element of the reciprocal matrix. + * Element are stored from left to right, line by line. + * * \ingroup Functor * \ingroup SARPolarimetry * diff --git a/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyMatrixFunctor.h index 6813d100f39250bb8fa80d1638cdb14bab5c31ff..f53e0adec0b668263b72c72889dc7815ea688db5 100644 --- a/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToReciprocalCoherencyMatrixFunctor.h @@ -29,15 +29,18 @@ namespace Functor * with Sinclair matrix information. * * Output value are: - * channel #0 : \f$ (S_{hh}+S_{vv}).(S_{hh}+S_{vv})^{*} \f$ - * channel #1 : \f$ (S_{hh}+S_{vv}).(S_{hh}-S_{vv})^{*} \f$ - * channel #2 : \f$ (S_{hh}+S_{vv}).(2*S_{hv})^{*} \f$ - * channel #3 : \f$ (S_{hh}-S_{vv}).(S_{hh}-S_{vv})^{*} \f$ - * channel #4 : \f$ (S_{hh}-S_{vv}).(2*S_{hv})^{*} \f$ - * channel #5 : \f$ (2*S_{hv}).(2*S_{hv})^{*} \f$ + * channel #0 : \f$ (S_{hh}+S_{vv}).(S_{hh}+S_{vv})^{*} \f$ \\ + * channel #1 : \f$ (S_{hh}+S_{vv}).(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #2 : \f$ (S_{hh}+S_{vv}).(2*S_{hv})^{*} \f$ \\ + * channel #3 : \f$ (S_{hh}-S_{vv}).(S_{hh}-S_{vv})^{*} \f$ \\ + * channel #4 : \f$ (S_{hh}-S_{vv}).(2*S_{hv})^{*} \f$ \\ + * channel #5 : \f$ (2*S_{hv}).(2*S_{hv})^{*} \f$ \\ * * This is a adaptation of the SinclairToCoherencyFunctor, where \f$ S_{hv}=S_{vh} \f$. * + * The output pixel has 6 channels : the diagonal and the upper element of the reciprocal matrix. + * Element are stored from left to right, line by line. + * * \ingroup Functor * \ingroup SARPolarimetry * diff --git a/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceMatrixFunctor.h b/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceMatrixFunctor.h index ad7036a56519a56e990c2120bbaf093fc46cee30..1e7e85373229991db22469ec14967502550f8ede 100644 --- a/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceMatrixFunctor.h +++ b/Code/SARPolarimetry/otbSinclairToReciprocalCovarianceMatrixFunctor.h @@ -29,15 +29,18 @@ namespace Functor * with Sinclair matrix information. * * Output value are: - * channel #0 : \f$ S_{hh}.S_{hh}^{*} \f$ - * channel #1 : \f$ S_{hh}.S_{hv}^{*} \f$ - * channel #2 : \f$ S_{hh}.S_{vv}^{*} \f$ - * channel #3 : \f$ S_{hv}.S_{hv}^{*} \f$ - * channel #4 : \f$ S_{hv}.S_{vv}^{*} \f$ - * channel #5 : \f$ S_{vv}.S_{vv}^{*} \f$ + * channel #0 : \f$ S_{hh}.S_{hh}^{*} \f$ \\ + * channel #1 : \f$ S_{hh}.S_{hv}^{*} \f$ \\ + * channel #2 : \f$ S_{hh}.S_{vv}^{*} \f$ \\ + * channel #3 : \f$ S_{hv}.S_{hv}^{*} \f$ \\ + * channel #4 : \f$ S_{hv}.S_{vv}^{*} \f$ \\ + * channel #5 : \f$ S_{vv}.S_{vv}^{*} \f$ \\ * * This is a adaptation of the SinclairToCovarianceMatrixFunctor, where \f$ S_{hv}=S_{vh} \f$. * + * The output pixel has 6 channels : the diagonal and the upper element of the reciprocal matrix. + * Element are stored from left to right, line by line. + * * \ingroup Functor * \ingroup SARPolarimetry * diff --git a/Code/Visualization/otbDragFullWindowActionHandler.h b/Code/Visualization/otbDragFullWindowActionHandler.h index bbdff05ca49e967046b59ad90650894e8b3bdf5d..b52896b6bfca8c909b563a72fa944febe149da78 100644 --- a/Code/Visualization/otbDragFullWindowActionHandler.h +++ b/Code/Visualization/otbDragFullWindowActionHandler.h @@ -36,7 +36,7 @@ class ITK_EXPORT DragFullWindowActionHandler { public: /** Standard class typedefs */ - typedef DragFullWindowActionHandler Self; + typedef DragFullWindowActionHandler Self; typedef ImageWidgetActionHandler Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -95,8 +95,8 @@ public: indexEnd[0] = indexBegin[0] + m_Model->GetExtractRegion().GetSize()[0]; indexEnd[1] = indexBegin[1] + m_Model->GetExtractRegion().GetSize()[1]; - if (indexEnd[0] < m_Model->GetLayer(0)->GetExtent().GetSize()[0] && indexEnd[1] - < m_Model->GetLayer(0)->GetExtent().GetSize()[1] && indexBegin[0] + if (indexEnd[0] < static_cast<unsigned int> (m_Model->GetLayer(0)->GetExtent().GetSize()[0]) && indexEnd[1] + < static_cast<unsigned int> (m_Model->GetLayer(0)->GetExtent().GetSize()[1]) && indexBegin[0] > static_cast<unsigned int> (m_Model->GetLayer(0)->GetExtent().GetIndex()[0]) && indexBegin[1] > static_cast<unsigned int> (m_Model->GetLayer(0)->GetExtent().GetIndex()[1])) { diff --git a/Code/Visualization/otbStandardRenderingFunction.h b/Code/Visualization/otbStandardRenderingFunction.h index ce279b01c274e165b18705d56f8b38f5256b65f9..ae5dafa3ee0aa5aac6b6a0f61586291189027ec4 100644 --- a/Code/Visualization/otbStandardRenderingFunction.h +++ b/Code/Visualization/otbStandardRenderingFunction.h @@ -281,7 +281,8 @@ public: for (unsigned int i = 0; i < channels.size(); ++i) { - oss << channels[i] << " "; + //Describe the channel selection (numbering starts with 1) + oss << channels[i] + 1 << " "; } oss << std::endl; diff --git a/Code/Visualization/otbVectorDataModel.cxx b/Code/Visualization/otbVectorDataModel.cxx index e93a6ad4711f62307fe6455b3f5f9ca34357633f..010d1e1820559260ef8f3f8581037dd1560c075c 100644 --- a/Code/Visualization/otbVectorDataModel.cxx +++ b/Code/Visualization/otbVectorDataModel.cxx @@ -134,7 +134,9 @@ void VectorDataModel::EndGeometry(bool callUpdate) itkExceptionMacro(<< "Polygon must have at least 3 points"); } otbMsgDevMacro(<< "VectorDataModel::EndGeometry: Ending polygon and adding to vector data"); - + VertexListConstIteratorType it = m_CurrentGeometry->GetPolygonExteriorRing()->GetVertexList()->Begin(); + VertexType firstVertex = it.Value(); + m_CurrentGeometry->GetPolygonExteriorRing()->AddVertex(firstVertex); m_CurrentGeometry = NULL; } else if (m_CurrentGeometry->GetNodeType() == FEATURE_LINE) diff --git a/Code/Visualization/otbVectorDataModel.h b/Code/Visualization/otbVectorDataModel.h index 062c092236a324539da074f982253d50cac1cb72..e0829d01d3f44540fe7a1c7ea4c1d827e17676e6 100644 --- a/Code/Visualization/otbVectorDataModel.h +++ b/Code/Visualization/otbVectorDataModel.h @@ -55,6 +55,8 @@ public: typedef VectorDataType::PolygonType PolygonType; typedef VectorDataType::LineType LineType; typedef PolygonType::VertexType VertexType; + typedef PolygonType::VertexListConstIteratorType + VertexListConstIteratorType; /** Runtime information */ itkTypeMacro(VectorDataModel, Object); diff --git a/Examples/IO/TileMapImageIOExample.cxx b/Examples/IO/TileMapImageIOExample.cxx index e8d2cc11bd908d46c5b4e8cf2f2dd03c1d1c35bf..a0d9381b0ee38bb14cb0afd3a5776e2cbd4a54ca 100644 --- a/Examples/IO/TileMapImageIOExample.cxx +++ b/Examples/IO/TileMapImageIOExample.cxx @@ -59,7 +59,7 @@ #include "otbForwardSensorModel.h" #include "otbExtractROI.h" #include "otbImageFileWriter.h" -#include "ossim/projection/ossimTileMapModel.h" +#include "ossimTileMapModel.h" #include "otbWorldFile.h" // Software Guide : EndCodeSnippet @@ -141,7 +141,7 @@ int main(int argc, char* argv[]) ModelType::Pointer model = ModelType::New(); model->SetImageGeometry(readerTile->GetOutput()->GetImageKeywordlist()); - dynamic_cast<ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth); + dynamic_cast<ossimplugins::ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth); if (!model) { std::cerr << "Unable to create a model" << std::endl; @@ -214,7 +214,7 @@ int main(int argc, char* argv[]) ForwardModelType::Pointer modelForward = ForwardModelType::New(); modelForward->SetImageGeometry(readerTile->GetOutput()->GetImageKeywordlist()); - dynamic_cast<ossimTileMapModel*>(modelForward->GetOssimModel())->setDepth( + dynamic_cast<ossimplugins::ossimTileMapModel*>(modelForward->GetOssimModel())->setDepth( depth); if (!modelForward) { diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 8ee553134ec91f613205f6214e4137abb96cdcc3..a731d4b1ea90a018676a32489212988fddf3a09a 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -304,6 +304,22 @@ ADD_TEST(bfTVectorRescaleIntensityImageFilter ${BASICFILTERS_TESTS3} 0 255 ) +# ------- otb::ShiftScaleVectorImageFilter ---------------------------- + +ADD_TEST(bfTuShiftScaleVectorImageFilterNew ${BASICFILTERS_TESTS3} + otbShiftScaleVectorImageFilterNew) + + +ADD_TEST(bfTvShiftScaleVectorImageFilter ${BASICFILTERS_TESTS3} + --compare-image ${EPSILON_7} + ${BASELINE}/bfTvShiftScaleVImageOutput.tif + ${TEMP}/bfTvShiftScaleVImageOutput.tif + otbShiftScaleVectorImageFilterTest + ${INPUTDATA}/qb_RoadExtract.img.hdr + ${TEMP}/bfTvShiftScaleVImageOutput.tif +) + + # ------- otb::VectorImageToImageListFilter ---------------------------- ADD_TEST(bfTuVectorImageToImageListFilterNew ${BASICFILTERS_TESTS3} @@ -1883,6 +1899,8 @@ otbVectorImageToImageListFilter.cxx otbImageListToVectorImageFilterNew.cxx otbImageListToVectorImageFilter.cxx otbImageListToVectorImageFilter2.cxx +otbShiftScaleVectorImageFilterNew.cxx +otbShiftScaleVectorImageFilterTest.cxx ) # A enrichir diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests3.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests3.cxx index f89241bc82e8e5c14c482794196155c4ea89e103..6499ed9549698792351be6b2c770b2a16ad2dfd7 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests3.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests3.cxx @@ -38,4 +38,6 @@ void RegisterTests() REGISTER_TEST(otbImageListToVectorImageFilterNew); REGISTER_TEST(otbImageListToVectorImageFilter); REGISTER_TEST(otbImageListToVectorImageFilter2); + REGISTER_TEST(otbShiftScaleVectorImageFilterNew); + REGISTER_TEST(otbShiftScaleVectorImageFilterTest); } diff --git a/Testing/Code/BasicFilters/otbShiftScaleVectorImageFilterNew.cxx b/Testing/Code/BasicFilters/otbShiftScaleVectorImageFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c49d63e2897107efec28034805e4eeb0bd8e0d17 --- /dev/null +++ b/Testing/Code/BasicFilters/otbShiftScaleVectorImageFilterNew.cxx @@ -0,0 +1,38 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#include "itkExceptionObject.h" + +#include "otbShiftScaleVectorImageFilter.h" +#include "otbVectorImage.h" + +int otbShiftScaleVectorImageFilterNew(int argc, char * argv[]) +{ + const unsigned int Dimension = 2; + typedef double InputPixelType; + typedef int OutputPixelType; + typedef otb::VectorImage<InputPixelType, Dimension> InputImageType; + typedef otb::VectorImage<OutputPixelType, Dimension> OutputImageType; + typedef otb::ShiftScaleVectorImageFilter<InputImageType, OutputImageType> ShiftScaleVImageFilterType; + + // Instantiating object + ShiftScaleVImageFilterType::Pointer filter = ShiftScaleVImageFilterType::New(); + + std::cout << filter << std::endl; + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/BasicFilters/otbShiftScaleVectorImageFilterTest.cxx b/Testing/Code/BasicFilters/otbShiftScaleVectorImageFilterTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..33e44198e93c522b24d7c24879db7058f6f25201 --- /dev/null +++ b/Testing/Code/BasicFilters/otbShiftScaleVectorImageFilterTest.cxx @@ -0,0 +1,112 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#include "itkExceptionObject.h" + +#include "otbShiftScaleVectorImageFilter.h" +#include "otbImage.h" +#include "otbVectorImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbImageList.h" +#include "otbVectorImageToImageListFilter.h" +#include "otbStreamingStatisticsImageFilter.h" + +int otbShiftScaleVectorImageFilterTest(int argc, char * argv[]) +{ + const char * infname = argv[1]; + const char * outfname = argv[2]; + + const unsigned int Dimension = 2; + typedef double InputPixelType; + typedef float OutputPixelType; + typedef otb::VectorImage<InputPixelType, Dimension> InputImageType; + typedef otb::VectorImage<OutputPixelType, Dimension> OutputImageType; + typedef otb::Image<InputPixelType, 2> ImageType; + typedef otb::ImageList<ImageType> ImageListType; + typedef otb::VectorImageToImageListFilter<InputImageType, ImageListType> VI2ILFilterType; + //Statistics estimator + typedef otb::StreamingStatisticsImageFilter<ImageType> StreamingStatisticsImageFilterType; + + typedef otb::ShiftScaleVectorImageFilter<InputImageType, OutputImageType> ShiftScaleVImageFilterType; + + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + + typedef itk::VariableLengthVector<InputPixelType> MeasurementType; + + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(infname); + reader->GenerateOutputInformation(); + + // Instantiating object + ShiftScaleVImageFilterType::Pointer filter = ShiftScaleVImageFilterType::New(); + filter->SetInput(reader->GetOutput()); + + // Build a Measurement Vector of mean + MeasurementType mean; + + // Build a MeasurementVector of variance + MeasurementType variance; + + int nbBands = reader->GetOutput()->GetNumberOfComponentsPerPixel(); + + ImageType::SizeType size; + size = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); + + //set the measurement vectors size + mean.SetSize(nbBands); + mean.Fill(0.); + variance.SetSize(nbBands); + variance.Fill(0.); + + //Splitting image into channels + VI2ILFilterType::Pointer vi2ilFilter = VI2ILFilterType::New(); + vi2ilFilter->SetInput(reader->GetOutput()); + vi2ilFilter->GenerateOutputInformation(); + + ImageListType::Iterator ilIt = vi2ilFilter->GetOutput()->Begin(); + + unsigned int i = 0; + //Iterate over each bands on the input vector image + while (ilIt != vi2ilFilter->GetOutput()->End()) + { + StreamingStatisticsImageFilterType::Pointer statsEstimator = StreamingStatisticsImageFilterType::New(); + statsEstimator->SetInput(ilIt.Get()); + statsEstimator->Update(); + + //Compute mean over band number i + mean[i] = statsEstimator->GetMean(); + //Compute variance over band i + variance[i] = statsEstimator->GetVariance(); + ++ilIt; + ++i; + } + + std::cout<< "mean: " << mean << std::endl; + std::cout<< "variance: " << variance << std::endl; + + filter->SetScale(variance); + filter->SetShift(mean); + + WriterType::Pointer writer = WriterType::New(); + writer->SetInput(filter->GetOutput()); + writer->SetFileName(outfname); + writer->Update(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/Fuzzy/CMakeLists.txt b/Testing/Code/Fuzzy/CMakeLists.txt index cdd21b05b44ecfb9e4ba2ebfa2621c5164b27bfe..0f0cbddc9a70914d028269a61383e815e62a4c9a 100644 --- a/Testing/Code/Fuzzy/CMakeLists.txt +++ b/Testing/Code/Fuzzy/CMakeLists.txt @@ -45,8 +45,37 @@ ADD_TEST(fzTvJointMassOfBeliefFilter ${Fuzzy_TESTS1} ADD_TEST(fzTvFuzzyVariableDSApplied ${Fuzzy_TESTS2} otbFuzzyVariableDSApplied) -ADD_TEST(fzTvMassOfBeliefDSApplied ${Fuzzy_TESTS2} - otbMassOfBeliefDSApplied) +ADD_TEST(fzTvMassOfBeliefDSApplied-H1H2 ${Fuzzy_TESTS2} + otbMassOfBeliefDSApplied + "H1" # describe the hypothesis + "H2" # here the hypothesis is {H1, H2} + 0.9 + 0.9 + ) + +ADD_TEST(fzTvMassOfBeliefDSApplied-H1H2_ ${Fuzzy_TESTS2} + otbMassOfBeliefDSApplied + "H1" + "H2_" # here the hypothesis is {H1, H2_} + 0.9 + 0.9 + ) + +ADD_TEST(fzTvMassOfBeliefDSApplied-H1_H2 ${Fuzzy_TESTS2} + otbMassOfBeliefDSApplied + "H1_" + "H2" # here the hypothesis is {H1_, H2} + 0.9 + 0.9 + ) + +ADD_TEST(fzTvMassOfBeliefDSApplied-H1_H2_ ${Fuzzy_TESTS2} + otbMassOfBeliefDSApplied + "H1_" + "H2_" # here the hypothesis is {H1_, H2_} + 0.9 + 0.9 + ) #ADD_TEST(fzTuVectorDataToSpecificDescriptionFilterBaseNew ${Fuzzy_TESTS2} # otbVectorDataToSpecificDescriptionFilterBaseNew) diff --git a/Testing/Code/Fuzzy/otbMassOfBeliefDSApplied.cxx b/Testing/Code/Fuzzy/otbMassOfBeliefDSApplied.cxx index 01e613b4ecd2f1693b34d58fe17fee41b60b608f..6e4ed2620c4f399490dda6347d8469f5a949ac3e 100644 --- a/Testing/Code/Fuzzy/otbMassOfBeliefDSApplied.cxx +++ b/Testing/Code/Fuzzy/otbMassOfBeliefDSApplied.cxx @@ -26,14 +26,19 @@ int otbMassOfBeliefDSApplied(int argc, char* argv[]) { + const char * hyp_1 = argv[1]; + const char * hyp_2 = argv[2]; + double desc1Val = atof(argv[3]); + double desc2Val = atof(argv[4]); + typedef float PrecisionType; - typedef otb::FuzzyVariable<std::string, - PrecisionType> FuzzyVarType; - + typedef otb::FuzzyVariable<std::string, PrecisionType> + FuzzyVarType; typedef otb::MassOfBelief<std::string> MassOfBeliefFunctionType; + typedef otb::JointMassOfBeliefFilter<MassOfBeliefFunctionType> + JointMassOfBeliefFilterType; - typedef otb::JointMassOfBeliefFilter<MassOfBeliefFunctionType> JointMassOfBeliefFilterType; - + // Descriptors and associated fuzzy variables FuzzyVarType::Pointer desc1 = FuzzyVarType::New(); FuzzyVarType::Pointer desc2 = FuzzyVarType::New(); @@ -43,22 +48,23 @@ int otbMassOfBeliefDSApplied(int argc, char* argv[]) desc2->SetMembership("H2", 0, 0, 0.58, 0.68, 0, 0.99); desc2->SetMembership("H2_", 0.68, 0.98, 1.0, 1.0, 0, 0.99); - PrecisionType desc1Val = 0.9; - PrecisionType desc2Val = 0.9; - + // Corresponding masses MassOfBeliefFunctionType::Pointer mass1 = MassOfBeliefFunctionType::New(); MassOfBeliefFunctionType::Pointer mass2 = MassOfBeliefFunctionType::New(); MassOfBeliefFunctionType::Pointer jointMass = MassOfBeliefFunctionType::New(); MassOfBeliefFunctionType::LabelSetType H1, H1_, H2, H2_, universe, Hyp; + // Defining universe universe.insert("H1"); universe.insert("H1_"); universe.insert("H2"); universe.insert("H2_"); - - Hyp.insert("H1"); - Hyp.insert("H2_"); + // Studied hypothesis + Hyp.insert(hyp_1); + Hyp.insert(hyp_2); + + // Initialize masses mass1->InitializePowerSetMasses(universe); mass2->InitializePowerSetMasses(universe); @@ -82,22 +88,11 @@ int otbMassOfBeliefDSApplied(int argc, char* argv[]) jointMass = jointMassFilter->GetOutput(); std::cout<<mass1<<std::endl; - std::cout << "[" - << desc1->GetMembership("H1", desc1Val) - << "," - << desc1->GetMembership("H1_", desc1Val) - << "]" - << std::endl; - + std::cout<<mass2<<std::endl; - std::cout << "[" - << desc2->GetMembership("H2", desc2Val) - << "," - << desc2->GetMembership("H2_", desc2Val) - << "]" - << std::endl; - + std::cout << jointMass << std::endl; + std::cout << "Considered Hypothesis : " << Hyp << std::endl; std::cout << "Belief(Hyp) : " << jointMass->GetBelief(Hyp) << " - Plausibility(Hyp) : " @@ -105,8 +100,14 @@ int otbMassOfBeliefDSApplied(int argc, char* argv[]) << " - Score(Hyp) : " << (jointMass->GetBelief(Hyp) + jointMass->GetPlausibility(Hyp))/2.0 << std::endl; - - return EXIT_SUCCESS; + + if (jointMass->GetBelief(Hyp) > jointMass->GetPlausibility(Hyp)) + { + std::cout << "Belief > Plausibility" << std::endl; + return EXIT_FAILURE; + } + else + { + return EXIT_SUCCESS; + } } - - diff --git a/Testing/Code/IO/otbTileMapImageIOTest.cxx b/Testing/Code/IO/otbTileMapImageIOTest.cxx index b6fc7944c45899439b2bc05869d631cfc04c7b4d..c7221828ae3978d097a57d8a5fb0088a5713b342 100644 --- a/Testing/Code/IO/otbTileMapImageIOTest.cxx +++ b/Testing/Code/IO/otbTileMapImageIOTest.cxx @@ -26,7 +26,7 @@ #include "otbInverseSensorModel.h" #include "otbExtractROI.h" #include "otbImageFileWriter.h" -#include "ossim/projection/ossimTileMapModel.h" +#include "ossimTileMapModel.h" int otbTileMapImageIOTest(int argc, char* argv[]) { @@ -64,7 +64,7 @@ int otbTileMapImageIOTest(int argc, char* argv[]) ModelType::Pointer model = ModelType::New(); model->SetImageGeometry(readerTile->GetOutput()->GetImageKeywordlist()); - dynamic_cast<ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth); + dynamic_cast<ossimplugins::ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth); if (!model) { std::cerr << "Unable to create a model" << std::endl; diff --git a/Testing/Code/SARPolarimetry/CMakeLists.txt b/Testing/Code/SARPolarimetry/CMakeLists.txt index c291daf45d2e66c98f55facf982901265abd93a8..31180060810d755a4c5fe37facc6769126acd473 100644 --- a/Testing/Code/SARPolarimetry/CMakeLists.txt +++ b/Testing/Code/SARPolarimetry/CMakeLists.txt @@ -280,10 +280,7 @@ ADD_TEST(saTvReciprocalCovarianceToCoherencyDegreeImageFilter ${SARPOLARIMETRY_T --compare-image ${EPSILON_12} ${BASELINE}/saTvMLCToCoherencyDegreeImageFilter.tif ${TEMP}/saTvMLCToCoherencyDegreeImageFilter.tif otbReciprocalCovarianceToCoherencyDegreeImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif ${TEMP}/saTvMLCToCoherencyDegreeImageFilter.tif ) @@ -296,10 +293,7 @@ ADD_TEST(saTvReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter --compare-image ${EPSILON_12} ${BASELINE}/saTvMLCToCircularCoherencyDegreeImageFilter.tif ${TEMP}/saTvMLCToCircularCoherencyDegreeImageFilter.tif otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif ${TEMP}/saTvMLCToCircularCoherencyDegreeImageFilter.tif ) @@ -312,10 +306,7 @@ ADD_TEST(saTvReciprocalHAlphaImageFilter ${SARPOLARIMETRY_TESTS2} --compare-image ${EPSILON_12} ${BASELINE}/saTvReciprocalHAlphaImageFilter.tif ${TEMP}/saTvReciprocalHAlphaImageFilter.tif otbReciprocalHAlphaImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCoherency.tif ${TEMP}/saTvReciprocalHAlphaImageFilter.tif ) @@ -328,10 +319,7 @@ ADD_TEST(saTvReciprocalCoherencyToMuellerImageFilter ${SARPOLARIMETRY_TESTS2} --compare-image ${EPSILON_12} ${BASELINE}/saTvReciprocalCoherencyToMuellerImageFilter.tif ${TEMP}/saTvReciprocalCoherencyToMuellerImageFilter.tif otbReciprocalCoherencyToMuellerImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCoherency.tif ${TEMP}/saTvReciprocalCoherencyToMuellerImageFilter.tif ) @@ -362,14 +350,14 @@ ADD_TEST(saTvMuellerToPolarisationDegreeAndPowerImageFilter ${SARPOLARIMETRY_TES ) # Mueller To Covariance Image Filter -ADD_TEST(saTuMuellerToCovarianceImageFilterNew ${SARPOLARIMETRY_TESTS2} - otbMuellerToCovarianceImageFilterNew +ADD_TEST(saTuMuellerToReciprocalCovarianceImageFilterNew ${SARPOLARIMETRY_TESTS2} + otbMuellerToReciprocalCovarianceImageFilterNew ) -ADD_TEST(saTvMuellerToCovarianceImageFilter ${SARPOLARIMETRY_TESTS2} +ADD_TEST(saTvMuellerToReciprocalCovarianceImageFilter ${SARPOLARIMETRY_TESTS2} --compare-image ${EPSILON_12} ${BASELINE}/saTvMuellerToMLCImageFilter.tif ${TEMP}/saTvMuellerToMLCImageFilter.tif - otbMuellerToCovarianceImageFilter + otbMuellerToReciprocalCovarianceImageFilter ${BASELINE}/saTvSinclairImageFilter_SinclairToMueller.tif ${TEMP}/saTvMuellerToMLCImageFilter.tif ) @@ -424,8 +412,8 @@ otbMuellerToCircularPolarisationImageFilterNew.cxx otbMuellerToCircularPolarisationImageFilter.cxx otbMuellerToPolarisationDegreeAndPowerImageFilterNew.cxx otbMuellerToPolarisationDegreeAndPowerImageFilter.cxx -otbMuellerToCovarianceImageFilterNew.cxx -otbMuellerToCovarianceImageFilter.cxx +otbMuellerToReciprocalCovarianceImageFilterNew.cxx +otbMuellerToReciprocalCovarianceImageFilter.cxx otbPolarimetricData.cxx ) diff --git a/Testing/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.cxx b/Testing/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilter.cxx similarity index 74% rename from Testing/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.cxx rename to Testing/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilter.cxx index 2eede1bb4e1304a63da4b9df2fa7ada8e2a11def..02d3ff7e5e6621830bf973a2b241515bcd0d2900 100644 --- a/Testing/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilter.cxx @@ -24,11 +24,10 @@ #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "otbMuellerToCovarianceImageFilter.h" -#include "otbComplexToVectorImageCastFilter.h" +#include "otbMuellerToReciprocalCovarianceImageFilter.h" #include "otbExtractROI.h" -int otbMuellerToCovarianceImageFilter(int argc, char * argv[]) +int otbMuellerToReciprocalCovarianceImageFilter(int argc, char * argv[]) { const char * inputFilename = argv[1]; const char * outputFilename = argv[2]; @@ -38,11 +37,10 @@ int otbMuellerToCovarianceImageFilter(int argc, char * argv[]) typedef otb::VectorImage<PixelType> RealImageType; typedef otb::VectorImage<ComplexPixelType> ComplexImageType; - typedef otb::MuellerToCovarianceImageFilter<RealImageType, ComplexImageType> FilterType; - typedef otb::ComplexToVectorImageCastFilter<ComplexImageType, RealImageType> Castertype; + typedef otb::MuellerToReciprocalCovarianceImageFilter<RealImageType, ComplexImageType> FilterType; typedef otb::ImageFileReader<RealImageType> ReaderType; - typedef otb::ImageFileWriter<RealImageType> WriterType; + typedef otb::ImageFileWriter<ComplexImageType> WriterType; ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); @@ -52,11 +50,8 @@ int otbMuellerToCovarianceImageFilter(int argc, char * argv[]) FilterType::Pointer filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - Castertype::Pointer caster = Castertype::New(); - caster->SetInput(filter->GetOutput()); - writer->SetFileName(outputFilename); - writer->SetInput(caster->GetOutput()); + writer->SetInput(filter->GetOutput()); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbMuellerToCovarianceImageFilterNew.cxx b/Testing/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilterNew.cxx similarity index 82% rename from Testing/Code/SARPolarimetry/otbMuellerToCovarianceImageFilterNew.cxx rename to Testing/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilterNew.cxx index 995acd55b623f9242efc7c0b411276c20b52c4a8..56285eb316cb8976eb77f8d6fc55a1860cbc4f86 100644 --- a/Testing/Code/SARPolarimetry/otbMuellerToCovarianceImageFilterNew.cxx +++ b/Testing/Code/SARPolarimetry/otbMuellerToReciprocalCovarianceImageFilterNew.cxx @@ -23,9 +23,9 @@ #include <iostream> #include "otbVectorImage.h" -#include "otbMuellerToCovarianceImageFilter.h" +#include "otbMuellerToReciprocalCovarianceImageFilter.h" -int otbMuellerToCovarianceImageFilterNew(int argc, char * argv[]) +int otbMuellerToReciprocalCovarianceImageFilterNew(int argc, char * argv[]) { const unsigned int Dimension = 2; @@ -34,7 +34,7 @@ int otbMuellerToCovarianceImageFilterNew(int argc, char * argv[]) typedef otb::VectorImage<PixelType, Dimension> ImageType; typedef otb::VectorImage<ComplexPixelType, Dimension> ComplexImageType; - typedef otb::MuellerToCovarianceImageFilter<ImageType, ComplexImageType> FilterType; + typedef otb::MuellerToReciprocalCovarianceImageFilter<ImageType, ComplexImageType> FilterType; FilterType::Pointer filter = FilterType::New(); diff --git a/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx index 470766ddda6d0efa2ba48fed50c4cb9a1dd4e8e6..dc20a0fa8a650156a0c2838abe874de69fda04c3 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx @@ -26,62 +26,33 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalCoherencyToMuellerImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" int otbReciprocalCoherencyToMuellerImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - - typedef otb::Image<InputPixelType, Dimension> InputImageType; + typedef otb::VectorImage<InputPixelType, Dimension> ImageType; typedef otb::VectorImage<PixelType, Dimension> RealImageType; - typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCoherencyFilterType; - typedef otb::ReciprocalCoherencyToMuellerImageFilter<ImageType, RealImageType> FilterType; + typedef otb::ReciprocalCoherencyToMuellerImageFilter<ImageType, RealImageType> FilterType; - typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileWriter<RealImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCoherencyFilterType::Pointer sinclairToCoherencyFilter - = SinclairToCoherencyFilterType::New(); - sinclairToCoherencyFilter->SetInputHH(reader1->GetOutput()); - sinclairToCoherencyFilter->SetInputHV(reader2->GetOutput()); - sinclairToCoherencyFilter->SetInputVH(reader3->GetOutput()); - sinclairToCoherencyFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(sinclairToCoherencyFilter->GetOutput()); + filter->SetInput(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx index 711447f3f7f1fa35ca397930d553a6d4c90a370b..efb2b54a0b53c74be0981f577c48a67db9a1ed27 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx @@ -26,61 +26,30 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalCovarianceToCoherencyDegreeImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" int otbReciprocalCovarianceToCoherencyDegreeImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - - typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<InputPixelType, Dimension> ImageType; - typedef otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCovarianceFilterType; typedef otb::ReciprocalCovarianceToCoherencyDegreeImageFilter<ImageType, ImageType> FilterType; - - typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileWriter<ImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCovarianceFilterType::Pointer sinclairToCovarianceFilter - = SinclairToCovarianceFilterType::New(); - sinclairToCovarianceFilter->SetInputHH(reader1->GetOutput()); - sinclairToCovarianceFilter->SetInputHV(reader2->GetOutput()); - sinclairToCovarianceFilter->SetInputVH(reader3->GetOutput()); - sinclairToCovarianceFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(sinclairToCovarianceFilter->GetOutput()); + filter->SetInput(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx index 4f72e660613f624f60c43b2f83dc665d50c1246a..b18dae2c436f12a9a15294eab736831f873b1925 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx @@ -25,7 +25,7 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h" -#include "otbComplexToVectorImageCastFilter.h" + int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int argc, char * argv[]) { @@ -40,13 +40,10 @@ int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int argc, char * arg typedef otb::ReciprocalCovarianceToReciprocalCoherencyImageFilter<ImageType, ImageType> FilterType; - typedef otb::ImageFileReader<ImageType> ReaderType; - typedef otb::ImageFileWriter<RealImageType> WriterType; - typedef otb::ComplexToVectorImageCastFilter<ImageType, RealImageType> CasterType; + typedef otb::ImageFileWriter<ImageType> WriterType; ReaderType::Pointer reader = ReaderType::New(); - CasterType::Pointer caster = CasterType::New(); WriterType::Pointer writer = WriterType::New(); reader->SetFileName(inputFilename); @@ -54,10 +51,8 @@ int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int argc, char * arg FilterType::Pointer filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - caster->SetInput(filter->GetOutput()); - writer->SetFileName(outputFilename); - writer->SetInput(caster->GetOutput()); + writer->SetInput(filter->GetOutput()); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx index 79c312c5cbeaf8059a450909ebb6e24aa2c14a17..0b1e45502a21eceeb88daccbc1bca397cc51eba1 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx @@ -26,85 +26,35 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalHAlphaImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" -#include "itkMeanImageFilter.h" -#include "otbPerBandVectorImageFilter.h" -#include "otbMultiChannelExtractROI.h" int otbReciprocalHAlphaImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<InputPixelType, Dimension> ImageType; typedef otb::VectorImage<PixelType, Dimension> RealImageType; - typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCoherencyFilterType; - - typedef itk::MeanImageFilter<InputImageType, InputImageType> MeanFilterType; - typedef otb::PerBandVectorImageFilter<ImageType, ImageType, - MeanFilterType> PerBandMeanFilterType; - + typedef otb::ReciprocalHAlphaImageFilter<ImageType, RealImageType> FilterType; - typedef otb::MultiChannelExtractROI<PixelType, PixelType> ExtractType; - typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileWriter<RealImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCoherencyFilterType::Pointer sinclairToCoherencyFilter - = SinclairToCoherencyFilterType::New(); - sinclairToCoherencyFilter->SetInputHH(reader1->GetOutput()); - sinclairToCoherencyFilter->SetInputHV(reader2->GetOutput()); - sinclairToCoherencyFilter->SetInputVH(reader3->GetOutput()); - sinclairToCoherencyFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); - PerBandMeanFilterType::Pointer perBandMeanFilter = PerBandMeanFilterType::New(); - perBandMeanFilter->SetInput(sinclairToCoherencyFilter->GetOutput()); - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(perBandMeanFilter->GetOutput()); - filter->SetNumberOfThreads(1); - - ExtractType::Pointer extract = ExtractType::New(); - extract->SetInput(filter->GetOutput()); - extract->SetStartX(10); - extract->SetStartY(10); - extract->SetSizeX(30); - extract->SetSizeY(30); + filter->SetInput(reader->GetOutput()); writer->SetFileName(outputFilename); - writer->SetInput(extract->GetOutput()); - writer->SetNumberOfThreads(1); -writer->SetNumberOfStreamDivisions(1); + writer->SetInput(filter->GetOutput()); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx index 6aa021331e5db71232d5dfec706f8393fd63b8d6..bbea66e5b19ba625b2a72fb4608c9899a27c5832 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx @@ -25,69 +25,33 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" -#include "otbComplexToVectorImageCastFilter.h" int otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - - typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<InputPixelType, Dimension> ImageType; - typedef otb::VectorImage<PixelType, Dimension> RealImageType; - typedef otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCovarianceFilterType; typedef otb::ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter<ImageType, ImageType> FilterType; - typedef otb::ComplexToVectorImageCastFilter<ImageType, RealImageType> CasterType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<RealImageType> WriterType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCovarianceFilterType::Pointer sinclairToCovarianceFilter - = SinclairToCovarianceFilterType::New(); - sinclairToCovarianceFilter->SetInputHH(reader1->GetOutput()); - sinclairToCovarianceFilter->SetInputHV(reader2->GetOutput()); - sinclairToCovarianceFilter->SetInputVH(reader3->GetOutput()); - sinclairToCovarianceFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(sinclairToCovarianceFilter->GetOutput()); - - CasterType::Pointer caster = CasterType::New(); - caster->SetInput(filter->GetOutput()); - + filter->SetInput(reader->GetOutput()); + writer->SetFileName(outputFilename); - writer->SetInput(caster->GetOutput()); + writer->SetInput(filter->GetOutput()); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbSARPolarimetryTests2.cxx b/Testing/Code/SARPolarimetry/otbSARPolarimetryTests2.cxx index 97a622061338743fcbf26f51075f6c820ca6d614..ccbcb412928ddecf7a9f817ca34d877772b4ac2c 100644 --- a/Testing/Code/SARPolarimetry/otbSARPolarimetryTests2.cxx +++ b/Testing/Code/SARPolarimetry/otbSARPolarimetryTests2.cxx @@ -40,8 +40,8 @@ void RegisterTests() REGISTER_TEST(otbMuellerToCircularPolarisationImageFilter); REGISTER_TEST(otbMuellerToPolarisationDegreeAndPowerImageFilterNew); REGISTER_TEST(otbMuellerToPolarisationDegreeAndPowerImageFilter); - REGISTER_TEST(otbMuellerToCovarianceImageFilterNew); - REGISTER_TEST(otbMuellerToCovarianceImageFilter); + REGISTER_TEST(otbMuellerToReciprocalCovarianceImageFilterNew); + REGISTER_TEST(otbMuellerToReciprocalCovarianceImageFilter); REGISTER_TEST(otbPolarimetricDataNew); REGISTER_TEST(otbPolarimetricDataTest); } diff --git a/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx b/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx index 084cb651eaa032ddd1b1c70417524eef4c698558..ff719172277f7f812fbfe67c0ffa767300336dac 100644 --- a/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx @@ -32,8 +32,8 @@ #include "otbSinclairToCircularCovarianceMatrixFunctor.h" #include "otbSinclairToCoherencyMatrixFunctor.h" #include "otbSinclairToMuellerMatrixFunctor.h" -#include "otbComplexToVectorImageCastFilter.h" -#include "otbExtractROI.h" +#include "otbMultiChannelExtractROI.h" + int otbSinclairImageFilterNew(int argc, char * argv[]) { @@ -51,49 +51,6 @@ int otbSinclairImageFilterNew(int argc, char * argv[]) } -#define generic_SinclairImageFilterMacro(T_InputPixel, T_OutputPixel, T_Function, _argc, _argv) \ - const char * inputFilename1 = _argv[1]; \ - const char * inputFilename2 = _argv[2]; \ - const char * inputFilename3 = _argv[3]; \ - typedef T_InputPixel InputPixelType; \ - typedef T_OutputPixel OutputPixelType; \ - typedef otb::Image<InputPixelType> InputImageType; \ - typedef otb::VectorImage<OutputPixelType> OutputImageType; \ - typedef otb::ImageFileReader<InputImageType> ReaderType; \ - typedef otb::ExtractROI<InputPixelType, InputPixelType > ExtractROIType; \ - typedef otb::SinclairImageFilter<InputImageType, InputImageType, InputImageType, InputImageType, OutputImageType, T_Function> FilterType; \ - typename FilterType::Pointer filter = FilterType::New(); \ - typename ReaderType::Pointer reader1 = ReaderType::New(); \ - typename ReaderType::Pointer reader2 = ReaderType::New(); \ - typename ReaderType::Pointer reader3 = ReaderType::New(); \ - typename ExtractROIType::Pointer extract1 = ExtractROIType::New(); \ - typename ExtractROIType::Pointer extract2 = ExtractROIType::New(); \ - typename ExtractROIType::Pointer extract3 = ExtractROIType::New(); \ - extract1->SetStartX(10); \ - extract1->SetStartY(10); \ - extract1->SetSizeX(30); \ - extract1->SetSizeY(30); \ - extract2->SetStartX(10); \ - extract2->SetStartY(10); \ - extract2->SetSizeX(30); \ - extract2->SetSizeY(30); \ - extract3->SetStartX(10); \ - extract3->SetStartY(10); \ - extract3->SetSizeX(30); \ - extract3->SetSizeY(30); \ - reader1->SetFileName(inputFilename1); \ - reader2->SetFileName(inputFilename2); \ - reader3->SetFileName(inputFilename3); \ - extract1->SetInput(reader1->GetOutput()); \ - extract2->SetInput(reader3->GetOutput()); \ - extract3->SetInput(reader3->GetOutput()); \ - filter->SetInputHH(extract1->GetOutput()); \ - filter->SetInputHV(extract2->GetOutput()); \ - filter->SetInputVH(extract2->GetOutput()); \ - filter->SetInputVV(extract3->GetOutput()); \ - filter->UpdateOutputInformation(); - - template<class TInputPixel, class TOutputPixel, class TFunction> int generic_SinclairImageFilter(int argc, char * argv[]) { @@ -102,42 +59,46 @@ int generic_SinclairImageFilter(int argc, char * argv[]) typedef otb::VectorImage<TOutputPixel> OutputImageType; typedef otb::ImageFileWriter<OutputImageType> WriterType; - generic_SinclairImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); - - typename WriterType::Pointer writer = WriterType::New(); - writer->SetFileName(outputFilename); - - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - return EXIT_SUCCESS; -} - -template<class TInputPixel, class TOutputPixel, class TFunction> -int generic_SinclairImageFilterWithCast(int argc, char * argv[]) -{ - const char * outputFilename = argv[4]; + const char * inputFilename1 = argv[1]; + const char * inputFilename2 = argv[2]; + const char * inputFilename3 = argv[3]; + typedef otb::Image<TInputPixel> InputImageType; typedef otb::VectorImage<TOutputPixel> OutputImageType; - typedef otb::VectorImage<typename TOutputPixel::value_type> OutputRealImageType; - typedef otb::ImageFileWriter<OutputRealImageType> WriterType; - typedef typename otb::ComplexToVectorImageCastFilter<OutputImageType, OutputRealImageType> CasterType; - - generic_SinclairImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::MultiChannelExtractROI<TOutputPixel, TOutputPixel > ExtractROIType; + typedef otb::SinclairImageFilter<InputImageType, InputImageType, InputImageType, InputImageType, OutputImageType, TFunction> FilterType; + typename FilterType::Pointer filter = FilterType::New(); + typename ReaderType::Pointer reader1 = ReaderType::New(); + typename ReaderType::Pointer reader2 = ReaderType::New(); + typename ReaderType::Pointer reader3 = ReaderType::New(); + + reader1->SetFileName(inputFilename1); + reader2->SetFileName(inputFilename2); + reader3->SetFileName(inputFilename3); + filter->SetInputHH(reader1->GetOutput()); + filter->SetInputHV(reader2->GetOutput()); + filter->SetInputVH(reader2->GetOutput()); + filter->SetInputVV(reader3->GetOutput()); + + filter->UpdateOutputInformation(); + + typename ExtractROIType::Pointer extract = ExtractROIType::New(); + extract->SetStartX(10); + extract->SetStartY(10); + extract->SetSizeX(30); + extract->SetSizeY(30); + extract->SetInput(filter->GetOutput()); typename WriterType::Pointer writer = WriterType::New(); - typename CasterType::Pointer caster = CasterType::New(); - writer->SetFileName(outputFilename); - - caster->SetInput( filter->GetOutput() ); - writer->SetInput( caster->GetOutput() ); + + writer->SetInput( extract->GetOutput() ); writer->Update(); - + return EXIT_SUCCESS; } - int otbSinclairImageFilter(int argc, char * argv[]) { const unsigned int Dimension = 2; @@ -153,7 +114,7 @@ int otbSinclairImageFilter(int argc, char * argv[]) argc--; argv++; if (strArgv == "SinclairToCovarianceMatrix") - return (generic_SinclairImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, @@ -161,7 +122,7 @@ int otbSinclairImageFilter(int argc, char * argv[]) OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToCircularCovarianceMatrix") - return (generic_SinclairImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToCircularCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, @@ -169,7 +130,7 @@ int otbSinclairImageFilter(int argc, char * argv[]) OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToCoherencyMatrix") - return (generic_SinclairImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToCoherencyMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, diff --git a/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx b/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx index 3eefb9a8d5cc86870b4efb36c6ce61a34c765b85..339bffacab87c3a34d58afbd6625f443ba2ebd2b 100644 --- a/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx @@ -31,8 +31,7 @@ #include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" #include "otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h" #include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" -#include "otbComplexToVectorImageCastFilter.h" -#include "otbExtractROI.h" +#include "otbMultiChannelExtractROI.h" int otbSinclairReciprocalImageFilterNew(int argc, char * argv[]) @@ -40,96 +39,58 @@ int otbSinclairReciprocalImageFilterNew(int argc, char * argv[]) typedef std::complex<float> ComplexType; typedef otb::Image<ComplexType, 2> CplxImageType; typedef otb::VectorImage<ComplexType, 2> VCplxImageType; - + typedef otb::SinclairReciprocalImageFilter<CplxImageType, CplxImageType, CplxImageType, VCplxImageType> FilterType; - + // Instantiating object FilterType::Pointer filter = FilterType::New(); - - + + return EXIT_SUCCESS; } -#define generic_SinclairReciprocalImageFilterMacro(T_InputPixel, T_OutputPixel, T_Function, _argc, _argv) \ - const char * inputFilename1 = _argv[1]; \ - const char * inputFilename2 = _argv[2]; \ - const char * inputFilename3 = _argv[3]; \ - typedef T_InputPixel InputPixelType; \ - typedef T_OutputPixel OutputPixelType; \ - typedef otb::Image<InputPixelType> InputImageType; \ - typedef otb::VectorImage<OutputPixelType> OutputImageType; \ - typedef otb::ImageFileReader<InputImageType> ReaderType; \ - typedef otb::ExtractROI<InputPixelType, InputPixelType > ExtractROIType; \ - typedef otb::SinclairReciprocalImageFilter<InputImageType, InputImageType, InputImageType, OutputImageType, T_Function> FilterType; \ - typename FilterType::Pointer filter = FilterType::New(); \ - typename ReaderType::Pointer reader1 = ReaderType::New(); \ - typename ReaderType::Pointer reader2 = ReaderType::New(); \ - typename ReaderType::Pointer reader3 = ReaderType::New(); \ - typename ExtractROIType::Pointer extract1 = ExtractROIType::New(); \ - typename ExtractROIType::Pointer extract2 = ExtractROIType::New(); \ - typename ExtractROIType::Pointer extract3 = ExtractROIType::New(); \ - extract1->SetStartX(10); \ - extract1->SetStartY(10); \ - extract1->SetSizeX(30); \ - extract1->SetSizeY(30); \ - extract2->SetStartX(10); \ - extract2->SetStartY(10); \ - extract2->SetSizeX(30); \ - extract2->SetSizeY(30); \ - extract3->SetStartX(10); \ - extract3->SetStartY(10); \ - extract3->SetSizeX(30); \ - extract3->SetSizeY(30); \ - reader1->SetFileName(inputFilename1); \ - reader2->SetFileName(inputFilename2); \ - reader3->SetFileName(inputFilename3); \ - extract1->SetInput(reader1->GetOutput()); \ - extract2->SetInput(reader3->GetOutput()); \ - extract3->SetInput(reader3->GetOutput()); \ - filter->SetInputHH(extract1->GetOutput()); \ - filter->SetInputHV(extract2->GetOutput()); \ - filter->SetInputVH(extract2->GetOutput()); \ - filter->SetInputVV(extract3->GetOutput()); \ - filter->UpdateOutputInformation(); template<class TInputPixel, class TOutputPixel, class TFunction> int generic_SinclairReciprocalImageFilter(int argc, char * argv[]) { + const char * inputFilename1 = argv[1]; + const char * inputFilename2 = argv[2]; + const char * inputFilename3 = argv[3]; const char * outputFilename = argv[4]; - + + typedef otb::Image<TInputPixel> InputImageType; typedef otb::VectorImage<TOutputPixel> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; typedef otb::ImageFileWriter<OutputImageType> WriterType; - - generic_SinclairReciprocalImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); + + typedef otb::MultiChannelExtractROI<TOutputPixel, TOutputPixel > ExtractROIType; + typedef otb::SinclairReciprocalImageFilter<InputImageType, InputImageType, InputImageType, OutputImageType, TFunction> FilterType; + + typename FilterType::Pointer filter = FilterType::New(); + typename ReaderType::Pointer reader1 = ReaderType::New(); + typename ReaderType::Pointer reader2 = ReaderType::New(); + typename ReaderType::Pointer reader3 = ReaderType::New(); + + reader1->SetFileName(inputFilename1); + reader2->SetFileName(inputFilename2); + reader3->SetFileName(inputFilename3); + + filter->SetInputHH(reader1->GetOutput()); + filter->SetInputHV(reader2->GetOutput()); + filter->SetInputVH(reader2->GetOutput()); + filter->SetInputVV(reader3->GetOutput()); + + typename ExtractROIType::Pointer extract = ExtractROIType::New(); + extract->SetStartX(10); + extract->SetStartY(10); + extract->SetSizeX(30); + extract->SetSizeY(30); + extract->SetInput( filter->GetOutput() ); typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outputFilename); - - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - return EXIT_SUCCESS; -} - -template<class TInputPixel, class TOutputPixel, class TFunction> -int generic_SinclairReciprocalImageFilterWithCast(int argc, char * argv[]) -{ - const char * outputFilename = argv[4]; - - typedef otb::VectorImage<TOutputPixel> OutputImageType; - typedef otb::VectorImage<typename TOutputPixel::value_type> OutputRealImageType; - typedef otb::ImageFileWriter<OutputRealImageType> WriterType; - typedef typename otb::ComplexToVectorImageCastFilter<OutputImageType, OutputRealImageType> CasterType; - - generic_SinclairReciprocalImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); - - typename WriterType::Pointer writer = WriterType::New(); - typename CasterType::Pointer caster = CasterType::New(); - - writer->SetFileName(outputFilename); - caster->SetInput( filter->GetOutput() ); - writer->SetInput( caster->GetOutput() ); + writer->SetInput( extract->GetOutput() ); writer->Update(); return EXIT_SUCCESS; @@ -142,30 +103,30 @@ int otbSinclairReciprocalImageFilter(int argc, char * argv[]) typedef std::complex <double> InputPixelType; typedef std::complex <double> OutputPixelType; typedef double OutputRealPixelType; - + typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<OutputPixelType, Dimension> OutputImageType; typedef otb::VectorImage<OutputRealPixelType, Dimension> OutputRealImageType; - + std::string strArgv(argv[1]); argc--; argv++; if (strArgv == "SinclairToReciprocalCovarianceMatrix") - return (generic_SinclairReciprocalImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairReciprocalImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToReciprocalCircularCovarianceMatrix") - return (generic_SinclairReciprocalImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairReciprocalImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToReciprocalCircularCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToReciprocalCoherencyMatrix") - return (generic_SinclairReciprocalImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairReciprocalImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, diff --git a/Testing/Code/TestSystem/CMakeLists.txt b/Testing/Code/TestSystem/CMakeLists.txt index ecb82abb21812a399b16411abe523ec8dc312230..18992a2a2e684a8fc5859f0c4b50eb1340df8335 100644 --- a/Testing/Code/TestSystem/CMakeLists.txt +++ b/Testing/Code/TestSystem/CMakeLists.txt @@ -21,7 +21,7 @@ SET(EPSILON_3 0.001) SET(TESTSYSTEM_TESTS ${CXX_TEST_PATH}/otbTestSystemTests) #Test if the current working copy corresponds to the nightly revision number -ADD_TEST(tsTuIsNightlyRevision ${TESTSYSTEM_TESTS} +ADD_TEST(tsTvIsNightlyRevision ${TESTSYSTEM_TESTS} otbIsNightlyRevision ${OTB_WC_REVISION} http://www.orfeo-toolbox.org/nightly/libNightlyNumber ) diff --git a/Testing/Code/TestSystem/otbIsNightlyRevision.cxx b/Testing/Code/TestSystem/otbIsNightlyRevision.cxx index 1a3aa2edbf4e9832cd7f2850ae698cdf4737e98c..f69e91400bc30f270ebf355252fcf4649e3b4846 100644 --- a/Testing/Code/TestSystem/otbIsNightlyRevision.cxx +++ b/Testing/Code/TestSystem/otbIsNightlyRevision.cxx @@ -24,6 +24,7 @@ int otbIsNightlyRevision(int argc, char * argv[]) { if (argc != 3) { + std::cerr << argv[0] << " revision_number http_address_of_nightlynumber" << std::endl; return EXIT_FAILURE; } @@ -44,5 +45,4 @@ int otbIsNightlyRevision(int argc, char * argv[]) std::cerr << "Nightly revision is " << nightlyRevision << " but working copy revision is " << wcRevision << std::endl; return EXIT_FAILURE; } - } diff --git a/Testing/Utilities/ossimTileMapModelTest.cxx b/Testing/Utilities/ossimTileMapModelTest.cxx index 86b968272463906e6eeb64c16620fb47e9563e57..f44b3eb2d81512d7a0741a38bc722f7e3f8d20d4 100644 --- a/Testing/Utilities/ossimTileMapModelTest.cxx +++ b/Testing/Utilities/ossimTileMapModelTest.cxx @@ -5,7 +5,7 @@ #include <cstdlib> #include "base/ossimString.h" -#include "projection/ossimTileMapModel.h" +#include "ossimTileMapModel.h" #include <ossim/base/ossimGpt.h> #include <ossim/base/ossimDpt.h> @@ -19,7 +19,7 @@ int ossimTileMapModelTest(int argc, char* argv[]) else { // Ossim containers and tileMapModel - ossimRefPtr<ossimTileMapModel> tileMapModel = new ossimTileMapModel; + ossimRefPtr<ossimplugins::ossimTileMapModel> tileMapModel = new ossimplugins::ossimTileMapModel; ossimGpt gpt; ossimDpt dpt; diff --git a/Utilities/otbossim/include/ossim/projection/ossimSensorModelFactory.h b/Utilities/otbossim/include/ossim/projection/ossimSensorModelFactory.h index 4cef08c566088d37106ac9feff5c06f0df5a7d59..e93dfd6ebb04214f947eee1f2feb93b7ebfe9d1e 100644 --- a/Utilities/otbossim/include/ossim/projection/ossimSensorModelFactory.h +++ b/Utilities/otbossim/include/ossim/projection/ossimSensorModelFactory.h @@ -57,7 +57,6 @@ protected: static ossimSensorModelFactory* theInstance; bool isNitf(const ossimFilename& filename)const; bool isLandsat(const ossimFilename& filename)const; - bool isTileMap(const ossimFilename& filename) const; void findCoarseGrid(ossimFilename& result, const ossimFilename& geomFile)const; }; diff --git a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp index 3fe1abcfa58169e80ff11048870c9240bdc7557f..547b4838c1423d3e09dd68fad1f018025e69ab0e 100644 --- a/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp +++ b/Utilities/otbossim/src/ossim/imaging/ossimImageHandlerFactory.cpp @@ -22,7 +22,6 @@ #include <ossim/imaging/ossimGeneralRasterTileSource.h> #include <ossim/imaging/ossimERSTileSource.h> #include <ossim/imaging/ossimVpfTileSource.h> -#include <ossim/imaging/ossimTileMapTileSource.h> #include <ossim/base/ossimTrace.h> #include <ossim/base/ossimKeywordNames.h> #include <ossim/imaging/ossimJpegTileSource.h> @@ -73,7 +72,7 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName) // for all of our imagehandlers the filename must exist. // if we have any imagehandlers that require an encoded string and is contrlled in this factory then // we need to move this. -// if (!copyFilename.exists()) break; + if (!copyFilename.exists()) break; ossimString ext = copyFilename.ext().downcase(); if(ext == "gz") @@ -171,10 +170,6 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName) result = new ossimCcfTileSource(); if (result->open(copyFilename)) break; - if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying TileMap..."; - result = new ossimTileMapTileSource(); - if (result->open(copyFilename)) break; - result = 0; break; } @@ -273,10 +268,6 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl, result = new ossimQbTileFilesHandler; if (result->loadState(kwl, prefix)) break; - if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying TileMap..."; - result = new ossimTileMapTileSource(); - if (result->loadState(kwl, prefix)) break; - result = 0; break; } @@ -494,10 +485,6 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimString& typeName) { return new ossimQbTileFilesHandler(); } - if(STATIC_TYPE_NAME(ossimTileMapTileSource) == typeName) - { - return new ossimTileMapTileSource(); - } return (ossimObject*)0; } @@ -526,7 +513,6 @@ void ossimImageHandlerFactory::getSupportedExtensions(ossimImageHandlerFactoryBa extensionList.push_back("nitf"); extensionList.push_back("ntf"); extensionList.push_back("til"); - extensionList.push_back("otb"); } void ossimImageHandlerFactory::getImageHandlersBySuffix(ossimImageHandlerFactoryBase::ImageHandlerList& result, const ossimString& ext)const @@ -644,12 +630,6 @@ void ossimImageHandlerFactory::getImageHandlersBySuffix(ossimImageHandlerFactory result.push_back(new ossimQbTileFilesHandler); return; } - if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing OTB..."<<std::endl; - if (testExt == "otb") - { - result.push_back(new ossimTileMapTileSource); - return; - } } void ossimImageHandlerFactory::getImageHandlersByMimeType(ossimImageHandlerFactoryBase::ImageHandlerList& result, const ossimString& mimeType)const @@ -703,10 +683,6 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimKeywordlist& kwl, } } } - if(ossimString(type).trim() == STATIC_TYPE_NAME(ossimTileMapTileSource)) - { - return new ossimTileMapTileSource(); - } if(traceDebug()) { @@ -731,7 +707,6 @@ void ossimImageHandlerFactory::getTypeNameList(std::vector<ossimString>& typeLis typeList.push_back(STATIC_TYPE_NAME(ossimERSTileSource)); typeList.push_back(STATIC_TYPE_NAME(ossimSrtmTileSource)); typeList.push_back(STATIC_TYPE_NAME(ossimGeneralRasterTileSource)); - typeList.push_back(STATIC_TYPE_NAME(ossimTileMapTileSource)); typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdNitfTileSource)); typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdTiffTileSource)); typeList.push_back(STATIC_TYPE_NAME(ossimQbTileFilesHandler)); diff --git a/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp b/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp index cd386ccad458c9cd9fca448126082185dc07bf5c..11362eee52fb2992105fa168b434918e82ddadc4 100644 --- a/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp +++ b/Utilities/otbossim/src/ossim/projection/ossimSensorModelFactory.cpp @@ -50,7 +50,6 @@ static ossimTrace traceDebug = ossimTrace("ossimSensorModelFactory:debug"); #include <ossim/projection/ossimApplanixEcefModel.h> #include <ossim/support_data/ossimFfL7.h> #include <ossim/support_data/ossimFfL5.h> -#include <ossim/projection/ossimTileMapModel.h> //*** // ADD_MODEL: List names of all sensor models produced by this factory: @@ -189,10 +188,6 @@ ossimSensorModelFactory::createProjection(const ossimString &name) const return new ossimSpot5Model; } - if(name==STATIC_TYPE_NAME(ossimTileMapModel)) - { - return new ossimTileMapModel; - } if(name == STATIC_TYPE_NAME(ossimSarModel)) { return new ossimSarModel; @@ -244,7 +239,6 @@ ossimSensorModelFactory::getTypeNameList(std::vector<ossimString>& typeList) typeList.push_back(STATIC_TYPE_NAME(ossimFcsiModel)); typeList.push_back(STATIC_TYPE_NAME(ossimSpot5Model)); typeList.push_back(STATIC_TYPE_NAME(ossimSarModel)); - typeList.push_back(STATIC_TYPE_NAME(ossimTileMapModel)); typeList.push_back(STATIC_TYPE_NAME(ossimBuckeyeSensor)); //*** // ADD_MODEL: Please leave this comment for the next programmer. Add above. @@ -480,24 +474,6 @@ ossimProjection* ossimSensorModelFactory::createProjection( } return model.release(); } - -bool ossimSensorModelFactory::isTileMap(const ossimFilename& filename)const -{ - ossimFilename temp(filename); - temp.downcase(); - - ossimString os = temp.beforePos(4); - - if(temp.ext()=="otb") - { - return true; - } - else if(os == "http") - { - return true; - } - return false; -} bool ossimSensorModelFactory::isNitf(const ossimFilename& filename)const { diff --git a/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp b/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp index 0925bcd3311ea3a343b86766c64b1082b01f91a6..8343f16cb46245542d4ecfd144ffa673569b5989 100644 --- a/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp +++ b/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.cpp @@ -22,6 +22,7 @@ #include "ossimErsSarModel.h" #include "ossimAlosPalsarModel.h" #include <ossim/base/ossimNotifyContext.h> +#include "ossimTileMapModel.h" //*** // Define Trace flags for use within this file: @@ -210,6 +211,27 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimTileMapModel" << std::endl; + } + + if (!projection) + { + ossimRefPtr<ossimTileMapModel> model = new ossimTileMapModel(); + if (model->open(filename)) + { + projection = model.get(); + } + else + { + model = 0; + } + } + + + return projection.release(); } @@ -256,6 +278,10 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( { return new ossimFormosatModel; } + else if (name == STATIC_TYPE_NAME(ossimTileMapModel)) + { + return new ossimTileMapModel; + } if(traceDebug()) { @@ -339,6 +365,15 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( result = 0; } } + else if (type == "ossimTileMapModel") + { + result = new ossimTileMapModel(); + if ( !result->loadState(kwl, prefix) ) + { + result = 0; + } + } + } if(traceDebug()) @@ -373,5 +408,26 @@ void ossimPluginProjectionFactory::getTypeNameList(std::vector<ossimString>& typ typeList.push_back(STATIC_TYPE_NAME(ossimErsSarModel)); typeList.push_back(STATIC_TYPE_NAME(ossimAlosPalsarModel)); typeList.push_back(STATIC_TYPE_NAME(ossimFormosatModel)); + typeList.push_back(STATIC_TYPE_NAME(ossimTileMapModel)); +} + +bool ossimPluginProjectionFactory::isTileMap(const ossimFilename& filename)const +{ + ossimFilename temp(filename); + temp.downcase(); + + ossimString os = temp.beforePos(4); + + if(temp.ext()=="otb") + { + return true; + } + else if(os == "http") + { + return true; + } + return false; } + + } diff --git a/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.h b/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.h index e83240852e461aa0aadf026dd3a4e0cbc91bdbee..ac9aaa27954f208ede2c79c79bd0de95422d415d 100644 --- a/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.h +++ b/Utilities/otbossimplugins/ossim/ossimPluginProjectionFactory.h @@ -52,7 +52,7 @@ public: virtual void getTypeNameList(std::vector<ossimString>& typeList)const; protected: ossimPluginProjectionFactory(){} - + bool isTileMap(const ossimFilename& filename) const; }; } diff --git a/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp b/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp index 9490b360af9d2916c54a0cf029ecd75fcef03806..88718c60837d2a2549a2f7d73533107072fec0b2 100644 --- a/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp +++ b/Utilities/otbossimplugins/ossim/ossimPluginReaderFactory.cpp @@ -20,6 +20,7 @@ #include <ossim/imaging/ossimImageHandler.h> #include <ossim/base/ossimTrace.h> #include <ossim/base/ossimKeywordNames.h> +#include "ossimTileMapTileSource.h" namespace ossimplugins { @@ -129,7 +130,7 @@ ossimImageHandler* ossimPluginReaderFactory::open(const ossimKeywordlist& kwl, << "ossimPluginReaderFactory::open(kwl, prefix) DEBUG: leaving..." << std::endl; } - + return reader.release(); } @@ -145,6 +146,11 @@ ossimObject* ossimPluginReaderFactory::createObject( { result = new ossimTerraSarTiffReader; } + if(typeName == "ossimTileMapTileSource") + { + result = new ossimTileMapTileSource; + } + return result.release(); } @@ -159,12 +165,14 @@ void ossimPluginReaderFactory::getTypeNameList( { typeList.push_back(ossimString("ossimRadarSat2TiffReader")); typeList.push_back(ossimString("ossimTerraSarTiffReader")); + typeList.push_back(ossimString("ossimTileMapTileSource")); } void ossimPluginReaderFactory::getSupportedExtensions( ossimImageHandlerFactoryBase::UniqueStringList& extensionList)const { extensionList.push_back(ossimString("xml")); + extensionList.push_back("otb"); } ossimPluginReaderFactory::ossimPluginReaderFactory(){} diff --git a/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp b/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp index 0b2cdaebc3bfb3e2a40dd60b5ad36d0f42948c49..7f64dba009e99c8d10c5252d76c25fc069e9823b 100644 --- a/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp +++ b/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp @@ -46,6 +46,7 @@ RTTI_DEF1(ossimRadarSatModel, "ossimRadarSatModel", ossimGeometricSarSensorModel static ossimTrace traceDebug("ossimRadarSatModel:debug"); ossimRadarSatModel::ossimRadarSatModel(): + ossimGeometricSarSensorModel(), _n_srgr(0), _pixel_spacing(0), _data(NULL), @@ -55,6 +56,17 @@ ossimRadarSatModel::ossimRadarSatModel(): { } +ossimRadarSatModel::ossimRadarSatModel(const ossimRadarSatModel& rhs): + ossimGeometricSarSensorModel(rhs), + _n_srgr(rhs._n_srgr), + _pixel_spacing(rhs._pixel_spacing), + _data(new Data(*(rhs._data))), + _leader(new Leader(*(rhs._leader))), + _trailer(new Trailer(*(rhs._trailer))), + _volumeDir(new VolumeDir(*(rhs._volumeDir))) +{ +} + ossimRadarSatModel::~ossimRadarSatModel() { if (_data != 0) @@ -280,7 +292,16 @@ bool ossimRadarSatModel::open(const ossimFilename& file) dataFile>>*_data; dataFile.close(); - _data->InsertRecord(headerDAT.get_rec_seq(), recordDAT); + /* + * Commenting this line : + * With SARDEGNA file (a corrupted file without number of lines) + * this line makes disappear the auto-computation of number of lines + * by file seeking. + * It does not seem to add any information either (same keywordlist) + * + * TODO : investigate : what is it supposed to do ? + */ + //_data->InsertRecord(headerDAT.get_rec_seq(), recordDAT); if(traceDebug()) { @@ -382,16 +403,40 @@ bool ossimRadarSatModel::open(const ossimFilename& file) } } + ossimKeywordlist geom_kwl; + this->internalSaveState(geom_kwl); + this->internalLoadState(geom_kwl); + + // Assign the ossimSensorModel::theBoundGndPolygon + ossimGpt ul; + ossimGpt ur; + ossimGpt lr; + ossimGpt ll; + lineSampleToWorld(theImageClipRect.ul(), ul); + lineSampleToWorld(theImageClipRect.ur(), ur); + lineSampleToWorld(theImageClipRect.lr(), lr); + lineSampleToWorld(theImageClipRect.ll(), ll); + setGroundRect(ul, ur, lr, ll); // ossimSensorModel method. + if(traceDebug()) { - ossimNotify(ossimNotifyLevel_DEBUG) << "ossimRadarSatTileSource::open() DEBUG: returning..." << std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "ossimRadarSatModel::open() DEBUG: returning..." << std::endl; } + return retValue; } -bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, - const char* prefix) const + +bool ossimRadarSatModel::internalSaveState(ossimKeywordlist& kwl, + const char* prefix) const { + static const char MODULE[] = "ossimRadarSatModel::internalSaveState"; + + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG)<< MODULE << " entered...\n"; + } + char name[64]; kwl.add(prefix, ossimKeywordNames::TYPE_KW, "ossimRadarSatModel", true); @@ -406,9 +451,6 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, return false; } - /* - * Ajout des donn�es n�cessaires au mod�le de capteur dans la liste des mots clefs - */ DataSetSummary * datasetSummary = _leader->get_DataSetSummary(); if(datasetSummary == NULL) { @@ -473,9 +515,6 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, return false; } - /* - * Ajout des donn�es n�cessaires au mod�le de capteur dans la liste des mots clefs - */ ProcessingParameters * processingParameters = _leader->get_ProcessingParameters(); if(processingParameters == NULL) { @@ -516,9 +555,6 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, return false; } - /* - * Ajout des donn�es n�cessaires au mod�le de capteur dans la liste des mots clefs - */ PlatformPositionData * platformPositionData = _leader->get_PlatformPositionData(); if(platformPositionData != NULL) { @@ -586,7 +622,7 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, } ProcessedDataRecord * lastProcessedDataRecord = _data->get_LastProcessedDataRecord(); - if(firstProcessedDataRecord != NULL) + if(lastProcessedDataRecord != NULL) { sprintf(name,"cornersLon%i",2); kwl.add(prefix, name,((float) (lastProcessedDataRecord->get_lon_first()))/1000000.0,true); @@ -607,18 +643,78 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, return true; } -bool ossimRadarSatModel::loadState (const ossimKeywordlist &kwl, - const char *prefix) +bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, + const char* prefix) const { + bool result = this->internalSaveState(kwl, prefix); - InitSRGR(kwl, prefix); - InitSensorParams(kwl, prefix); - InitPlatformPosition(kwl, prefix); - InitRefPoint(kwl, prefix); + if (result) + { + result = ossimGeometricSarSensorModel::saveState(kwl, prefix); + } + return result; +} + +bool ossimRadarSatModel::internalLoadState (const ossimKeywordlist &kwl, + const char *prefix) +{ + static const char MODULE[] = "ossimRadarSatModel::internalLoadState"; + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; + } + + this->InitSRGR(kwl, prefix); + this->InitSensorParams(kwl, prefix); + this->InitPlatformPosition(kwl, prefix); + this->InitRefPoint(kwl, prefix); + + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit...\n"; + } return true; } +bool ossimRadarSatModel::loadState (const ossimKeywordlist &kwl, + const char *prefix) +{ + static const char MODULE[] = "ossimRadarSatModel::loadState"; + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; + } + + const char* lookup = 0; + ossimString s; + + // Check the type first. + lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW); + if (lookup) + { + s = lookup; + if (s != getClassName()) + { + return false; + } + } + + //bool result = ossimGeometricSarSensorModel::loadState(kwl, prefix); + + bool result = true; + if (result) + { + result = this->internalLoadState(kwl, prefix); + } + + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit...\n"; + } + return result; +} + bool ossimRadarSatModel::InitSensorParams(const ossimKeywordlist &kwl, const char *prefix) { const char* wave_length_str = kwl.find(prefix,"wave_length"); @@ -955,9 +1051,10 @@ bool ossimRadarSatModel::InitRefPoint(const ossimKeywordlist &kwl, const char *p // in order to use ossimSensorModel::lineSampleToWorld const char* nbCol_str = kwl.find(prefix,"nbCol"); const char* nbLin_str = kwl.find(prefix,"nbLin"); + theImageSize.x = atoi(nbCol_str); - theImageSize.y = atoi(nbLin_str); - theImageClipRect = ossimDrect(0, 0, theImageSize.x-1, theImageSize.y-1); + theImageSize.y = atoi(nbLin_str); + theImageClipRect = ossimDrect(0, 0, theImageSize.x-1, theImageSize.y-1); // sensor PRF update in the case of ground projected products if (_isProductGeoreferenced) { @@ -1034,7 +1131,7 @@ bool ossimRadarSatModel::InitSRGR(const ossimKeywordlist &kwl, const char *prefi format[3] = '\0'; std::string format_str(format); - _isProductGeoreferenced = (format_str=="SGX") || (format_str=="SGF"); + _isProductGeoreferenced = (format_str=="SGX") || (format_str=="SGF") || (format_str=="SCW"); // pixel spacing const char* pixel_spacing_str = kwl.find(prefix,"pixel_spacing"); diff --git a/Utilities/otbossimplugins/ossim/ossimRadarSatModel.h b/Utilities/otbossimplugins/ossim/ossimRadarSatModel.h index 7617ce1bc84aaa7a0eda364e350ff04f4522245f..4f22daf86c69e7a1351e1dba85b7c645b884dfed 100644 --- a/Utilities/otbossimplugins/ossim/ossimRadarSatModel.h +++ b/Utilities/otbossimplugins/ossim/ossimRadarSatModel.h @@ -43,6 +43,9 @@ public: /** @brief Constructor */ ossimRadarSatModel(); + /** @brief copy constructor */ + ossimRadarSatModel(const ossimRadarSatModel& rhs); + /** @brief Destructor */ virtual ~ossimRadarSatModel(); @@ -135,6 +138,24 @@ private: * @brief Initializes the Slant Range for each Ground Range data sets : _n_srgr,_srgr_coefset,_srgr_update,_pixel_spacing,_isProductGeoreferenced */ virtual bool InitSRGR(const ossimKeywordlist &kwl, const char *prefix); + + /** + * @brief Method to save object state to a keyword list. + * @param kwl Keyword list to save to. + * @param prefix added to keys when saved. + * @return true on success, false on error. + */ + virtual bool internalSaveState(ossimKeywordlist& kwl, + const char* prefix=0) const; + + /** + * @brief Method to the load (recreate) the state of the object from a + * keyword list. Return true if ok or false on error. + * @return true if load OK, false on error + */ + virtual bool internalLoadState (const ossimKeywordlist &kwl, const char *prefix=0); + + /** * @brief Finds the SRGR data set which update time is the closest to the center scene time */ diff --git a/Utilities/otbossim/src/ossim/projection/ossimTileMapModel.cpp b/Utilities/otbossimplugins/ossim/ossimTileMapModel.cpp similarity index 94% rename from Utilities/otbossim/src/ossim/projection/ossimTileMapModel.cpp rename to Utilities/otbossimplugins/ossim/ossimTileMapModel.cpp index 0e51c49c82db57482e40e2b3625f834e6067829c..d3b5b2722feb148926d33a3a919cb1ac0592d143 100644 --- a/Utilities/otbossim/src/ossim/projection/ossimTileMapModel.cpp +++ b/Utilities/otbossimplugins/ossim/ossimTileMapModel.cpp @@ -12,14 +12,13 @@ // //***************************************************************************** -#include <ossim/projection/ossimTileMapModel.h> +#include "ossimTileMapModel.h" -RTTI_DEF1(ossimTileMapModel, "ossimTileMapModel", ossimSensorModel); +#include <stdio.h> +#include <cstdlib> #include <ossim/base/ossimKeywordlist.h> #include <ossim/base/ossimKeywordNames.h> -#include <stdio.h> -#include <cstdlib> //*** // Define Trace flags for use within this file: @@ -28,6 +27,10 @@ RTTI_DEF1(ossimTileMapModel, "ossimTileMapModel", ossimSensorModel); static ossimTrace traceExec ("ossimTileMapModel:exec"); static ossimTrace traceDebug ("ossimTileMapModel:debug"); +namespace ossimplugins +{ + +RTTI_DEF1(ossimTileMapModel, "ossimTileMapModel", ossimSensorModel); //***************************************************************************** // DEFAULT CONSTRUCTOR: ossimTileMapModel() @@ -49,6 +52,26 @@ ossimTileMapModel::ossimTileMapModel() } +bool ossimTileMapModel::open(const ossimFilename& file) +{ + static const char MODULE[] = "ossimTileMapModel::open"; + + ossimString os = file.beforePos(4); + + if (traceDebug()) + { + CLOG << " Entered..." << std::endl + << " trying to open file " << file << std::endl; + } + if(os == "http" || file.ext() == "otb") + { + return true; + } + + return false; +} + + //***************************************************************************** // CONSTRUCTOR: ossimTileMapModel(kwl) // @@ -262,3 +285,4 @@ void ossimTileMapModel::writeGeomTemplate(ostream& os) if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimTileMapModel::writeGeomTemplate: returning..." << std::endl; return; } +} // End: namespace ossimplugins diff --git a/Utilities/otbossim/include/ossim/projection/ossimTileMapModel.h b/Utilities/otbossimplugins/ossim/ossimTileMapModel.h similarity index 97% rename from Utilities/otbossim/include/ossim/projection/ossimTileMapModel.h rename to Utilities/otbossimplugins/ossim/ossimTileMapModel.h index cb6dcf6d4557c79135f56776b485b993006d10ee..eb46b4f8815d05bcd20a8d49e303f09bd82fe0ac 100644 --- a/Utilities/otbossim/include/ossim/projection/ossimTileMapModel.h +++ b/Utilities/otbossimplugins/ossim/ossimTileMapModel.h @@ -23,6 +23,8 @@ class ossimMapProjection; +namespace ossimplugins +{ //****************************************************************************** //* //* CLASS: ossimTileMapModel @@ -59,6 +61,10 @@ public: */ virtual std::ostream& print(std::ostream& out) const; + + + bool open(const ossimFilename& file); + /*! * Fulfills ossimObject base-class pure virtuals. Loads and saves geometry * KWL files. Returns true if successful. @@ -155,5 +161,5 @@ protected: }; - +} // End: namespace ossimplugins #endif diff --git a/Utilities/otbossim/src/ossim/imaging/ossimTileMapTileSource.cpp b/Utilities/otbossimplugins/ossim/ossimTileMapTileSource.cpp similarity index 96% rename from Utilities/otbossim/src/ossim/imaging/ossimTileMapTileSource.cpp rename to Utilities/otbossimplugins/ossim/ossimTileMapTileSource.cpp index 7550ecac211fc267e19b06480acd5885a64202ea..7bffdd6a42a10cc2fb765797cb6d943a9f847c9e 100644 --- a/Utilities/otbossim/src/ossim/imaging/ossimTileMapTileSource.cpp +++ b/Utilities/otbossimplugins/ossim/ossimTileMapTileSource.cpp @@ -11,20 +11,24 @@ //******************************************************************* // $Id: ossimTileMapTileSource.cpp 10752 2007-04-23 16:50:08Z dburken $ -#include <ossim/imaging/ossimTileMapTileSource.h> +#include "ossimTileMapTileSource.h" + +#include "ossimTileMapModel.h" + #include <ossim/base/ossimDirectory.h> #include <ossim/base/ossimTrace.h> #include <ossim/base/ossimNotifyContext.h> #include <ossim/base/ossimKeywordNames.h> #include <ossim/imaging/ossimImageGeometryRegistry.h> -#include <ossim/projection/ossimTileMapModel.h> -RTTI_DEF1_INST(ossimTileMapTileSource, - "ossimTileMapTileSource", - ossimGeneralRasterTileSource) static ossimTrace traceDebug("ossimTileMapTileSource:debug"); +namespace ossimplugins +{ +RTTI_DEF1_INST(ossimTileMapTileSource, + "ossimTileMapTileSource", + ossimGeneralRasterTileSource) //******************************************************************* // Public Constructor: @@ -141,5 +145,4 @@ ossimString ossimTileMapTileSource::className() const return ossimString("ossimTileMapTileSource"); } - - +} // End: namespace ossimplugins diff --git a/Utilities/otbossim/include/ossim/imaging/ossimTileMapTileSource.h b/Utilities/otbossimplugins/ossim/ossimTileMapTileSource.h similarity index 96% rename from Utilities/otbossim/include/ossim/imaging/ossimTileMapTileSource.h rename to Utilities/otbossimplugins/ossim/ossimTileMapTileSource.h index c32673c16fe49c06ba554dc42055703151435212..f7461b59b245bc36790b13995daf882e3e1cad39 100644 --- a/Utilities/otbossim/include/ossim/imaging/ossimTileMapTileSource.h +++ b/Utilities/otbossimplugins/ossim/ossimTileMapTileSource.h @@ -22,6 +22,8 @@ class ossimFfL7; +namespace ossimplugins +{ class OSSIM_DLL ossimTileMapTileSource : public ossimGeneralRasterTileSource { public: @@ -58,5 +60,5 @@ private: TYPE_DATA }; - +} // End: namespace ossimplugins #endif