From ae6a2a0a138cffdab0c9666247ef1e11d5a05e58 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@c-s.fr>
Date: Wed, 20 Dec 2006 18:39:05 +0000
Subject: [PATCH] Premier commit pour les transfoms LogPolaire. Le dernier test
 est en erreur.

---
 .../otbInverseLogPolarTransform.h             | 114 +++++++++++++
 .../otbInverseLogPolarTransform.txx           | 159 ++++++++++++++++++
 Code/BasicFilters/otbLogPolarTransform.h      | 114 +++++++++++++
 Code/BasicFilters/otbLogPolarTransform.txx    | 151 +++++++++++++++++
 Testing/Code/BasicFilters/CMakeLists.txt      |  36 ++++
 .../BasicFilters/otbBasicFiltersTests.cxx     |   5 +
 .../otbInverseLogPolarTransform.cxx           |  96 +++++++++++
 .../otbInverseLogPolarTransformNew.cxx        |  55 ++++++
 .../BasicFilters/otbLogPolarTransform.cxx     |  95 +++++++++++
 .../BasicFilters/otbLogPolarTransformNew.cxx  |  55 ++++++
 10 files changed, 880 insertions(+)
 create mode 100644 Code/BasicFilters/otbInverseLogPolarTransform.h
 create mode 100644 Code/BasicFilters/otbInverseLogPolarTransform.txx
 create mode 100644 Code/BasicFilters/otbLogPolarTransform.h
 create mode 100644 Code/BasicFilters/otbLogPolarTransform.txx
 create mode 100644 Testing/Code/BasicFilters/otbInverseLogPolarTransform.cxx
 create mode 100644 Testing/Code/BasicFilters/otbInverseLogPolarTransformNew.cxx
 create mode 100644 Testing/Code/BasicFilters/otbLogPolarTransform.cxx
 create mode 100644 Testing/Code/BasicFilters/otbLogPolarTransformNew.cxx

diff --git a/Code/BasicFilters/otbInverseLogPolarTransform.h b/Code/BasicFilters/otbInverseLogPolarTransform.h
new file mode 100644
index 0000000000..ad9d47e42d
--- /dev/null
+++ b/Code/BasicFilters/otbInverseLogPolarTransform.h
@@ -0,0 +1,114 @@
+/*=========================================================================
+
+  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 _otbInverseLogPolarTransform_h
+#define _otbInverseLogPolarTransform_h
+
+#include "itkTransform.h"
+
+namespace otb
+{
+  /** \class InverseLogPolarTransform
+   * \brief
+   *
+   */
+
+template <class TScalarType>
+class ITK_EXPORT InverseLogPolarTransform
+  : public itk::Transform<TScalarType,2,2>
+  {
+  public:
+    /** Standard typedef */
+    typedef InverseLogPolarTransform Self;
+    typedef itk::Transform<TScalarType,2,2> Superclass;
+    typedef itk::SmartPointer<Self> Pointer;
+    typedef itk::SmartPointer<const Self> ConstPointer;
+    /** Creation through object factory */
+    itkNewMacro(Self);
+    /** Runtime information */
+    itkTypeMacro(InverseLogPolarTransform,Transform);
+
+    /** Template related typedefs */
+    typedef TScalarType ScalarType;
+
+    /** Superclass related typedefs */
+    typedef typename Superclass::InputPointType InputPointType;
+    typedef typename Superclass::OutputPointType OutputPointType;
+    typedef typename Superclass::InputVectorType InputVectorType;
+    typedef typename Superclass::OutputVectorType OutputVectorType;
+    typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
+    typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
+    typedef typename Superclass::ParametersType ParametersType;
+    typedef itk::FixedArray<TScalarType,2> ScaleType;
+
+    /** Set/Get the origin */
+    itkSetMacro(Center,InputPointType);
+    itkGetConstReferenceMacro(Center,InputPointType);
+
+    /** Set/Get the scales */
+    itkSetMacro(Scale,ScaleType);
+    itkGetConstReferenceMacro(Scale,ScaleType);
+    /**
+     * Set the transform parameters through the standard interface.
+     * \param parameters The parameters of the transform.
+     */
+    void SetParameters(const ParametersType &parameters);
+    /**
+     * Get the transform parameters through the standard interface.
+     * \return The parameters of the transform.
+     */
+     ParametersType& GetParameters(void) const;
+    /**
+     * Transform a point.
+     * \param point The point to transform.
+     * \return The transformed point.
+     */
+    OutputPointType TransformPoint(const InputPointType &point);
+    /**
+     * Transform a vector representing a point.
+     * \param vector The point to transform.
+     * \return The transformed point.
+     */
+    OutputVectorType TransformVector(const InputVectorType &vector);
+    /**
+     * Transform a vnl vector representing a point.
+     * \param vector The point to transform.
+     * \return The transformed point.
+     */
+    OutputVnlVectorType TransformVector(const InputVnlVectorType &vector);
+
+  protected:
+    /** Constructor */
+    InverseLogPolarTransform();
+    /** Destructor */
+    ~InverseLogPolarTransform();
+    /** PrintSelf method */
+    void PrintSelf(std::ostream &os,itk::Indent indent) const;
+
+  private:
+    InverseLogPolarTransform(const Self&); // purposely not implemented
+    void operator=(const Self&); // purposely not implemented
+  
+    InputPointType m_Center;
+    ScaleType m_Scale;
+  };
+}// end namespace otb
+#ifndef OTB_MANUAL_INSTANTIATION
+#include "otbInverseLogPolarTransform.txx"
+#endif
+
+#endif
diff --git a/Code/BasicFilters/otbInverseLogPolarTransform.txx b/Code/BasicFilters/otbInverseLogPolarTransform.txx
new file mode 100644
index 0000000000..e08a1baa53
--- /dev/null
+++ b/Code/BasicFilters/otbInverseLogPolarTransform.txx
@@ -0,0 +1,159 @@
+/*=========================================================================
+
+  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 _otbInverseLogPolarTransform_txx
+#define _otbInverseLogPolarTransform_txx
+
+#include "otbInverseLogPolarTransform.h"
+#include "otbMacro.h"
+
+namespace otb
+{
+/**
+ * Constructor.
+ */
+template <class TScalarType>
+InverseLogPolarTransform<TScalarType>
+::InverseLogPolarTransform()
+  :Superclass(2,4)
+{
+  m_Center[0]=0.0;
+  m_Center[1]=0.0;
+  m_Scale[0]=1.0;
+  m_Scale[1]=1.0;
+}
+/**
+ * Destructor.
+ */
+template <class TScalarType>
+InverseLogPolarTransform<TScalarType>
+::~InverseLogPolarTransform()
+{}
+/**
+ * Set the transform parameters through the standard interface.
+ * \param parameters The parameters of the transform.
+  */
+template <class TScalarType>
+void
+InverseLogPolarTransform<TScalarType>
+::SetParameters(const ParametersType &parameters)
+{
+  m_Center[0]=parameters[0];
+  m_Center[1]=parameters[1];
+  m_Scale[0] =parameters[2];
+  m_Scale[1] =parameters[3];
+  otbMsgDebugMacro(<<"Call To SetParameters: Center="<<m_Center<<", Scale="<<m_Scale);
+  this->m_Parameters=parameters;
+  this->Modified();
+}
+/**
+ * Get the transform parameters through the standard interface.
+ * \return The parameters of the transform.
+ */
+template <class TScalarType>
+typename InverseLogPolarTransform<TScalarType>
+::ParametersType&
+InverseLogPolarTransform<TScalarType>
+::GetParameters(void) const
+{
+  // Filling parameters vector
+  this->m_Parameters[0]=m_Center[0];
+  this->m_Parameters[1]=m_Center[1];
+  this->m_Parameters[2]=m_Scale[0];
+  this->m_Parameters[3]=m_Scale[1];
+  
+  return this->m_Parameters;
+}
+
+/**
+ * Transform a point.
+ * \param point The point to transform.
+ * \return The transformed point.
+ */
+template <class TScalarType>
+typename InverseLogPolarTransform<TScalarType>
+::OutputPointType
+ InverseLogPolarTransform<TScalarType>
+::TransformPoint(const InputPointType &point)
+{
+  OutputPointType result;
+  result[0]=0;
+  result[1]=0;
+  if((point[0]-m_Center[0]!=0)&&(point[1]-m_Center[1]!=0))
+    {
+      result[0]=(1/m_Scale[0])*asin((point[1]-m_Center[1])/sqrt(pow(point[0]-m_Center[0],2)+pow(point[1]-m_Center[1],2)));
+      result[1]=(1/2*m_Scale[1])*log(sqrt(pow(point[0]-m_Center[0],2)+pow(point[1]-m_Center[1],2)));
+    }
+  return result;
+}
+/**
+ * Transform a vector representing a point.
+ * \param vector The point to transform.
+ * \return The transformed point.
+ */
+template <class TScalarType>
+typename InverseLogPolarTransform<TScalarType>
+::OutputVectorType
+InverseLogPolarTransform<TScalarType>
+::TransformVector(const InputVectorType &vector)
+{
+  OutputVectorType result;
+  result[0]=0;
+  result[1]=0;
+  if((vector[0]!=0)&&(vector[1]!=0))
+    {
+      result[0]=(1/m_Scale[0])*asin((vector[1])/sqrt(pow(vector[0],2)+pow(vector[1],2)));
+      result[1]=(1/2*m_Scale[1])*log(sqrt(pow(vector[0],2)+pow(vector[1],2)));
+    }
+  return result;
+}
+/**
+ * Transform a vnl vector representing a point.
+ * \param vector The point to transform.
+ * \return The transformed point.
+ */  
+template <class TScalarType>
+typename InverseLogPolarTransform<TScalarType>
+::OutputVnlVectorType
+InverseLogPolarTransform<TScalarType>
+::TransformVector(const InputVnlVectorType &vector)
+{
+  OutputVnlVectorType result;
+  result[0]=0;
+  result[1]=0;
+  if((vector[0]!=0)&&(vector[1]!=0))
+    {
+      result[0]=(1/m_Scale[0])*asin((vector[1])/sqrt(pow(vector[0],2)+pow(vector[1],2)));
+      result[1]=(1/2*m_Scale[1])*log(sqrt(pow(vector[0],2)+pow(vector[1],2)));
+    }
+  return result;
+}
+/**
+ * PrintSelf method.
+ */
+template <class TScalarType>
+void
+InverseLogPolarTransform<TScalarType>
+::PrintSelf(std::ostream &os,itk::Indent indent) const
+{
+  Superclass::PrintSelf(os,indent);
+  os<<indent<<"Center: "<<m_Center<<std::endl;
+  os<<indent<<"Scale: "<<m_Scale<<std::endl;
+}
+
+} // end namespace otb
+#endif
diff --git a/Code/BasicFilters/otbLogPolarTransform.h b/Code/BasicFilters/otbLogPolarTransform.h
new file mode 100644
index 0000000000..74d0b571d8
--- /dev/null
+++ b/Code/BasicFilters/otbLogPolarTransform.h
@@ -0,0 +1,114 @@
+/*=========================================================================
+
+  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 _otbLogPolarTransform_h
+#define _otbLogPolarTransform_h
+
+#include "itkTransform.h"
+
+namespace otb
+{
+  /** \class LogPolarTransform
+   * \brief
+   *
+   */
+
+template <class TScalarType>
+class ITK_EXPORT LogPolarTransform
+  : public itk::Transform<TScalarType,2,2>
+  {
+  public:
+    /** Standard typedef */
+    typedef LogPolarTransform Self;
+    typedef itk::Transform<TScalarType,2,2> Superclass;
+    typedef itk::SmartPointer<Self> Pointer;
+    typedef itk::SmartPointer<const Self> ConstPointer;
+    /** Creation through object factory */
+    itkNewMacro(Self);
+    /** Runtime information */
+    itkTypeMacro(LogPolarTransform,Transform);
+
+    /** Template related typedefs */
+    typedef TScalarType ScalarType;
+
+    /** Superclass related typedefs */
+    typedef typename Superclass::InputPointType InputPointType;
+    typedef typename Superclass::OutputPointType OutputPointType;
+    typedef typename Superclass::InputVectorType InputVectorType;
+    typedef typename Superclass::OutputVectorType OutputVectorType;
+    typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
+    typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
+    typedef typename Superclass::ParametersType ParametersType;
+    typedef itk::FixedArray<TScalarType,2> ScaleType;
+
+    /** Set/Get the origin */
+    itkSetMacro(Center,InputPointType);
+    itkGetConstReferenceMacro(Center,InputPointType);
+
+    /** Set/Get the scales */
+    itkSetMacro(Scale,ScaleType);
+    itkGetConstReferenceMacro(Scale,ScaleType);
+    /**
+     * Set the transform parameters through the standard interface.
+     * \param parameters The parameters of the transform.
+     */
+    void SetParameters(const ParametersType &parameters);
+    /**
+     * Get the transform parameters through the standard interface.
+     * \return The parameters of the transform.
+     */
+     ParametersType& GetParameters(void) const;
+    /**
+     * Transform a point.
+     * \param point The point to transform.
+     * \return The transformed point.
+     */
+    OutputPointType TransformPoint(const InputPointType &point);
+    /**
+     * Transform a vector representing a point.
+     * \param vector The point to transform.
+     * \return The transformed point.
+     */
+    OutputVectorType TransformVector(const InputVectorType &vector);
+    /**
+     * Transform a vnl vector representing a point.
+     * \param vector The point to transform.
+     * \return The transformed point.
+     */
+    OutputVnlVectorType TransformVector(const InputVnlVectorType &vector);
+
+  protected:
+    /** Constructor */
+    LogPolarTransform();
+    /** Destructor */
+    ~LogPolarTransform();
+    /** PrintSelf method */
+    void PrintSelf(std::ostream &os,itk::Indent indent) const;
+
+  private:
+    LogPolarTransform(const Self&); // purposely not implemented
+    void operator=(const Self&); // purposely not implemented
+  
+    InputPointType m_Center;
+    ScaleType m_Scale;
+  };
+}// end namespace otb
+#ifndef OTB_MANUAL_INSTANTIATION
+#include "otbLogPolarTransform.txx"
+#endif
+
+#endif
diff --git a/Code/BasicFilters/otbLogPolarTransform.txx b/Code/BasicFilters/otbLogPolarTransform.txx
new file mode 100644
index 0000000000..fe498d4c78
--- /dev/null
+++ b/Code/BasicFilters/otbLogPolarTransform.txx
@@ -0,0 +1,151 @@
+/*=========================================================================
+
+  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 _otbLogPolarTransform_txx
+#define _otbLogPolarTransform_txx
+
+#include "otbLogPolarTransform.h"
+#include "otbMacro.h"
+
+namespace otb
+{
+/**
+ * Constructor.
+ */
+template <class TScalarType>
+LogPolarTransform<TScalarType>
+::LogPolarTransform()
+  :Superclass(2,4)
+{
+  m_Center[0]=0.0;
+  m_Center[1]=0.0;
+  m_Scale[0]=1.0;
+  m_Scale[1]=1.0;
+}
+/**
+ * Destructor.
+ */
+template <class TScalarType>
+LogPolarTransform<TScalarType>
+::~LogPolarTransform()
+{}
+/**
+ * Set the transform parameters through the standard interface.
+ * \param parameters The parameters of the transform.
+  */
+template <class TScalarType>
+void
+LogPolarTransform<TScalarType>
+::SetParameters(const ParametersType &parameters)
+{
+  m_Center[0]=parameters[0];
+  m_Center[1]=parameters[1];
+  m_Scale[0] =parameters[2];
+  m_Scale[1] =parameters[3];
+  otbMsgDebugMacro(<<"Call To SetParameters: Center="<<m_Center<<", Scale="<<m_Scale);
+  this->m_Parameters=parameters;
+  this->Modified();
+}
+/**
+ * Get the transform parameters through the standard interface.
+ * \return The parameters of the transform.
+ */
+template <class TScalarType>
+typename LogPolarTransform<TScalarType>
+::ParametersType&
+LogPolarTransform<TScalarType>
+::GetParameters(void) const
+{
+  // Filling parameters vector
+  this->m_Parameters[0]=m_Center[0];
+  this->m_Parameters[1]=m_Center[1];
+  this->m_Parameters[2]=m_Scale[0];
+  this->m_Parameters[3]=m_Scale[1];
+  
+  return this->m_Parameters;
+}
+
+/**
+ * Transform a point.
+ * \param point The point to transform.
+ * \return The transformed point.
+ */
+template <class TScalarType>
+typename LogPolarTransform<TScalarType>
+::OutputPointType
+ LogPolarTransform<TScalarType>
+::TransformPoint(const InputPointType &point)
+{
+  double Theta = point[0]*m_Scale[0]*acos(-1.0)/180.0;
+  double Rho   = point[1]*m_Scale[1];
+  OutputPointType result;
+  result[0]=exp(Rho) * cos(Theta)+m_Center[0];
+  result[1]=exp(Rho) * sin(Theta)+m_Center[1];
+  return result;
+}
+/**
+ * Transform a vector representing a point.
+ * \param vector The point to transform.
+ * \return The transformed point.
+ */
+template <class TScalarType>
+typename LogPolarTransform<TScalarType>
+::OutputVectorType
+LogPolarTransform<TScalarType>
+::TransformVector(const InputVectorType &vector)
+{
+
+  double Theta = vector[0]*m_Scale[0]*acos(-1.0)/180.0;
+  double Rho   = vector[1]*m_Scale[1];
+  OutputVectorType result;
+  result[0]=exp(Rho) * cos(Theta);
+  result[1]=exp(Rho) * sin(Theta);
+  return result;
+}
+/**
+ * Transform a vnl vector representing a point.
+ * \param vector The point to transform.
+ * \return The transformed point.
+ */  
+template <class TScalarType>
+typename LogPolarTransform<TScalarType>
+::OutputVnlVectorType
+LogPolarTransform<TScalarType>
+::TransformVector(const InputVnlVectorType &vector)
+{
+  double Theta = vector[0]*m_Scale[0]*acos(-1.0)/180.0;
+  double Rho   = vector[1]*m_Scale[1];
+  OutputVnlVectorType result;
+  result[0]=exp(Rho) * cos(Theta);
+  result[1]=exp(Rho) * sin(Theta);
+  return result;
+}
+/**
+ * PrintSelf method.
+ */
+template <class TScalarType>
+void
+LogPolarTransform<TScalarType>
+::PrintSelf(std::ostream &os,itk::Indent indent) const
+{
+  Superclass::PrintSelf(os,indent);
+  os<<indent<<"Center: "<<m_Center<<std::endl;
+  os<<indent<<"Scale: "<<m_Scale<<std::endl;
+}
+
+} // end namespace otb
+#endif
diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt
index 042e7d0837..29b1cb7ec3 100755
--- a/Testing/Code/BasicFilters/CMakeLists.txt
+++ b/Testing/Code/BasicFilters/CMakeLists.txt
@@ -105,6 +105,37 @@ ADD_TEST(bfTvBoundingRegionCalculator ${BASICFILTERS_TESTS}
 	${INPUTDATA}/rcc8_mire4.png
 	)
 
+# -------            otb::LogPolarTransform   ----------------------------
+
+ADD_TEST(bfTuLogPolarTransformNew ${BASICFILTERS_TESTS}  
+         otbLogPolarTransformNew)
+
+ADD_TEST(bfTvLogPolarTransform ${BASICFILTERS_TESTS}
+        otbLogPolarTransform
+	1 1 6 0 0 10 20 45 60 3.14 3.14 1 0 0 1
+	)
+
+ADD_TEST(bfTvLogPolarTransformResample ${BASICFILTERS_TESTS}  
+  --compare-image ${TOL}  ${BASELINE}/bfLogPolarResampleImageFilter.hdr
+                          ${TEMP}/bfLogPolarResampleOutput.hdr 
+        otbLogPolarTransformResample
+        ${INPUTDATA}/DeuxCercles.hdr
+	${TEMP}/bfLogPolarResampleOutput.hdr
+        1.0 1.0	
+)
+
+
+# -------            otb::InverseLogPolarTransform   ----------------------------
+
+ADD_TEST(bfTuInverseLogPolarTransformNew ${BASICFILTERS_TESTS}  
+         otbInverseLogPolarTransformNew)
+
+ADD_TEST(bfTvInverseLogPolarTransform ${BASICFILTERS_TESTS}
+        otbInverseLogPolarTransform
+	1 1 6 0 0 10 20 45 60 3.14 3.14 1 0 0 1
+	)
+
+
 # A enrichir
 SET(BasicFilters_SRCS
 otbLeeFilter.cxx
@@ -120,6 +151,11 @@ otbClosingOpeningMorphologicalFilterNew.cxx
 otbClosingOpeningMorphologicalFilter.cxx
 otbBinaryImageMinimalBoundingRegionCalculatorNew.cxx
 otbBinaryImageMinimalBoundingRegionCalculator.cxx
+otbLogPolarTransformNew.cxx
+otbLogPolarTransform.cxx
+otbLogPolarTransformResample.cxx
+otbInverseLogPolarTransformNew.cxx
+otbInverseLogPolarTransform.cxx
 )
 
 
diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx
index a124fa8a1f..7b87ed77b6 100755
--- a/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx
+++ b/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx
@@ -40,4 +40,9 @@ REGISTER_TEST(otbClosingOpeningMorphologicalFilterNew);
 REGISTER_TEST(otbClosingOpeningMorphologicalFilter);
 REGISTER_TEST(otbBinaryImageMinimalBoundingRegionCalculatorNew);
 REGISTER_TEST(otbBinaryImageMinimalBoundingRegionCalculator);
+REGISTER_TEST(otbLogPolarTransformNew);
+REGISTER_TEST(otbLogPolarTransform);
+REGISTER_TEST(otbLogPolarTransformResample);
+REGISTER_TEST(otbInverseLogPolarTransformNew);
+REGISTER_TEST(otbInverseLogPolarTransform);
 }
diff --git a/Testing/Code/BasicFilters/otbInverseLogPolarTransform.cxx b/Testing/Code/BasicFilters/otbInverseLogPolarTransform.cxx
new file mode 100644
index 0000000000..92901b7d49
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbInverseLogPolarTransform.cxx
@@ -0,0 +1,96 @@
+/*=========================================================================
+
+  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 "otbInverseLogPolarTransform.h"
+#include "otbMacro.h"
+
+int otbInverseLogPolarTransform(int argc, char* argv[])
+{
+try
+  {
+    double radialStep = atof(argv[1]);
+    double angularStep = atof(argv[2]);
+    unsigned int nbPoints = atoi(argv[3]);
+
+    typedef double PrecisionType;
+    typedef otb::InverseLogPolarTransform<PrecisionType> InverseLogPolarTransformType;
+    typedef itk::Point<PrecisionType,2> PointType;
+    typedef std::vector<PointType> PointsVectorType;
+    // input points retrieval
+    PointsVectorType vect;
+    for(unsigned int i=0;i<nbPoints;++i)
+      {
+	PointType p;
+	p[0]=atof(argv[4+2*i]);
+	p[1]=atof(argv[5+2*i]);
+	std::cout<<"Adding point "<<p<<"."<<std::endl;
+	vect.push_back(p);
+      }
+    // Instantiation
+    InverseLogPolarTransformType::Pointer transform = InverseLogPolarTransformType::New();
+    InverseLogPolarTransformType::ParametersType params(4);
+    params[0]=0.;
+    params[1]=0.;
+    params[2]=radialStep;
+    params[3]=angularStep;
+    transform->SetParameters(params);
+
+    for(PointsVectorType::iterator it=vect.begin();it!=vect.end();++it)
+      {
+	PointType p = transform->TransformPoint(*it);
+	PointType pprime;
+	if(((*it)[0]==0)&&((*it)[0]==0))
+	  {
+	    pprime.Fill(0);
+	  }
+	else
+	  {
+	    pprime[0]=(1/angularStep)*asin((*it)[1]/sqrt((*it)[0]*(*it)[0]+(*it)[1]*(*it)[1]));
+	    pprime[1]=(1/2*radialStep)*log((*it)[0]*(*it)[0]+(*it)[1]*(*it)[1]);
+	  }
+
+	std::cout<<"Original Point: "<<(*it)<<", Reference point: "<<pprime<<", Transformed point: "<<p<<std::endl;
+	otbControlConditionTestMacro(p[0]!=pprime[0],"Error while transforming point.");
+	otbControlConditionTestMacro(p[1]!=pprime[1],"Error while transforming point.");
+      }
+  }
+catch( itk::ExceptionObject & err ) 
+  { 
+    std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; 
+    std::cout << err << std::endl; 
+    return EXIT_FAILURE;
+  } 
+catch( ... ) 
+  { 
+    std::cout << "Unknown exception thrown !" << std::endl; 
+    return EXIT_FAILURE;
+  } 
+ return EXIT_SUCCESS;
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/Testing/Code/BasicFilters/otbInverseLogPolarTransformNew.cxx b/Testing/Code/BasicFilters/otbInverseLogPolarTransformNew.cxx
new file mode 100644
index 0000000000..32448504dd
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbInverseLogPolarTransformNew.cxx
@@ -0,0 +1,55 @@
+/*=========================================================================
+
+  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 "otbInverseLogPolarTransform.h"
+
+int otbInverseLogPolarTransformNew(int argc, char* argv[])
+{
+try
+  {
+    typedef double PrecisionType;
+    typedef otb::InverseLogPolarTransform<PrecisionType> InverseLogPolarTransformType;
+  
+    // Instantiation
+    InverseLogPolarTransformType::Pointer transform = InverseLogPolarTransformType::New();
+  }
+catch( itk::ExceptionObject & err ) 
+  { 
+    std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; 
+    std::cout << err << std::endl; 
+    return EXIT_FAILURE;
+  } 
+catch( ... ) 
+  { 
+    std::cout << "Unknown exception thrown !" << std::endl; 
+    return EXIT_FAILURE;
+  } 
+ return EXIT_SUCCESS;
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/Testing/Code/BasicFilters/otbLogPolarTransform.cxx b/Testing/Code/BasicFilters/otbLogPolarTransform.cxx
new file mode 100644
index 0000000000..ee53f5fcc3
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbLogPolarTransform.cxx
@@ -0,0 +1,95 @@
+/*=========================================================================
+
+  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 "otbLogPolarTransform.h"
+#include "itkPoint.h"
+#include "otbMacro.h"
+
+int otbLogPolarTransform(int argc, char* argv[])
+{
+try
+  {
+    double radialStep = atof(argv[1]);
+    double angularStep = atof(argv[2]);
+    unsigned int nbPoints = atoi(argv[3]);
+    typedef double PrecisionType;
+    typedef otb::LogPolarTransform<PrecisionType> LogPolarTransformType;
+    typedef itk::Point<PrecisionType,2> PointType;
+    typedef std::vector<PointType> PointsVectorType;
+
+    // input points retrieval
+    PointsVectorType vect;
+    for(unsigned int i=0;i<nbPoints;++i)
+      {
+	PointType p;
+	p[0]=atof(argv[4+2*i]);
+	p[1]=atof(argv[5+2*i]);
+	std::cout<<"Adding point "<<p<<"."<<std::endl;
+	vect.push_back(p);
+      }
+
+    // Instantiation
+    LogPolarTransformType::Pointer transform = LogPolarTransformType::New();
+    LogPolarTransformType::ParametersType params(4);
+    params[0]=0.;
+    params[1]=0.;
+    params[2]=radialStep;
+    params[3]=angularStep;
+    transform->SetParameters(params);
+
+	for(PointsVectorType::iterator it=vect.begin();it!=vect.end();++it)
+	  {
+	    PointType p = transform->TransformPoint(*it);
+	    
+	    PointType pprime;
+
+	    double Theta = (*it)[0]*angularStep*acos(-1.0)/180.0;
+	    double Rho   = (*it)[1]*radialStep;
+	    pprime[0]=exp(Rho) * cos(Theta);
+	    pprime[1]=exp(Rho) * sin(Theta);
+
+	    std::cout<<"Original Point: "<<(*it)<<", Reference point: "<<pprime<<", Transformed point: "<<p<<std::endl;
+	    otbControlConditionTestMacro(p[0]!=pprime[0],"Error while transforming point.");
+	    otbControlConditionTestMacro(p[1]!=pprime[1],"Error while transforming point.");
+	  }
+  }
+catch( itk::ExceptionObject & err ) 
+  { 
+    std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; 
+    std::cout << err << std::endl; 
+    return EXIT_FAILURE;
+  } 
+catch( ... ) 
+  { 
+    std::cout << "Unknown exception thrown !" << std::endl; 
+    return EXIT_FAILURE;
+  } 
+ return EXIT_SUCCESS;
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/Testing/Code/BasicFilters/otbLogPolarTransformNew.cxx b/Testing/Code/BasicFilters/otbLogPolarTransformNew.cxx
new file mode 100644
index 0000000000..df03109be6
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbLogPolarTransformNew.cxx
@@ -0,0 +1,55 @@
+/*=========================================================================
+
+  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 "otbLogPolarTransform.h"
+
+int otbLogPolarTransformNew(int argc, char* argv[])
+{
+try
+  {
+    typedef double PrecisionType;
+    typedef otb::LogPolarTransform<PrecisionType> LogPolarTransformType;
+  
+    // Instantiation
+    LogPolarTransformType::Pointer transform = LogPolarTransformType::New();
+  }
+catch( itk::ExceptionObject & err ) 
+  { 
+    std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; 
+    std::cout << err << std::endl; 
+    return EXIT_FAILURE;
+  } 
+catch( ... ) 
+  { 
+    std::cout << "Unknown exception thrown !" << std::endl; 
+    return EXIT_FAILURE;
+  } 
+ return EXIT_SUCCESS;
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
-- 
GitLab