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..c576cef3fd2a8f540a383758a2adac4360fa1ade 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/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/otbUtils.cxx b/Code/Common/otbUtils.cxx index 4af006907b965d2b0d24286d387c1178cc621445..1beb2b1acd82c7c3f940eee1de4672d753220b4d 100644 --- a/Code/Common/otbUtils.cxx +++ b/Code/Common/otbUtils.cxx @@ -17,11 +17,15 @@ =========================================================================*/ #include "otbUtils.h" +#include <sstream> namespace otb { -bool Utils::IsLonLatValid(double lon, double lat) +namespace Utils +{ + +bool IsLonLatValid(double lon, double lat) { if (lon < -180.0) return false; if (lon > 180.0) return false; @@ -31,3 +35,5 @@ bool Utils::IsLonLatValid(double lon, double lat) } } + +} diff --git a/Code/Common/otbUtils.h b/Code/Common/otbUtils.h index 6ab435e7a3ed52689d0525d6a57113605122ec27..dd0b5b8c1007a6933ac13ba4cde3c5e393413205 100644 --- a/Code/Common/otbUtils.h +++ b/Code/Common/otbUtils.h @@ -29,14 +29,20 @@ namespace otb * Some usefull utilities in use across the library * */ -class ITK_EXPORT Utils +namespace Utils { -public: - /** Check that the values for lon, lat are reasonable */ - static bool IsLonLatValid(double lon, double lat); + bool IsLonLatValid(double lon, double lat); + + template <class T> + inline std::string ConvertToString (const T& v) + { + std::stringstream s; + s << v; + return s.str(); + } -}; +} } // namespace otb 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/otbGDALImageIO.cxx b/Code/IO/otbGDALImageIO.cxx index 9d9b81204ae2cff82417936507b911a7a384cb98..8e533b231498bf21f7f2c98e704378221ded84db 100644 --- a/Code/IO/otbGDALImageIO.cxx +++ b/Code/IO/otbGDALImageIO.cxx @@ -1458,6 +1458,8 @@ std::string GDALImageIO::FilenameToGdalDriverShortName(std::string name) gdalDriverShortName="JPEG"; else if ( extension == "pix" ) gdalDriverShortName="PCIDSK"; + else if ( extension == "ras" ) + gdalDriverShortName="GTiff"; else gdalDriverShortName = "NOT-FOUND"; 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/IO/otbMapProjectionWrapper.cxx b/Code/IO/otbMapProjectionWrapper.cxx index 876af945777cb95273a4cb9efbfa52df5f03af4c..734399aab46904c7e48837a0e97765305ba29bc9 100644 --- a/Code/IO/otbMapProjectionWrapper.cxx +++ b/Code/IO/otbMapProjectionWrapper.cxx @@ -17,10 +17,13 @@ =========================================================================*/ #include "otbMapProjectionWrapper.h" + +#include <cassert> + #include "otbMacro.h" +#include "otbUtils.h" #include "projection/ossimMapProjection.h" - #include "projection/ossimMapProjectionFactory.h" #include "projection/ossimMapProjection.h" #include "base/ossimGpt.h" @@ -31,11 +34,14 @@ #include "base/ossimString.h" #include "gdal/ossimOgcWktTranslator.h" +#include "projection/ossimUtmProjection.h" +#include "projection/ossimLambertConformalConicProjection.h" + namespace otb { MapProjectionWrapper::MapProjectionWrapper(): - m_MapProjection(NULL), m_ProjectionRefWkt(""), reinstanciateProjection(true) + m_MapProjection(NULL), m_ProjectionRefWkt(""), m_ReinstanciateProjection(true) { } @@ -50,7 +56,7 @@ MapProjectionWrapper::~MapProjectionWrapper() MapProjectionWrapper::InternalMapProjectionPointer MapProjectionWrapper::GetMapProjection() { itkDebugMacro("returning MapProjection address " << this->m_MapProjection); - if ((reinstanciateProjection) || (m_MapProjection == NULL)) + if ((m_ReinstanciateProjection) || (m_MapProjection == NULL)) { this->InstanciateProjection(); } @@ -61,7 +67,7 @@ MapProjectionWrapper::InternalMapProjectionPointer MapProjectionWrapper::GetMapP MapProjectionWrapper::InternalMapProjectionConstPointer MapProjectionWrapper::GetMapProjection() const { itkDebugMacro("returning MapProjection address " << this->m_MapProjection); - if ((reinstanciateProjection) || (m_MapProjection == NULL)) + if ((m_ReinstanciateProjection) || (m_MapProjection == NULL)) { itkExceptionMacro(<< "m_MapProjection not up-to-date, call InstanciateProjection() first"); } @@ -69,8 +75,7 @@ MapProjectionWrapper::InternalMapProjectionConstPointer MapProjectionWrapper::Ge return this->m_MapProjection; } - -std::string MapProjectionWrapper::GetWkt() +std::string MapProjectionWrapper::GetWkt() const { ossimKeywordlist kwl; this->GetMapProjection(); @@ -88,41 +93,137 @@ std::string MapProjectionWrapper::GetWkt() void MapProjectionWrapper::SetWkt(std::string projectionRefWkt) { this->m_ProjectionRefWkt = projectionRefWkt; - reinstanciateProjection = true; - this->InstanciateProjection(); + m_ReinstanciateProjection = true; + this->InstanciateProjection(); //Should not be needed, but it is... + this->Modified(); +} + +void MapProjectionWrapper::SetParameter(std::string key, std::string value) +{ + m_ParameterStore[key] = value; + m_ReinstanciateProjection = true; + this->InstanciateProjection(); //Should not be needed, but it is... this->Modified(); } +std::string MapProjectionWrapper::GetParameter(std::string key) const +{ + // Please refer to the note in the header filer + // we do NOT want to read from m_ParameterStore here! + + std::string projectionName = this->GetMapProjection()->getClassName(); + + // Start by matching generic parameters + const ossimMapProjection* projection = dynamic_cast<const ossimMapProjection*>(this->GetMapProjection()); + if (key.compare("Origin") == 0) + { + return Utils::ConvertToString(projection->origin()); + } + if (key.compare("FalseNorthing") == 0) + { + return Utils::ConvertToString(projection->getFalseNorthing()); + } + if (key.compare("FalseEasting") == 0) + { + return Utils::ConvertToString(projection->getFalseEasting()); + } + if (key.compare("StandardParallel1") == 0) + { + return Utils::ConvertToString(projection->getStandardParallel1()); + } + if (key.compare("StandardParallel2") == 0) + { + return Utils::ConvertToString(projection->getStandardParallel2()); + } + if (key.compare("A") == 0) + { + return Utils::ConvertToString(projection->getA()); + } + if (key.compare("B") == 0) + { + return Utils::ConvertToString(projection->getB()); + } + if (key.compare("F") == 0) + { + return Utils::ConvertToString(projection->getF()); + } + if (key.compare("MetersPerPixel") == 0) + { + return Utils::ConvertToString(projection->getMetersPerPixel()); + } + if (key.compare("DecimalDegreesPerPixel") == 0) + { + return Utils::ConvertToString(projection->getDecimalDegreesPerPixel()); + } + + + // Apply parameters to Utm + if (projectionName.compare("ossimUtmProjection") == 0) + { + const ossimUtmProjection* projection = dynamic_cast<const ossimUtmProjection*>(this->GetMapProjection()); + if (key.compare("Zone") == 0) + { + return Utils::ConvertToString(projection->getZone()); + } + if (key.compare("Hemisphere") == 0) + { + return Utils::ConvertToString(projection->getHemisphere()); + } + } + + return ""; +} + bool MapProjectionWrapper::InstanciateProjection() { - if ((this->reinstanciateProjection) || (m_MapProjection == NULL)) + if ((this->m_ReinstanciateProjection) || (m_MapProjection == NULL)) { ossimKeywordlist kwl; ossimOgcWktTranslator wktTranslator; bool projectionInformationAvailable = wktTranslator.toOssimKwl(m_ProjectionRefWkt, kwl); - if (!projectionInformationAvailable) + if (projectionInformationAvailable) { - otbMsgDevMacro(<< "WARNING: Impossible to create the projection from string: " << m_ProjectionRefWkt); - return false; - } + //we don't want to have a ossimEquDistCylProjection here: + //see discussion in May 2009 on ossim list; + //a better solution might be available... + std::string projectionString(kwl.find("type")); + if (projectionString.find("ossimEquDistCylProjection") != string::npos) + { + otbMsgDevMacro(<< "WARNING: Not instanciating a ossimEquDistCylProjection: " << projectionString); + otbMsgDevMacro(<< "Wkt was: " << kwl); + otbMsgDevMacro(<< "From RefWkt: " << m_ProjectionRefWkt); + return false; + } + + m_MapProjection = ossimMapProjectionFactory::instance()->createProjection(kwl); - //we don't want to have a ossimEquDistCylProjection here: - //see discussion in May 2009 on ossim list; - //a better solution might be available... - std::string projectionString(kwl.find("type")); - if (projectionString.find("ossimEquDistCylProjection") != string::npos) - { - otbMsgDevMacro(<< "WARNING: Not instanciating a ossimEquDistCylProjection: " << projectionString); - otbMsgDevMacro(<< "Wkt was: " << kwl); - otbMsgDevMacro(<< "From RefWkt: " << m_ProjectionRefWkt); - return false; } + else + { + otbMsgDevMacro(<< "WARNING: Impossible to create the projection from Wkt: " << m_ProjectionRefWkt); + otbMsgDevMacro(<< "Trying with string as a string (ossimUtmProjection or Utm would qualify"); + // Trying directly with the m_ProjectionRefWkt (is + // ossimUtmProjection for example) + ossimString name(m_ProjectionRefWkt); + m_MapProjection = ossimMapProjectionFactory::instance()->createProjection(name); + if (m_MapProjection == NULL) + { + // Trying directly extending the m_ProjectionRefWkt (convert the + // Utm to ossimUtmProjection for example) + ossimString extendedName("ossim"); + extendedName += m_ProjectionRefWkt; + extendedName += "Projection"; + m_MapProjection = ossimMapProjectionFactory::instance()->createProjection(extendedName); + } + + if (m_MapProjection == NULL) return false; - m_MapProjection = ossimMapProjectionFactory::instance()->createProjection(kwl); + } - this->reinstanciateProjection = false; + this->m_ReinstanciateProjection = false; + this->ApplyParametersToProjection(); return true; } return false; @@ -175,8 +276,118 @@ void MapProjectionWrapper::ForwardTransform(double lon, double lat, double h, z = h; } +void MapProjectionWrapper::ApplyParametersToProjection() +{ + // Start by identifying the projection, that will be necessary for + // the casting. + std::string projectionName = this->GetMapProjection()->getClassName(); + + StoreType::const_iterator it; + + // Apply standard map projection parameters + ossimMapProjection* projection = dynamic_cast<ossimMapProjection*>(this->GetMapProjection()); + // Set up origin + + const ossimDatum* datum = ossimDatumFactory::instance()->wgs84(); //default value + it = m_ParameterStore.find("Datum"); + if (it != m_ParameterStore.end()) + { + datum = ossimDatumFactory::instance()->create((*it).second); + projection->setDatum(datum); + } + + StoreType::const_iterator itX = m_ParameterStore.find("OriginX"); + StoreType::const_iterator itY = m_ParameterStore.find("OriginY"); + StoreType::const_iterator itZ = m_ParameterStore.find("OriginZ"); + + if (itX != m_ParameterStore.end() && itY != m_ParameterStore.end()) + { + double originX = atof((*itX).second.c_str()); + double originY = atof((*itY).second.c_str()); + double originZ = 0; + if (itZ != m_ParameterStore.end()) + { + originZ = atof((*itZ).second.c_str()); + } + ossimGpt origin(originY, originX, originZ, datum); + projection->setOrigin(origin); + } + + // Apply parameters to LambertConformalConic + if (projectionName.compare("ossimLambertConformalConicProjection") == 0) + { + ossimLambertConformalConicProjection* projection = dynamic_cast<ossimLambertConformalConicProjection*>(this->GetMapProjection()); + + it = m_ParameterStore.find("FalseNorthing"); + if (it != m_ParameterStore.end()) + { + double value = atof((*it).second.c_str()); + projection->setFalseNorthing(value); + } + it = m_ParameterStore.find("FalseEasting"); + if (it != m_ParameterStore.end()) + { + double value = atof((*it).second.c_str()); + projection->setFalseEasting(value); + } + it = m_ParameterStore.find("StandardParallel1"); + if (it != m_ParameterStore.end()) + { + double value = atof((*it).second.c_str()); + projection->setStandardParallel1(value); + } + it = m_ParameterStore.find("StandardParallel2"); + if (it != m_ParameterStore.end()) + { + double value = atof((*it).second.c_str()); + projection->setStandardParallel2(value); + } + } + + + // Apply parameters to Utm + if (projectionName.compare("ossimUtmProjection") == 0) + { + ossimUtmProjection* projection = dynamic_cast<ossimUtmProjection*>(this->GetMapProjection()); + it = m_ParameterStore.find("Zone"); + if (it != m_ParameterStore.end()) + { + int zone = atoi((*it).second.c_str()); + projection->setZone(zone); + } + it = m_ParameterStore.find("Hemisphere"); + if (it != m_ParameterStore.end()) + { + projection->setHemisphere((*it).second[0]); + } + } +} + void MapProjectionWrapper::PrintMap() const { std::cout << m_MapProjection->print(std::cout); + std::cout << "Parameter store:\n"; + for (StoreType::const_iterator it = m_ParameterStore.begin(); + it != m_ParameterStore.end(); + ++it) + { + std::cout << " " << (*it).first << ": " << (*it).second << "\n"; + } } + + +namespace Utils +{ + +int GetZoneFromGeoPoint(double lon, double lat) +{ + //use ossim to handle the special case of UTM + ossimGpt point(lat, lon); + ossimUtmProjection projection; + int zone = projection.computeZone(point); + return zone; +} + +} + } // namespace otb diff --git a/Code/IO/otbMapProjectionWrapper.h b/Code/IO/otbMapProjectionWrapper.h index c8afab5a83ea52e7fcd59a3fa3f541626c1e4638..eb4923df5e3f6494a67436d30e5c64faa99e03ef 100644 --- a/Code/IO/otbMapProjectionWrapper.h +++ b/Code/IO/otbMapProjectionWrapper.h @@ -18,6 +18,9 @@ #ifndef __otbMapProjectionWrapper_h #define __otbMapProjectionWrapper_h +#include <string> +#include <map> + #include "itkObject.h" #include "itkObjectFactory.h" @@ -31,7 +34,8 @@ namespace otb * \brief Wrapper class to group all dependencies to ossim for map projection * * This class is NOT intented to be used outside of OTB. Use the - * GenericMapProjection. + * GenericMapProjection. If you feel that you need to use it directly, + * think again! * * \sa GenericMapProjection * \ingroup Projection @@ -47,7 +51,7 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef ossimProjection* InternalMapProjectionPointer; + typedef ossimProjection* InternalMapProjectionPointer; typedef const ossimProjection* InternalMapProjectionConstPointer; /** Method for creation through the object factory. */ @@ -59,8 +63,12 @@ public: InternalMapProjectionPointer GetMapProjection(); InternalMapProjectionConstPointer GetMapProjection() const; - std::string GetWkt(); + std::string GetWkt() const; void SetWkt(std::string projectionRefWkt); + + void SetParameter(std::string key, std::string value); + std::string GetParameter(std::string key) const; + bool InstanciateProjection(); void InverseTransform(double x, double y, double z, @@ -69,20 +77,37 @@ public: double& x, double& y, double& z); void PrintMap() const; + protected: MapProjectionWrapper(); virtual ~MapProjectionWrapper(); - private: MapProjectionWrapper(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented + void ApplyParametersToProjection(); + InternalMapProjectionPointer m_MapProjection; std::string m_ProjectionRefWkt; - bool reinstanciateProjection; + // Hold the parameters specified directly from the user of the class + // Consistency is done from ParameterStore -> MapProjection + // But NOT MapProjection -> ParameterStore + // so DO NOT use that to read the projection parameters + typedef std::map<std::string, std::string> StoreType; + StoreType m_ParameterStore; + + bool m_ReinstanciateProjection; }; + +// Some usefull free functions related to ossim +namespace Utils +{ +int GetZoneFromGeoPoint(double lon, double lat); +} + + } // namespace otb #endif diff --git a/Code/Projections/otbGenericMapProjection.h b/Code/Projections/otbGenericMapProjection.h index 1b7e351bc2b73f829326229991567225e875872f..58614d1d95eca8cde1a29be20393692816ebd0fe 100644 --- a/Code/Projections/otbGenericMapProjection.h +++ b/Code/Projections/otbGenericMapProjection.h @@ -101,6 +101,11 @@ public: const MapProjectionWrapper* GetMapProjection() const; + virtual bool IsProjectionDefined() const; + + void SetParameter(std::string key, std::string value); + std::string GetParameter(std::string key) const; + protected: GenericMapProjection(); virtual ~GenericMapProjection(); diff --git a/Code/Projections/otbGenericMapProjection.txx b/Code/Projections/otbGenericMapProjection.txx index 132cb993f4a4ee7687bf07bf27c12267fe85dd3c..f02c899c85c4e36c1511c4acc77c5581b5c56ab0 100644 --- a/Code/Projections/otbGenericMapProjection.txx +++ b/Code/Projections/otbGenericMapProjection.txx @@ -124,6 +124,32 @@ GenericMapProjection<TDirectionOfMapping, TScalarType, NInputDimensions, NOutput m_MapProjection->PrintMap(); } +template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions, + unsigned int NOutputDimensions> +bool +GenericMapProjection<TDirectionOfMapping, TScalarType, NInputDimensions, NOutputDimensions> +::IsProjectionDefined() const +{ + return (m_MapProjection->GetMapProjection() != NULL); +} + +template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions, + unsigned int NOutputDimensions> + void +GenericMapProjection<TDirectionOfMapping, TScalarType, NInputDimensions, NOutputDimensions> +::SetParameter(std::string key, std::string value) +{ + m_MapProjection->SetParameter(key, value); +} + +template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions, + unsigned int NOutputDimensions> +std::string +GenericMapProjection<TDirectionOfMapping, TScalarType, NInputDimensions, NOutputDimensions> +::GetParameter(std::string key) const +{ + return m_MapProjection->GetParameter(key); +} template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions> @@ -132,7 +158,6 @@ GenericMapProjection<TDirectionOfMapping, TScalarType, NInputDimensions, NOutput ::PrintSelf(std::ostream& os, itk::Indent indent) const { Superclass::PrintSelf(os, indent); - os << indent << "ProjectionRefWkt: " << m_MapProjection->GetWkt() << std::endl; } diff --git a/Code/Projections/otbGenericRSTransform.txx b/Code/Projections/otbGenericRSTransform.txx index 2c8517dd24649abcd0d8e64872e258d4e194f122..a69d69daa5c42f82c7eef7a777add95b96e67825 100644 --- a/Code/Projections/otbGenericRSTransform.txx +++ b/Code/Projections/otbGenericRSTransform.txx @@ -117,7 +117,7 @@ GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions> InverseMapProjectionType; typename InverseMapProjectionType::Pointer mapTransform = InverseMapProjectionType::New(); mapTransform->SetWkt(m_InputProjectionRef); - if (mapTransform->GetMapProjection() != NULL) + if (mapTransform->IsProjectionDefined()) { m_InputTransform = mapTransform.GetPointer(); inputTransformIsMap = true; @@ -195,7 +195,7 @@ GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions> OutputSpaceDimension> ForwardMapProjectionType; typename ForwardMapProjectionType::Pointer mapTransform = ForwardMapProjectionType::New(); mapTransform->SetWkt(m_OutputProjectionRef); - if (mapTransform->GetMapProjection() != NULL) + if (mapTransform->IsProjectionDefined()) { m_OutputTransform = mapTransform.GetPointer(); outputTransformIsMap = true; diff --git a/Code/Projections/otbLambert2EtenduProjection.h b/Code/Projections/otbLambert2EtenduProjection.h index 06ff11d5abc95bd4fb940cf8c8a02269e18eda73..9a1df1fb8c18a20585435b2672e3b7ec25e22ce4 100644 --- a/Code/Projections/otbLambert2EtenduProjection.h +++ b/Code/Projections/otbLambert2EtenduProjection.h @@ -18,7 +18,7 @@ #ifndef __otbLambert2EtenduProjection_h #define __otbLambert2EtenduProjection_h -#include "otbMapProjection.h" +#include "otbLambertConformalConicMapProjection.h" namespace otb { @@ -37,10 +37,6 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef typename Superclass::ScalarType ScalarType; - typedef itk::Point<ScalarType, 2> InputPointType; - typedef itk::Point<ScalarType, 2> OutputPointType; - /** Method for creation through the object factory. */ itkNewMacro(Self); @@ -48,18 +44,24 @@ public: itkTypeMacro(Lambert2EtenduProjection, LambertConformalConicMapProjection); protected: - Lambert2EtenduProjection(); - virtual ~Lambert2EtenduProjection(); + Lambert2EtenduProjection() + { + this->SetParameter("OriginX", "2.33722778"); + this->SetParameter("OriginY", "46.8"); + this->SetParameter("Datum", "NTF"); + this->SetParameter("FalseNorthing", "2200000"); + this->SetParameter("FalseEasting", "600000"); + this->SetParameter("StandardParallel1", "45.89891944"); + this->SetParameter("StandardParallel2", "47.69601389"); + } + + virtual ~Lambert2EtenduProjection() {} private: Lambert2EtenduProjection(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented + void operator =(const Self&); //purposely not implemented }; } // namespace otb -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbLambert2EtenduProjection.txx" -#endif - #endif diff --git a/Code/Projections/otbLambert2EtenduProjection.txx b/Code/Projections/otbLambert2EtenduProjection.txx deleted file mode 100644 index 0acf0d864f8bb694da2d53526014689f5afdf3e4..0000000000000000000000000000000000000000 --- a/Code/Projections/otbLambert2EtenduProjection.txx +++ /dev/null @@ -1,57 +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 __otbLambert2EtenduProjection_txx -#define __otbLambert2EtenduProjection_txx - -#include "otbLambert2EtenduProjection.h" - -namespace otb -{ - -template <TransformDirection::TransformationDirection TTransform> -Lambert2EtenduProjection<TTransform> -::Lambert2EtenduProjection() -{ - itk::Point<double, 2> origin; - origin[0] = 2.33722778; - origin[1] = 46.8; - std::string datum = "NTF"; - - double parall1 = 45.89891944; - double parall2 = 47.69601389; - double falseEasting = 600000; - double falseNorthing = 2200000; - std::string ellipsoid = "CE"; - - //TODO: 29-02-2008 Emmanuel: when ossim version > 1.7.2 only - // SetOrigin required (remove SetEllipsoid) - this->SetOrigin(origin, datum); - this->SetEllipsoid(ellipsoid); - this->SetParameters(parall1, parall2, falseEasting, falseNorthing); -} - -template <TransformDirection::TransformationDirection TTransform> -Lambert2EtenduProjection<TTransform> -::~Lambert2EtenduProjection() -{ -} - -} // namespace otb - -#endif diff --git a/Code/Projections/otbLambert3CartoSudProjection.h b/Code/Projections/otbLambert3CartoSudProjection.h index 79c720471955a8b9c12a6bb4e43fdf7113874700..ada8a8a52915b8521e3c4e48a0e1d5f80a338946 100644 --- a/Code/Projections/otbLambert3CartoSudProjection.h +++ b/Code/Projections/otbLambert3CartoSudProjection.h @@ -18,7 +18,7 @@ #ifndef __otbLambert3CartoSudProjection_h #define __otbLambert3CartoSudProjection_h -#include "otbMapProjection.h" +#include "otbLambertConformalConicMapProjection.h" namespace otb { @@ -48,8 +48,18 @@ public: itkTypeMacro(Lambert3CartoSudProjection, LambertConformalConicMapProjection); protected: - Lambert3CartoSudProjection(); - virtual ~Lambert3CartoSudProjection(); + Lambert3CartoSudProjection() + { + this->SetParameter("OriginX", "3"); + this->SetParameter("OriginY", "46.5"); + this->SetParameter("Datum", "WE"); + this->SetParameter("FalseNorthing", "3200000"); + this->SetParameter("FalseEasting", "600000"); + this->SetParameter("StandardParallel1", "43.1992913888888888888888888889"); + this->SetParameter("StandardParallel2", "44.9960938888888888888888888888"); + } + + virtual ~Lambert3CartoSudProjection() {} private: Lambert3CartoSudProjection(const Self &); //purposely not implemented @@ -58,8 +68,4 @@ private: } // namespace otb -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbLambert3CartoSudProjection.txx" -#endif - #endif diff --git a/Code/Projections/otbLambert3CartoSudProjection.txx b/Code/Projections/otbLambert3CartoSudProjection.txx deleted file mode 100644 index 629af6b46ea65c814782bafe1c9aae1ad98babbd..0000000000000000000000000000000000000000 --- a/Code/Projections/otbLambert3CartoSudProjection.txx +++ /dev/null @@ -1,57 +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 __otbLambert3CartoSudProjection_txx -#define __otbLambert3CartoSudProjection_txx - -#include "otbLambert3CartoSudProjection.h" - -namespace otb -{ - -template <TransformDirection::TransformationDirection TTransform> -Lambert3CartoSudProjection<TTransform> -::Lambert3CartoSudProjection() -{ - itk::Point<double, 2> origin; - origin[0] = 3; - origin[1] = 46.5; - std::string datum = "WE"; //WGS84 datum - - double parall1 = 43.1992913888888888888888888889; - double parall2 = 44.9960938888888888888888888888; - double falseEasting = 600000; - double falseNorthing = 3200000; - std::string ellipsoid = "CE"; - - //TODO: 29-02-2008 Emmanuel: when ossim version > 1.7.2 only - // SetOrigin required (remove SetEllipsoid) - this->SetOrigin(origin, datum); - this->SetEllipsoid(ellipsoid); - this->SetParameters(parall1, parall2, falseEasting, falseNorthing); -} - -template <TransformDirection::TransformationDirection TTransform> -Lambert3CartoSudProjection<TTransform> -::~Lambert3CartoSudProjection() -{ -} - -} // namespace otb - -#endif diff --git a/Code/Projections/otbLambert93Projection.h b/Code/Projections/otbLambert93Projection.h index b58f316bd78a1ae7a197ed7b0728d4b90e3ade68..258da098e86f385e649d6f599a475ce72c569ff9 100644 --- a/Code/Projections/otbLambert93Projection.h +++ b/Code/Projections/otbLambert93Projection.h @@ -18,9 +18,7 @@ #ifndef __otbLambert93Projection_h #define __otbLambert93Projection_h -#include "projection/ossimMapProjection.h" -#include "projection/ossimLambertConformalConicProjection.h" -#include "otbMapProjection.h" +#include "otbLambertConformalConicMapProjection.h" namespace otb { @@ -29,19 +27,15 @@ namespace otb * It converts coordinates in longitude, latitude (WGS84) to Lambert 93 map coordinates. * */ -template <TransformDirection::TransformationDirection transform> -class ITK_EXPORT Lambert93Projection : public LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +class ITK_EXPORT Lambert93Projection : public LambertConformalConicMapProjection<TTransform> { public: /** Standard class typedefs. */ - typedef Lambert93Projection Self; - typedef LambertConformalConicMapProjection<transform> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef typename Superclass::ScalarType ScalarType; - typedef itk::Point<ScalarType, 2> InputPointType; - typedef itk::Point<ScalarType, 2> OutputPointType; + typedef Lambert93Projection Self; + typedef LambertConformalConicMapProjection<TTransform> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); @@ -50,18 +44,24 @@ public: itkTypeMacro(Lambert93Projection, LambertConformalConicMapProjection); protected: - Lambert93Projection(); - virtual ~Lambert93Projection(); + Lambert93Projection() + { + this->SetParameter("OriginX", "3"); + this->SetParameter("OriginY", "46.5"); + this->SetParameter("Datum", "WE"); + this->SetParameter("FalseNorthing", "6600000"); + this->SetParameter("FalseEasting", "700000"); + this->SetParameter("StandardParallel1", "44"); + this->SetParameter("StandardParallel2", "49"); + } + + virtual ~Lambert93Projection() {} private: Lambert93Projection(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented + void operator =(const Self&); //purposely not implemented }; } // namespace otb -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbLambert93Projection.txx" -#endif - #endif diff --git a/Code/Projections/otbLambert93Projection.txx b/Code/Projections/otbLambert93Projection.txx deleted file mode 100644 index 8dc32d8a80ea0de9f7a435929f36d650b16383dc..0000000000000000000000000000000000000000 --- a/Code/Projections/otbLambert93Projection.txx +++ /dev/null @@ -1,57 +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 __otbLambert93Projection_txx -#define __otbLambert93Projection_txx - -#include "otbLambert93Projection.h" - -namespace otb -{ - -template <TransformDirection::TransformationDirection transform> -Lambert93Projection<transform> -::Lambert93Projection() -{ - itk::Point<double, 2> origin; - origin[0] = 3; - origin[1] = 46.5; - std::string datum = "WE"; //WGS84 datum - - double parall1 = 44; - double parall2 = 49; - double falseEasting = 700000; - double falseNorthing = 6600000; - std::string ellipsoid = "RF"; //GRS-80 ellipsoid - - //TODO: 29-02-2008 Emmanuel: when ossim version > 1.7.2 only - // SetOrigin required (remove SetEllipsoid) - this->SetOrigin(origin, datum); - this->SetEllipsoid(ellipsoid); - this->SetParameters(parall1, parall2, falseEasting, falseNorthing); -} - -template <TransformDirection::TransformationDirection transform> -Lambert93Projection<transform> -::~Lambert93Projection() -{ -} - -} // namespace otb - -#endif diff --git a/Code/Projections/otbLambertConformalConicMapProjection.h b/Code/Projections/otbLambertConformalConicMapProjection.h index 6878967e9bdbe3420208b3c132208bfc49e596b2..b9f39eefd92d8bb89589407c0410132a554603a3 100644 --- a/Code/Projections/otbLambertConformalConicMapProjection.h +++ b/Code/Projections/otbLambertConformalConicMapProjection.h @@ -18,9 +18,7 @@ #ifndef __otbLambertConformalConicMapProjection_h #define __otbLambertConformalConicMapProjection_h -#include "projection/ossimMapProjection.h" -#include "projection/ossimLambertConformalConicProjection.h" -#include "otbMapProjection.h" +#include "otbGenericMapProjection.h" namespace otb { @@ -29,16 +27,15 @@ namespace otb * It converts coordinates in longitude, latitude (WGS84) to Lambert Conformal Conic map coordinates. * */ -template <TransformDirection::TransformationDirection transform> -class ITK_EXPORT LambertConformalConicMapProjection : public MapProjection<ossimLambertConformalConicProjection, - transform> +template <TransformDirection::TransformationDirection TTransform> +class ITK_EXPORT LambertConformalConicMapProjection : public GenericMapProjection<TTransform> { public: /** Standard class typedefs. */ - typedef LambertConformalConicMapProjection Self; - typedef MapProjection<ossimLambertConformalConicProjection, transform> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef LambertConformalConicMapProjection Self; + typedef GenericMapProjection<TTransform> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; typedef typename Superclass::ScalarType ScalarType; typedef itk::Point<ScalarType, 2> InputPointType; @@ -48,7 +45,7 @@ public: itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(LambertConformalConicMapProjection, MapProjection); + itkTypeMacro(LambertConformalConicMapProjection, GenericMapProjection); void SetStandardParallel1(double degree); void SetStandardParallel2(double degree); @@ -57,12 +54,12 @@ public: void SetFalseNorthing(double falseNorthing); double GetFalseNorthing() const; double GetFalseEasting() const; - void SetParameters(double parallel1Degree, double parallel2Degree, double falseEasting, double falseNorthing); - void SetDefaults(); + void SetParameters(double parallel1Degree, double parallel2Degree, + double falseEasting, double falseNorthing); protected: LambertConformalConicMapProjection(); - virtual ~LambertConformalConicMapProjection(); + virtual ~LambertConformalConicMapProjection() {}; private: LambertConformalConicMapProjection(const Self &); //purposely not implemented diff --git a/Code/Projections/otbLambertConformalConicMapProjection.txx b/Code/Projections/otbLambertConformalConicMapProjection.txx index 456446b8294f5fb3c439e92b3ef01a91b47ff255..8e64a1c56f537e002aec3d36f65517a7d3a2822d 100644 --- a/Code/Projections/otbLambertConformalConicMapProjection.txx +++ b/Code/Projections/otbLambertConformalConicMapProjection.txx @@ -24,90 +24,86 @@ namespace otb { -template <TransformDirection::TransformationDirection transform> -LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +LambertConformalConicMapProjection<TTransform> ::LambertConformalConicMapProjection() { -} - -template <TransformDirection::TransformationDirection transform> -LambertConformalConicMapProjection<transform> -::~LambertConformalConicMapProjection() -{ + this->SetWkt("ossimLambertConformalConicProjection"); } /// Parallel1 specification -template <TransformDirection::TransformationDirection transform> -void LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +void LambertConformalConicMapProjection<TTransform> ::SetStandardParallel1(double degree) { - this->m_MapProjection->setStandardParallel1(degree); + this->SetParameter("StandardParallel1", Utils::ConvertToString(degree)); + this->Modified(); } /// Parallel2 specification -template <TransformDirection::TransformationDirection transform> -void LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +void LambertConformalConicMapProjection<TTransform> ::SetStandardParallel2(double degree) { - this->m_MapProjection->setStandardParallel2(degree); + this->SetParameter("StandardParallel2", Utils::ConvertToString(degree)); + this->Modified(); } /// Specification of the 2 parallels -template <TransformDirection::TransformationDirection transform> -void LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +void LambertConformalConicMapProjection<TTransform> ::SetStandardParallels(double parallel1Degree, double parallel2Degree) { - this->m_MapProjection->setStandardParallels(parallel1Degree, parallel2Degree); + this->SetParameter("StandardParallel1", Utils::ConvertToString(parallel1Degree)); + this->SetParameter("StandardParallel2", Utils::ConvertToString(parallel2Degree)); + this->Modified(); } /// False easting specification -template <TransformDirection::TransformationDirection transform> -void LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +void LambertConformalConicMapProjection<TTransform> ::SetFalseEasting(double falseEasting) { - this->m_MapProjection->setFalseEasting(falseEasting); + this->SetParameter("falseEasting", Utils::ConvertToString(falseEasting)); + this->Modified(); } /// False Northing specification -template <TransformDirection::TransformationDirection transform> -void LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +void LambertConformalConicMapProjection<TTransform> ::SetFalseNorthing(double falseNorthing) { - this->m_MapProjection->setFalseNorthing(falseNorthing); + this->SetParameter("falseNorthing", Utils::ConvertToString(falseNorthing)); + this->Modified(); } /// Set the parameters -template <TransformDirection::TransformationDirection transform> -void LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +void LambertConformalConicMapProjection<TTransform> ::SetParameters(double parallel1Degree, double parallel2Degree, double falseEasting, double falseNorthing) { - this->m_MapProjection->setParameters(parallel1Degree, parallel2Degree, falseEasting, falseNorthing); -} - -/// Set the default parameters -template <TransformDirection::TransformationDirection transform> -void LambertConformalConicMapProjection<transform> -::SetDefaults() -{ - this->m_MapProjection->setDefaults(); + this->SetParameter("StandardParallel1", Utils::ConvertToString(parallel1Degree)); + this->SetParameter("StandardParallel2", Utils::ConvertToString(parallel2Degree)); + this->SetParameter("falseEasting", Utils::ConvertToString(falseEasting)); + this->SetParameter("falseNorthing", Utils::ConvertToString(falseNorthing)); + this->Modified(); } /// Get the False Northing (avoid negative coordinates) -template <TransformDirection::TransformationDirection transform> -double LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +double LambertConformalConicMapProjection<TTransform> ::GetFalseNorthing() const { - double falseNorthing = this->m_MapProjection->getFalseNorthing(); - + double falseNorthing = atoi(this->GetParameter("FalseNorthing").c_str()); return falseNorthing; } ///Get the False Easting (avoid negative coordinates) -template <TransformDirection::TransformationDirection transform> -double LambertConformalConicMapProjection<transform> +template <TransformDirection::TransformationDirection TTransform> +double LambertConformalConicMapProjection<TTransform> ::GetFalseEasting() const { - double falseEasting = this->m_MapProjection->getFalseEasting(); + double falseEasting = atoi(this->GetParameter("FalseEasting").c_str()); return falseEasting; } 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/Projections/otbUtmMapProjection.h b/Code/Projections/otbUtmMapProjection.h index b031c63ba05f9d1af083d8a87db9774d4dd34a51..ae5d9a243749f047223757e8bc732cd793d3b3c3 100644 --- a/Code/Projections/otbUtmMapProjection.h +++ b/Code/Projections/otbUtmMapProjection.h @@ -18,8 +18,7 @@ #ifndef __otbUtmMapProjection_h #define __otbUtmMapProjection_h -#include "projection/ossimUtmProjection.h" -#include "otbMapProjection.h" +#include "otbGenericMapProjection.h" namespace otb { @@ -30,15 +29,15 @@ namespace otb * */ template <TransformDirection::TransformationDirection TTransform> -class ITK_EXPORT UtmMapProjection : public MapProjection<ossimUtmProjection, TTransform> +class ITK_EXPORT UtmMapProjection : public GenericMapProjection<TTransform> { public: /** Standard class typedefs. */ - typedef UtmMapProjection Self; - typedef MapProjection<ossimUtmProjection, TTransform> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef UtmMapProjection Self; + typedef GenericMapProjection<TTransform> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; typedef typename Superclass::ScalarType ScalarType; typedef itk::Point<ScalarType, 2> InputPointType; @@ -48,7 +47,7 @@ public: itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(UtmMapProjection, MapProjection); + itkTypeMacro(UtmMapProjection, GenericMapProjection); virtual void SetZone(long zone); virtual void SetHemisphere(char hemisphere); @@ -56,10 +55,10 @@ public: virtual char GetHemisphere() const; virtual void SetZoneAndHemisphereFromGeoPoint(const InputPointType& geoPoint); - virtual int GetZoneFromGeoPoint(const InputPointType& geoPoint) const; + itkLegacyMacro(virtual int GetZoneFromGeoPoint(const InputPointType& geoPoint) const); protected: - UtmMapProjection() {}; + UtmMapProjection(); virtual ~UtmMapProjection() {}; private: diff --git a/Code/Projections/otbUtmMapProjection.txx b/Code/Projections/otbUtmMapProjection.txx index 450e166099ed39206dfaeda9483066bc5a1e91db..b1bbd30a74b715e09492672b8dbb42af6f7999d1 100644 --- a/Code/Projections/otbUtmMapProjection.txx +++ b/Code/Projections/otbUtmMapProjection.txx @@ -21,15 +21,25 @@ #include "otbUtmMapProjection.h" +#include "otbUtils.h" + namespace otb { +template <TransformDirection::TransformationDirection TTransform> +UtmMapProjection<TTransform> +::UtmMapProjection() +{ + this->SetWkt("ossimUtmProjection"); +} + + ///Set the zone template <TransformDirection::TransformationDirection TTransform> void UtmMapProjection<TTransform> ::SetZone(long zone) { - this->m_MapProjection->setZone(zone); + this->SetParameter("Zone", Utils::ConvertToString(zone)); this->Modified(); } @@ -38,7 +48,7 @@ template <TransformDirection::TransformationDirection TTransform> void UtmMapProjection<TTransform> ::SetHemisphere(char hemisphere) { - this->m_MapProjection->setHemisphere(hemisphere); + this->SetParameter("Hemisphere", Utils::ConvertToString(hemisphere)); this->Modified(); } @@ -46,14 +56,11 @@ template <TransformDirection::TransformationDirection TTransform> void UtmMapProjection<TTransform> ::SetZoneAndHemisphereFromGeoPoint(const InputPointType& geoPoint) { - char hemisphere; - - if (geoPoint[1] > 0.) hemisphere = 'N'; - else hemisphere = 'S'; - this->SetHemisphere(hemisphere); + if (geoPoint[1] > 0.) this->SetParameter("Hemisphere", "N"); + else this->SetParameter("Hemisphere", "S"); - int zone = this->GetZoneFromGeoPoint(geoPoint); - this->SetZone(zone); + int zone = Utils::GetZoneFromGeoPoint(geoPoint[0], geoPoint[1]); + this->SetParameter("Zone", Utils::ConvertToString(zone)); } ///\return the zone @@ -61,8 +68,7 @@ template <TransformDirection::TransformationDirection TTransform> int UtmMapProjection<TTransform> ::GetZone() const { - int zone = this->m_MapProjection->getZone(); - + int zone = atoi(this->GetParameter("Zone").c_str()); return zone; } @@ -71,7 +77,10 @@ template <TransformDirection::TransformationDirection TTransform> char UtmMapProjection<TTransform> ::GetHemisphere() const { - char hemisphere = this->m_MapProjection->getHemisphere(); + //If this happens, we have to better control the instanciation of + //the projection. + assert(this->GetParameter("Hemisphere").size() > 0); + char hemisphere = this->GetParameter("Hemisphere")[0]; return hemisphere; } @@ -80,11 +89,7 @@ template <TransformDirection::TransformationDirection TTransform> int UtmMapProjection<TTransform> ::GetZoneFromGeoPoint(const InputPointType& geoPoint) const { - //use ossim to handle the special case of UTM - ossimGpt point(geoPoint[1], geoPoint[0]); - int zone = this->m_MapProjection->computeZone(point); - - return zone; + return Utils::GetZoneFromGeoPoint(geoPoint[0], geoPoint[1]); } } diff --git a/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h b/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h index 89ae7bdcb18a0270d6588d9c5cd1bc1d3aa24779..5608881c42378b5091466dc6e0ff55c48cd0bfad 100644 --- a/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToCircularPolarisationImageFilter.h @@ -27,8 +27,21 @@ 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 diff --git a/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.h b/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.h index 984cb2d356c330c36827ba81fe39555e530b01d1..fb87074ac529385a97a36f2a04a2e13d3b6a9148 100644 --- a/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToCovarianceImageFilter.h @@ -30,16 +30,25 @@ namespace Functor { * \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$ + * 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. + * 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 returned output pixel have 6 channles. + * 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 diff --git a/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h b/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h index 5e434d0501b1e74650856e9eebd3d1080f3e1b6a..51e28279045d0ffd64f87782b3e7dd58a98b231f 100644 --- a/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h +++ b/Code/SARPolarimetry/otbMuellerToPolarisationDegreeAndPowerImageFilter.h @@ -34,6 +34,35 @@ 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 * @@ -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,7 +191,7 @@ 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) */ template <class TInputImage, class TOutputImage, class TFunction = Functor::MuellerToPolarisationDegreeAndPowerFunctor< 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..39977f8d2118219d9b7132d0c319048cba8b36e6 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 */ diff --git a/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h b/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h index 4ab3d2e9e4fcb6f2fc63ba8f970dbd8d4353be0c..f83fa46e82e8fdfb630d16ddb91d7780421e372d 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 diff --git a/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h b/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h index 65f6c95fabd9ff4cdec5a3c3c0a1bd33f466ab1e..85ad74e3fde5e082e0a5f68c8268140910fe1609 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 diff --git a/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h b/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.h index dde56ad11960624c6f0858aa488ab665cfd8b008..2712cacc4b248d814f012616f3acad6ce6c664e8 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; diff --git a/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h b/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h index 24e02335cbc683e0eb577012f1da76419a67a7aa..7fa9efaa1e51c4a70f2220360291f882eec6b71b 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 diff --git a/Code/SARPolarimetry/otbSinclairImageFilter.h b/Code/SARPolarimetry/otbSinclairImageFilter.h index 52b583b5f71068166bc1ef4868ffff2a3d872dca..ad58fec992ee0b581ff6426a335611426243b29c 100644 --- a/Code/SARPolarimetry/otbSinclairImageFilter.h +++ b/Code/SARPolarimetry/otbSinclairImageFilter.h @@ -26,12 +26,15 @@ 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. + * * \ingroup SARPolarimetry * * \sa SinclairImageFilter diff --git a/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h b/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h index 0da324822d685ef522a9dc7d0825783a82a865f6..ae40d45e9aca7699d6cea1908d6937140d72f51b 100644 --- a/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h +++ b/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.h @@ -32,6 +32,9 @@ namespace otb * 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. + * * \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/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/Examples/OBIA/CMakeLists.txt b/Examples/OBIA/CMakeLists.txt index a1ecb1171b4a556b59f961bb982c4e10be6bad22..ab6a226f6cc15a63ab0a41fc57cc481fce2be0e8 100644 --- a/Examples/OBIA/CMakeLists.txt +++ b/Examples/OBIA/CMakeLists.txt @@ -60,7 +60,7 @@ ADD_TEST(trTeOBIARadiometricAttributesLabelMapFilterTest ${EXE_TESTS} ${TEMP}/OBIARadiometricAttributes.tif ${TEMP}/qb_RoadExtract_Radiometry_pretty.png STATS::Band1::Mean - 0.0 + 0 0.5 16 16 diff --git a/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx b/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx index 613e0c2c94e89ce77300a542e2198a907c05c1b1..4cb0395f89aa2d3ea7e3cc478482b20c0b5046e8 100644 --- a/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx +++ b/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx @@ -74,7 +74,7 @@ int main(int argc, char * argv[]) const char * outfname = argv[2]; const char * outprettyfname = argv[3]; const char * attr = argv[4]; - double lowerThan = atof(argv[5]); + bool lowerThan = atoi(argv[5]); double thresh = atof(argv[6]); const unsigned int spatialRadius = atoi(argv[7]); diff --git a/Examples/Projections/MapProjectionExample.cxx b/Examples/Projections/MapProjectionExample.cxx index fc244b6cdd7c7602d5b070fb08d63929e0608607..b1487fa1643ccb7def1735f442d8971d0c1a4795 100644 --- a/Examples/Projections/MapProjectionExample.cxx +++ b/Examples/Projections/MapProjectionExample.cxx @@ -205,7 +205,7 @@ int main(int argc, char* argv[]) // Forward Lambert93 projection: // [1.4835345, 43.55968261] -> [577437.889798954, 6274578.791561] // - // Forward gerenic projection: + // Forward generic projection: // [1.4835345, 43.55968261] -> [377522.448427013, 4824086.71129131] // \end{verbatim} // 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/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index 9ac1d53a298c0bbd251c57eb44f2b30da0f37e6e..39fb5575cfee77c2fdf7a32fb6ca4bf2591bc292 100644 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -844,6 +844,10 @@ ADD_TEST(ioTvGDALImageFileWriterTIF2TIF ${IO_TESTS7} ${INPUTDATA}/poupeesTIF/IMAGERY.TIF ${TEMP}/poupees.tiff ) +ADD_TEST(ioTvGDALImageFileWriterTIF2RAS ${IO_TESTS7} + otbImageFileWriterRGBTest + ${INPUTDATA}/poupees.tif + ${TEMP}/poupees.ras ) # ------- otb::ImageFileReader pour GDAL ------------------------------ # ------- otb::ImageFileWriter pour GDAL ------------------------------ @@ -1606,6 +1610,16 @@ ADD_TEST(ioTvossimElevManagerTest2 ${IO_TESTS12} 500 ) +# otb::MapProjectionWrapper (TODO: remove from IO) +ADD_TEST(ioTvMapProjectionWrapperTest ${IO_TESTS12} + --compare-ascii ${EPSILON_9} + ${BASELINE_FILES}/ioTvMapProjectionWrapperTest.txt + ${TEMP}/ioTvMapProjectionWrapperTest.txt + otbMapProjectionWrapperTest + ${TEMP}/ioTvMapProjectionWrapperTest.txt +) + + # --- otb::DEMToOrthoImageGenerator --- ADD_TEST(ioTuDEMToOrthoImageGeneratorNew ${IO_TESTS12} @@ -3262,6 +3276,7 @@ otbDEMToImageGeneratorTest.cxx otbOssimElevManagerTest.cxx otbOssimElevManagerTest2.cxx otbOssimElevManagerTest4.cxx +otbMapProjectionWrapperTest.cxx otbDEMToOrthoImageGeneratorNew.cxx otbDEMToOrthoImageGeneratorTest.cxx otbDEMToOrthoImageGeneratorTest2.cxx diff --git a/Testing/Code/IO/otbIOTests12.cxx b/Testing/Code/IO/otbIOTests12.cxx index 9f74fb0570a81968526874d1f44f50434cdd85b2..1bf089d6593db9419797c5aed55c92cf6705eeeb 100644 --- a/Testing/Code/IO/otbIOTests12.cxx +++ b/Testing/Code/IO/otbIOTests12.cxx @@ -33,6 +33,7 @@ void RegisterTests() REGISTER_TEST(otbOssimElevManagerTest); REGISTER_TEST(otbOssimElevManagerTest2); REGISTER_TEST(otbOssimElevManagerTest4); + REGISTER_TEST(otbMapProjectionWrapperTest); REGISTER_TEST(otbDEMToOrthoImageGeneratorNew); REGISTER_TEST(otbDEMToOrthoImageGeneratorTest); REGISTER_TEST(otbDEMToOrthoImageGeneratorTest2); diff --git a/Testing/Code/IO/otbMapProjectionWrapperTest.cxx b/Testing/Code/IO/otbMapProjectionWrapperTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9318fbc0c5f5f3880e2dc923c75dea0c33e2c4bd --- /dev/null +++ b/Testing/Code/IO/otbMapProjectionWrapperTest.cxx @@ -0,0 +1,207 @@ +/*========================================================================= + + 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 <fstream> +#include <iomanip> + +#include "otbMapProjectionWrapper.h" + +int otbMapProjectionWrapperTest(int argc, char* argv[]) +{ + const char * outFileName = argv[1]; + std::ofstream file; + file.open(outFileName); + + file << std::setprecision(15); + + { + /** Test the ability to instanciate a projection from a wkt string*/ + std::string projectionRefWkt = + "PROJCS[\"UTM Zone 31, Northern Hemisphere\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\",\"9108\"]], AXIS[\"Lat\", NORTH], AXIS[\"Long\", EAST], AUTHORITY[\"EPSG\",\"4326\"]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 3], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000], PARAMETER[\"false_northing\", 0], UNIT[\"Meter\", 1]]"; + + otb::MapProjectionWrapper::Pointer genericMapProjection = otb::MapProjectionWrapper::New(); + genericMapProjection->SetWkt(projectionRefWkt); + file << "Instanciating from : " << projectionRefWkt << std::endl; + file << genericMapProjection->GetWkt() << std::endl << std::endl; + + double lon = 1.44; + double lat = 43.6050; + double h = 10; + double x = 0; + double y = 0; + double z = 0; + genericMapProjection->ForwardTransform(lon, lat, h, x, y, z); + file << "Forward projection: " << std::endl; + file << lon << ", " << lat << ", " << h << " -> "; + file << x << ", " << y << ", " << z; + file << std::endl << std::endl; + + genericMapProjection->InverseTransform(x, y, z, lon, lat, h); + file << "Inverse projection: " << std::endl; + file << x << ", " << y << ", " << z << " -> "; + file << lon << ", " << lat << ", " << h; + file << std::endl << std::endl; + } + + { + /** Test the ability to instanciate a projection from an ossim string*/ + std::string projectionRefWkt ="ossimUtmProjection"; + + otb::MapProjectionWrapper::Pointer genericMapProjection = otb::MapProjectionWrapper::New(); + genericMapProjection->SetWkt(projectionRefWkt); + file << "Instanciating from : " << projectionRefWkt << std::endl; + file << genericMapProjection->GetWkt() << std::endl << std::endl; + + double lon = 1.44; + double lat = 43.6050; + double h = 10; + double x = 0; + double y = 0; + double z = 0; + genericMapProjection->ForwardTransform(lon, lat, h, x, y, z); + file << "Forward projection: " << std::endl; + file << lon << ", " << lat << ", " << h << " -> "; + file << x << ", " << y << ", " << z; + file << std::endl << std::endl; + + genericMapProjection->InverseTransform(x, y, z, lon, lat, h); + file << "Inverse projection: " << std::endl; + file << x << ", " << y << ", " << z << " -> "; + file << lon << ", " << lat << ", " << h; + file << std::endl << std::endl; + } + + { + /** Test the ability to instanciate a projection from an short string*/ + std::string projectionRefWkt ="Utm"; + + otb::MapProjectionWrapper::Pointer genericMapProjection = otb::MapProjectionWrapper::New(); + genericMapProjection->SetWkt(projectionRefWkt); + file << "Instanciating from : " << projectionRefWkt << std::endl; + file << genericMapProjection->GetWkt() << std::endl << std::endl; + + double lon = 1.44; + double lat = 43.6050; + double h = 10; + double x = 0; + double y = 0; + double z = 0; + genericMapProjection->ForwardTransform(lon, lat, h, x, y, z); + file << "Forward projection: " << std::endl; + file << lon << ", " << lat << ", " << h << " -> "; + file << x << ", " << y << ", " << z; + file << std::endl << std::endl; + + genericMapProjection->InverseTransform(x, y, z, lon, lat, h); + file << "Inverse projection: " << std::endl; + file << x << ", " << y << ", " << z << " -> "; + file << lon << ", " << lat << ", " << h; + file << std::endl << std::endl; + } + + { + /** Test the ability to instanciate a projection from an short string*/ + std::string projectionRefWkt ="Mercator"; + + otb::MapProjectionWrapper::Pointer genericMapProjection = otb::MapProjectionWrapper::New(); + genericMapProjection->SetWkt(projectionRefWkt); + file << "Instanciating from : " << projectionRefWkt << std::endl; + file << genericMapProjection->GetWkt() << std::endl << std::endl; + + double lon = 1.44; + double lat = 43.6050; + double h = 10; + double x = 0; + double y = 0; + double z = 0; + genericMapProjection->ForwardTransform(lon, lat, h, x, y, z); + file << "Forward projection: " << std::endl; + file << lon << ", " << lat << ", " << h << " -> "; + file << x << ", " << y << ", " << z; + file << std::endl << std::endl; + + genericMapProjection->InverseTransform(x, y, z, lon, lat, h); + file << "Inverse projection: " << std::endl; + file << x << ", " << y << ", " << z << " -> "; + file << lon << ", " << lat << ", " << h; + file << std::endl << std::endl; + } + + { + /** Test the ability to instanciate a projection from an short string*/ + std::string projectionRefWkt ="LambertConformalConic"; + + otb::MapProjectionWrapper::Pointer genericMapProjection = otb::MapProjectionWrapper::New(); + genericMapProjection->SetWkt(projectionRefWkt); + file << "Instanciating from : " << projectionRefWkt << std::endl; + file << genericMapProjection->GetWkt() << std::endl << std::endl; + + double lon = 1.44; + double lat = 43.6050; + double h = 10; + double x = 0; + double y = 0; + double z = 0; + genericMapProjection->ForwardTransform(lon, lat, h, x, y, z); + file << "Forward projection: " << std::endl; + file << lon << ", " << lat << ", " << h << " -> "; + file << x << ", " << y << ", " << z; + file << std::endl << std::endl; + + genericMapProjection->InverseTransform(x, y, z, lon, lat, h); + file << "Inverse projection: " << std::endl; + file << x << ", " << y << ", " << z << " -> "; + file << lon << ", " << lat << ", " << h; + file << std::endl << std::endl; + } + + + { + /** Test the ability to instanciate an Utm projection in a different zone */ + std::string projectionRefWkt ="Utm"; + + otb::MapProjectionWrapper::Pointer genericMapProjection = otb::MapProjectionWrapper::New(); + genericMapProjection->SetWkt(projectionRefWkt); + genericMapProjection->SetParameter("Zone", "46"); + genericMapProjection->SetParameter("Hemisphere", "S"); + file << "Instanciating from : " << projectionRefWkt << " with some extra parameters" << std::endl; + file << genericMapProjection->GetWkt() << std::endl << std::endl; + + double lon = 91.44; + double lat = -43.6050; + double h = 10; + double x = 0; + double y = 0; + double z = 0; + genericMapProjection->ForwardTransform(lon, lat, h, x, y, z); + file << "Forward projection: " << std::endl; + file << lon << ", " << lat << ", " << h << " -> "; + file << x << ", " << y << ", " << z; + file << std::endl << std::endl; + + genericMapProjection->InverseTransform(x, y, z, lon, lat, h); + file << "Inverse projection: " << std::endl; + file << x << ", " << y << ", " << z << " -> "; + file << lon << ", " << lat << ", " << h; + file << std::endl << std::endl; + } + + + file.close(); + 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/Projections/otbGenericMapProjection.cxx b/Testing/Code/Projections/otbGenericMapProjection.cxx index fa14279087c1339fd25156bed8271a2dea9240c3..8ee5817e0b5f927b08394a7538cbd36d9e051e71 100644 --- a/Testing/Code/Projections/otbGenericMapProjection.cxx +++ b/Testing/Code/Projections/otbGenericMapProjection.cxx @@ -19,8 +19,6 @@ #include <fstream> #include <iomanip> -#include "otbMacro.h" -#include "otbImage.h" #include "otbGenericMapProjection.h" int otbGenericMapProjection(int argc, char* argv[]) diff --git a/Testing/Code/Projections/otbGenericMapProjectionNew.cxx b/Testing/Code/Projections/otbGenericMapProjectionNew.cxx index b798a54b50d582145f1006ccc39fd71c6d5db710..0cdead96facaf52ba876b426d8964ce8d55ef45f 100644 --- a/Testing/Code/Projections/otbGenericMapProjectionNew.cxx +++ b/Testing/Code/Projections/otbGenericMapProjectionNew.cxx @@ -31,7 +31,5 @@ int otbGenericMapProjectionNew(int argc, char* argv[]) typedef otb::GenericMapProjection<otb::TransformDirection::FORWARD> MapProjectionType; MapProjectionType::Pointer mapProjection = MapProjectionType::New(); - std::cout << mapProjection << std::endl; - return EXIT_SUCCESS; } diff --git a/Testing/Code/Projections/otbMapProjection.cxx b/Testing/Code/Projections/otbMapProjection.cxx index 9953bf368dc95d1e94d718046a8757beb766a471..b4f29e7c51910817918985823b798d9dd53d25f5 100644 --- a/Testing/Code/Projections/otbMapProjection.cxx +++ b/Testing/Code/Projections/otbMapProjection.cxx @@ -24,47 +24,97 @@ int otbMapProjection(int argc, char* argv[]) { const char * outFileName = argv[1]; std::ofstream file; + + itk::Point<double, 2> point; + point[0] = 1.44; + point[1] = 43.6050; + itk::Point<double, 2> point2; file.open(outFileName); + file << std::setprecision(15); /** Test the output of the projection in Wkt format*/ + otb::UtmForwardProjection::Pointer lUtmProjection2 = otb::UtmForwardProjection::New(); + point2 = lUtmProjection2->TransformPoint(point); + file << lUtmProjection2->GetWkt() << std::endl << std::endl; + file << "Forward projection: " << std::endl; + file << point << " -> "; + file << point2; + file << std::endl << std::endl; + + otb::UtmInverseProjection::Pointer lUtmProjection = otb::UtmInverseProjection::New(); file << lUtmProjection->GetWkt() << std::endl << std::endl; + file << "Inverse projection: " << std::endl; + file << point2 << " -> "; + file << lUtmProjection->TransformPoint(point2); + file << std::endl << std::endl; - otb::UtmForwardProjection::Pointer lUtmProjection2 = otb::UtmForwardProjection::New(); - file << lUtmProjection2->GetWkt() << std::endl << std::endl; + + otb::Lambert2EtenduForwardProjection::Pointer lLambert2Etendu2 = otb::Lambert2EtenduForwardProjection::New(); + point2 = lLambert2Etendu2->TransformPoint(point); + file << lLambert2Etendu2->GetWkt() << std::endl << std::endl; + file << "Forward projection: " << std::endl; + file << point << " -> "; + file << point2; + file << std::endl << std::endl; otb::Lambert2EtenduInverseProjection::Pointer lLambert2Etendu = otb::Lambert2EtenduInverseProjection::New(); file << lLambert2Etendu->GetWkt() << std::endl << std::endl; + file << "Inverse projection: " << std::endl; + file << point2 << " -> "; + file << lLambert2Etendu->TransformPoint(point2); + file << std::endl << std::endl; - otb::Lambert2EtenduForwardProjection::Pointer lLambert2Etendu2 = otb::Lambert2EtenduForwardProjection::New(); - file << lLambert2Etendu2->GetWkt() << std::endl << std::endl; + + otb::Lambert93ForwardProjection::Pointer lLambert93_2 = otb::Lambert93ForwardProjection::New(); + point2 = lLambert93_2->TransformPoint(point); + file << lLambert93_2->GetWkt() << std::endl << std::endl; + file << "Forward projection: " << std::endl; + file << point << " -> "; + file << point2; + file << std::endl << std::endl; otb::Lambert93InverseProjection::Pointer lLambert93 = otb::Lambert93InverseProjection::New(); file << lLambert93->GetWkt() << std::endl << std::endl; + file << "Inverse projection: " << std::endl; + file << point2 << " -> "; + file << lLambert93->TransformPoint(point2); + file << std::endl << std::endl; - otb::Lambert93ForwardProjection::Pointer lLambert93_2 = otb::Lambert93ForwardProjection::New(); - file << lLambert93_2->GetWkt() << std::endl << std::endl; - otb::MercatorInverseProjection::Pointer lMercatorProjection = otb::MercatorInverseProjection::New(); - file << lMercatorProjection->GetWkt() << std::endl << std::endl; otb::MercatorForwardProjection::Pointer lMercatorProjection2 = otb::MercatorForwardProjection::New(); + point2 = lMercatorProjection2->TransformPoint(point); file << lMercatorProjection2->GetWkt() << std::endl << std::endl; + file << "Forward projection: " << std::endl; + file << point << " -> "; + file << point2; + file << std::endl << std::endl; + + + otb::MercatorInverseProjection::Pointer lMercatorProjection = otb::MercatorInverseProjection::New(); + file << lMercatorProjection->GetWkt() << std::endl << std::endl; + file << "Inverse projection: " << std::endl; + file << point2 << " -> "; + file << lMercatorProjection->TransformPoint(point2); + file << std::endl << std::endl; + + // Moving to GenericMapProjection, change the access file << "\n\n *** Test accessors *** \n\n"; file << std::setprecision(15); - file << "Origin: \t" << lUtmProjection->Origin() << std::endl; - file << "False northing: \t" << lUtmProjection->GetFalseNorthing() << std::endl; - file << "False easting: \t" << lUtmProjection->GetFalseEasting() << std::endl; - file << "Parallel 1: \t" << lUtmProjection->GetStandardParallel1() << std::endl; - file << "Parallel 2: \t" << lUtmProjection->GetStandardParallel2() << std::endl; - file << "Name: \t" << lUtmProjection->GetProjectionName() << std::endl; - file << "Geo: \t" << lUtmProjection->IsGeographic() << std::endl; - file << "A: \t" << lUtmProjection->GetA() << std::endl; - file << "B: \t" << lUtmProjection->GetB() << std::endl; - file << "F: \t" << lUtmProjection->GetF() << std::endl; - file << "m per pix: \t" << lUtmProjection->GetMetersPerPixel() << std::endl; - file << "degree per pix: \t" << lUtmProjection->GetDecimalDegreesPerPixel() << std::endl; + file << "Origin: \t" << lUtmProjection->GetParameter("Origin") << std::endl; + file << "False northing: \t" << lUtmProjection->GetParameter("FalseNorthing") << std::endl; + file << "False easting: \t" << lUtmProjection->GetParameter("FalseEasting") << std::endl; + file << "Parallel 1: \t" << lUtmProjection->GetParameter("StandardParallel1") << std::endl; + file << "Parallel 2: \t" << lUtmProjection->GetParameter("StandardParallel2") << std::endl; +// file << "Name: \t" << lUtmProjection->GetProjectionName() << std::endl; +// file << "Geo: \t" << lUtmProjection->IsGeographic() << std::endl; + file << "A: \t" << lUtmProjection->GetParameter("A") << std::endl; + file << "B: \t" << lUtmProjection->GetParameter("B") << std::endl; + file << "F: \t" << lUtmProjection->GetParameter("F") << std::endl; + file << "m per pix: \t" << lUtmProjection->GetParameter("MetersPerPixel") << std::endl; + file << "degree per pix: \t" << lUtmProjection->GetParameter("DecimalDegreesPerPixel") << std::endl; file.close(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx index 79c312c5cbeaf8059a450909ebb6e24aa2c14a17..982b869b5ae80e44b08588c46ed9d8648ac1b121 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx @@ -28,8 +28,6 @@ #include "otbReciprocalHAlphaImageFilter.h" #include "otbSinclairReciprocalImageFilter.h" #include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" -#include "itkMeanImageFilter.h" -#include "otbPerBandVectorImageFilter.h" #include "otbMultiChannelExtractROI.h" int otbReciprocalHAlphaImageFilter(int argc, char * argv[]) @@ -59,10 +57,6 @@ int otbReciprocalHAlphaImageFilter(int argc, char * argv[]) 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; @@ -87,12 +81,8 @@ int otbReciprocalHAlphaImageFilter(int argc, char * argv[]) sinclairToCoherencyFilter->SetInputVH(reader3->GetOutput()); sinclairToCoherencyFilter->SetInputVV(reader4->GetOutput()); - PerBandMeanFilterType::Pointer perBandMeanFilter = PerBandMeanFilterType::New(); - perBandMeanFilter->SetInput(sinclairToCoherencyFilter->GetOutput()); - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(perBandMeanFilter->GetOutput()); - filter->SetNumberOfThreads(1); + filter->SetInput(sinclairToCoherencyFilter->GetOutput()); ExtractType::Pointer extract = ExtractType::New(); extract->SetInput(filter->GetOutput()); @@ -103,8 +93,6 @@ int otbReciprocalHAlphaImageFilter(int argc, char * argv[]) writer->SetFileName(outputFilename); writer->SetInput(extract->GetOutput()); - writer->SetNumberOfThreads(1); -writer->SetNumberOfStreamDivisions(1); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx b/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx index 084cb651eaa032ddd1b1c70417524eef4c698558..e4c34c330aad1d36906a41b8bb7a51541f0c0624 100644 --- a/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx @@ -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,7 +59,45 @@ int generic_SinclairImageFilter(int argc, char * argv[]) typedef otb::VectorImage<TOutputPixel> OutputImageType; typedef otb::ImageFileWriter<OutputImageType> WriterType; - generic_SinclairImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); + 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::ImageFileReader<InputImageType> ReaderType; + typedef otb::ExtractROI<TInputPixel, TInputPixel > 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(); + 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(); typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outputFilename); @@ -123,7 +118,45 @@ int generic_SinclairImageFilterWithCast(int argc, char * argv[]) typedef otb::ImageFileWriter<OutputRealImageType> WriterType; typedef typename otb::ComplexToVectorImageCastFilter<OutputImageType, OutputRealImageType> CasterType; - generic_SinclairImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); + 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::ImageFileReader<InputImageType> ReaderType; + typedef otb::ExtractROI<TInputPixel, TInputPixel > 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(); + 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(); typename WriterType::Pointer writer = WriterType::New(); typename CasterType::Pointer caster = CasterType::New(); 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/FLTK/fluid/Makefile b/Utilities/FLTK/fluid/Makefile-upstream similarity index 100% rename from Utilities/FLTK/fluid/Makefile rename to Utilities/FLTK/fluid/Makefile-upstream diff --git a/Utilities/FLTK/jpeg/Makefile b/Utilities/FLTK/jpeg/Makefile-upstream similarity index 100% rename from Utilities/FLTK/jpeg/Makefile rename to Utilities/FLTK/jpeg/Makefile-upstream diff --git a/Utilities/FLTK/png/Makefile b/Utilities/FLTK/png/Makefile-upstream similarity index 100% rename from Utilities/FLTK/png/Makefile rename to Utilities/FLTK/png/Makefile-upstream diff --git a/Utilities/FLTK/zlib/Makefile b/Utilities/FLTK/zlib/Makefile-upstream similarity index 100% rename from Utilities/FLTK/zlib/Makefile rename to Utilities/FLTK/zlib/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/Makefile b/Utilities/ITK/Utilities/nifti/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/Makefile rename to Utilities/ITK/Utilities/nifti/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/Testing/Makefile b/Utilities/ITK/Utilities/nifti/Testing/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/Testing/Makefile rename to Utilities/ITK/Utilities/nifti/Testing/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/examples/Makefile b/Utilities/ITK/Utilities/nifti/examples/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/examples/Makefile rename to Utilities/ITK/Utilities/nifti/examples/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/fsliolib/Makefile b/Utilities/ITK/Utilities/nifti/fsliolib/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/fsliolib/Makefile rename to Utilities/ITK/Utilities/nifti/fsliolib/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/nifticdf/Makefile b/Utilities/ITK/Utilities/nifti/nifticdf/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/nifticdf/Makefile rename to Utilities/ITK/Utilities/nifti/nifticdf/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/niftilib/Makefile b/Utilities/ITK/Utilities/nifti/niftilib/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/niftilib/Makefile rename to Utilities/ITK/Utilities/nifti/niftilib/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/utils/Makefile b/Utilities/ITK/Utilities/nifti/utils/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/utils/Makefile rename to Utilities/ITK/Utilities/nifti/utils/Makefile-upstream diff --git a/Utilities/ITK/Utilities/nifti/znzlib/Makefile b/Utilities/ITK/Utilities/nifti/znzlib/Makefile-upstream similarity index 100% rename from Utilities/ITK/Utilities/nifti/znzlib/Makefile rename to Utilities/ITK/Utilities/nifti/znzlib/Makefile-upstream diff --git a/Utilities/otb6S/libf2c/uninit.c b/Utilities/otb6S/libf2c/uninit.c index f15fe3913999d07dfbad219dfcf26f0ec6edd26c..8b06c5a6a0c38afd342a9daee7a50d62ec6860b0 100644 --- a/Utilities/otb6S/libf2c/uninit.c +++ b/Utilities/otb6S/libf2c/uninit.c @@ -183,8 +183,6 @@ ieee0(Void) /* code from Eric Grosse */ #include <stdlib.h> #include <stdio.h> -#include "/usr/include/sigfpe.h" /* full pathname for lcc -N */ -#include "/usr/include/sys/fpu.h" static void #ifdef KR_headers diff --git a/Utilities/otbliblas/Makefile b/Utilities/otbliblas/Makefile-upstream similarity index 100% rename from Utilities/otbliblas/Makefile rename to Utilities/otbliblas/Makefile-upstream diff --git a/Utilities/otbliblas/apps/Makefile b/Utilities/otbliblas/apps/Makefile-upstream similarity index 100% rename from Utilities/otbliblas/apps/Makefile rename to Utilities/otbliblas/apps/Makefile-upstream diff --git a/Utilities/otbliblas/doc/Makefile b/Utilities/otbliblas/doc/Makefile-upstream similarity index 100% rename from Utilities/otbliblas/doc/Makefile rename to Utilities/otbliblas/doc/Makefile-upstream diff --git a/Utilities/otbliblas/src/Makefile b/Utilities/otbliblas/src/Makefile-upstream similarity index 100% rename from Utilities/otbliblas/src/Makefile rename to Utilities/otbliblas/src/Makefile-upstream diff --git a/Utilities/otbliblas/test/Makefile b/Utilities/otbliblas/test/Makefile-upstream similarity index 100% rename from Utilities/otbliblas/test/Makefile rename to Utilities/otbliblas/test/Makefile-upstream diff --git a/Utilities/otbliblas/test/unit/Makefile b/Utilities/otbliblas/test/unit/Makefile-upstream similarity index 100% rename from Utilities/otbliblas/test/unit/Makefile rename to Utilities/otbliblas/test/unit/Makefile-upstream diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Makefile b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Makefile-upstream similarity index 100% rename from Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Makefile rename to Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Makefile-upstream 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/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 diff --git a/Utilities/otbsiftfast/Makefile b/Utilities/otbsiftfast/Makefile-upstream similarity index 100% rename from Utilities/otbsiftfast/Makefile rename to Utilities/otbsiftfast/Makefile-upstream