Commits

Rashad M committed 73b8dce

updating Colorspace functors

Comments (0)

Files changed (9)

Applications/ContrastEnhancement/CMakeLists.txt

                        SOURCES        otbColorHistogramEqualize.cxx
                        LINK_LIBRARIES OTBIO;OTBCommon;OTBContrastEnhancementFilters)
 
-
-#OTB_CREATE_APPLICATION(NAME FindPixelType 
-#                      SOURCES FindPixelType.cxx
-#                       LINK_LIBRARIES OTBIO;OTBCommon)
-                       
-
+OTB_CREATE_APPLICATION(NAME           GammaCorrection
+                       SOURCES        otbGammaCorrection.cxx
+                       LINK_LIBRARIES OTBIO;OTBCommon;OTBContrastEnhancementFilters)

Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.cxx

   // Check that the right extension is given : expected .xml
   if (itksys::SystemTools::GetFilenameLastExtension(m_FileName) != ".xml")
     {
-    itkExceptionMacro(<<itksys::SystemTools::GetFilenameLastExtension(m_FileName)
+    itkExceptionMacro(<<itksys::SystemTools::GetFilenameLastExtension(m_FileName) << " " << m_FileName << " "
                       <<" is a wrong Extension FileName : Expected .xml");
     }
 

Code/ContrastEnhancement/otbRGBToYUVFunctor.h

+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+  Some parts of this code are derived from ITK. See ITKCopyright.txt
+  for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef __otbRGBToYUVFunctor_h
+#define __otbRGBToYUVFunctor_h
+
+#include "itkIndex.h"
+
+namespace otb
+{
+namespace Functor {
+
+template<class TInput, class TOutput>
+class RGBToYUVFunctor {
+
+public:
+
+  typedef itk::Index<3> IndexType;
+
+  RGBToYUVFunctor()
+    :m_rChannel(0),
+     m_gChannel(1),
+     m_bChannel(2)
+  {
+  }
+
+  ~RGBToYUVFunctor() { }
+
+  void SetRGBIndex(IndexType index)
+  {
+    m_rChannel = index[0];
+    m_gChannel = index[1];
+    m_bChannel = index[2];
+
+  }
+
+  inline void SetDelta(unsigned int delta)
+  {
+    m_Delta = delta;
+  }
+
+  inline TOutput operator ()(const TInput& input) const
+  {
+    TOutput output;
+    output.SetSize(3);
+
+    typedef typename TInput::ValueType InputType;
+    typedef typename TOutput::ValueType OutputType;
+
+    InputType R = input[m_rChannel] ;
+    InputType G = input[m_gChannel] ;
+    InputType B = input[m_bChannel] ;
+
+    double Y  =  0.299 * R + 0.587 * G + 0.114  * B;
+    double Cb = -0.169 * R - 0.331 * G + 0.499  * B + m_Delta;
+    double Cr =  0.499 * R - 0.418 * G - 0.0813 * B + m_Delta;
+
+    output[0] = static_cast<OutputType>(Y); // Y
+    output[1] = static_cast<OutputType>(Cb); // Cb
+    output[2] = static_cast<OutputType>(Cr); // Cr
+
+    return output;
+  }
+
+private:
+  int m_rChannel;
+  int m_gChannel;
+  int m_bChannel;
+  unsigned int m_Delta;
+};
+
+} //end namespace Functor
+} //end namespace otb
+
+#endif

Code/ContrastEnhancement/otbYUVToRGBFunctor.h

+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+  Some parts of this code are derived from ITK. See ITKCopyright.txt
+  for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef __otbYUVToRGBFunctor_h
+#define __otbYUVToRGBFunctor_h
+
+#include "itkIndex.h"
+
+namespace otb
+{
+namespace Functor {
+
+template<class TInput, class TOutput>
+class YUVToRGBFunctor {
+
+public:
+
+  typedef itk::Index<3> IndexType;
+  typedef typename TInput::ValueType InputType;
+  typedef typename TOutput::ValueType OutputType;
+
+  YUVToRGBFunctor()
+    :m_rChannel(0),
+     m_gChannel(1),
+     m_bChannel(2)
+  {
+
+  }
+
+  ~YUVToRGBFunctor() { }
+
+  void SetRGBIndex(IndexType index)
+  {
+    m_rChannel = index[0];
+    m_gChannel = index[1];
+    m_bChannel = index[2];
+  }
+
+  inline void SetDelta(unsigned int delta)
+  {
+    m_Delta = delta;
+  }
+
+  inline void SetMaxPixelValue(OutputType maxValue)
+  {
+    m_MaxPixelValue = maxValue;
+  }
+
+  inline TOutput operator ()(const TInput& input)
+  {
+    TOutput output;
+    output.SetSize(3);
+
+    double Y =  input[0] ;
+    double Cb = input[1] - m_Delta;
+    double Cr = input[2] - m_Delta;
+
+    double R = Y + 1.402 * Cr;
+    double G = Y - 0.344 * Cb - 0.714 *Cr;
+    double B = Y + 1.772 * Cb;
+
+    output[0] = ClipToMinMax(R);
+    output[1] = ClipToMinMax(G);
+    output[2] = ClipToMinMax(B);
+
+    return output;
+  }
+
+  OutputType ClipToMinMax(double value)
+  {
+    if(value > m_MaxPixelValue)
+      return m_MaxPixelValue;
+    else if(value < 0)
+      return 0;
+    else
+      return (OutputType)value;
+  }
+
+private:
+  int m_rChannel;
+  int m_gChannel;
+  int m_bChannel;
+  unsigned int m_Delta;
+  OutputType m_MaxPixelValue;
+
+};
+
+} //end namespace Functor
+} //end namespace otb
+
+#endif

Code/Wrappers/CommandLine/otbApplicationLauncherCommandLine.cxx

     }
   std::string ext = filename.substr(filename.size()-4,filename.size());
   if(ext != ".xml" )
-    std::cerr << ext  << " is a wrong extension: Expected .xml" << std::endl;
+    std::cerr << ext  << " is a wrong extension: Expected .xml " << __FILE__ << std::endl;
 
   // Open the xml file
   TiXmlDocument doc;
     }
 
    }
-  std::cerr << exp << ":\n";
+//  std::cerr << exp << ":\n";
 
   typedef otb::Wrapper::CommandLineLauncher LauncherType;
   LauncherType::Pointer launcher = LauncherType::New();

Code/Wrappers/SWIG/otbApplication.i

 =========================================================================*/
 
 %module otbApplication
- 
+
 
  %{
 #include "itkBase.includes"
     DefaultValueMode_RELATIVE,
     DefaultValueMode_ABSOLUTE
   };
-  
+
   typedef enum
   {
     ParameterType_Empty,
     ParameterType_OutputProcessXML,
     ParameterType_InputProcessXML
   } ParameterType;
-  
+
   typedef enum
   {
     UserLevel_Basic,
     UserLevel_Advanced
   } UserLevel;
-  
+
   typedef enum
   {
     ImagePixelType_uint8,
    ComplexImagePixelType_float,
    ComplexImagePixelType_double,
  } ComplexImagePixelType;
-  
+
 }
 }
 
   void UpdateParameters();
   int Execute();
   int ExecuteAndWriteOutput();
-  
+
   std::vector<std::string> GetParametersKeys(bool recursive = true);
   std::string GetParameterName(std::string);
   std::string GetParameterDescription(std::string);
   void SetParameterDescription(std::string paramKey, std::string dec);
-  
+
   void EnableParameter(std::string paramKey);
   void DisableParameter(std::string paramKey);
   bool IsParameterEnabled(std::string paramKey) const;
   otb::Wrapper::UserLevel GetParameterUserLevel(std::string paramKey) const;
   otb::Wrapper::ParameterType GetParameterType(std::string paramKey) const;
   otb::Wrapper::Role GetParameterRole(std::string paramKey) const;
- 
+
   std::vector<std::string> GetChoiceKeys(std::string choiceKey);
   std::vector<std::string> GetChoiceNames(std::string choiceKey);
-  
+
   bool IsApplicationReady();
-  
+
   void SetParameterInt(std::string parameter, int value);
   void SetParameterFloat(std::string parameter, float value);
   void SetParameterString(std::string parameter, std::string value);
   void SetParameterStringList(std::string parameter, std::vector<std::string> value);
-  
+
   void SetParameterOutputImagePixelType(std::string parameter, otb::Wrapper::ImagePixelType pixelType);
   void SetParameterComplexOutputImagePixelType(std::string parameter, otb::Wrapper::ComplexImagePixelType cpixelType);
 
   otb::Wrapper::ImagePixelType GetParameterOutputImagePixelType(std::string parameter);
   otb::Wrapper::ComplexImagePixelType GetParameterComplexOutputImagePixelType(std::string parameter);
-  
+
   int GetParameterInt(std::string parameter);
   float GetParameterFloat(std::string parameter);
   std::string GetParameterString(std::string parameter);
   std::vector<std::string> GetParameterStringList(std::string parameter);
   std::string GetParameterAsString(std::string paramKey);
-  
+
   itkProcessObject* GetProgressSource() const;
 
   std::string GetProgressDescription() const;
   unsigned int GetExampleNumberOfParameters(unsigned int id);
   std::string GetExampleParameterKey(unsigned int exId, unsigned int paramId);
   std::string GetExampleParameterValue(unsigned int exId, unsigned int paramId);
-  
+
   void SetDocExampleParameterValue( const std::string key, const std::string value, unsigned int exId=0 );
   void SetExampleComment( const std::string & comm, unsigned int i );
   unsigned int AddExample( const std::string & comm="" );
 };
 DECLARE_REF_COUNT_CLASS( Application )
 
+%extend Application {
+  %pythoncode {
+    def GetParameterValue(self, paramKey):
+       paramType = self.GetParameterType(paramKey)
+       if paramType in [ParameterType_InputProcessXML, ParameterType_Choice, ParameterType_ListView,
+                        ParameterType_String, ParameterType_InputFilename,
+                        ParameterType_OutputImage, ParameterType_OutputVectorData,
+                        ParameterType_OutputProcessXML, ParameterType_OutputFilename,
+                        ParameterType_Directory, ParameterType_InputImage,
+                        ParameterType_ComplexInputImage, ParameterType_InputVectorData]:
+          return self.GetParameterString(paramKey)
+
+       elif paramType in [ ParameterType_InputImageList, ParameterType_InputVectorDataList,
+                        ParameterType_InputFilenameList, ParameterType_StringList ]:
+          return self.GetParameterStringList(paramKey)
+
+       elif paramType in [ParameterType_Int, ParameterType_Radius, ParameterType_RAM]:
+          return self.GetParameterInt(paramKey)
+
+       elif paramType in [ParameterType_Float]:
+          return self.GetParameterFloat(paramKey)
+
+       else:
+          print "Cant get value for parameter '" + paramKey  + " ' of type '" + paramType + "' or ParameterType Emtpy"
+          return None
+      }
+}
 
 class Registry : public itkObject
 {
 };
 
 %include "PyCommand.i"
-
-

Testing/Applications/Classification/CMakeLists.txt

     OTB_TEST_APPLICATION(
                          NAME     apTvClTrainMethod${classifier}ImagesClassifierQB1_InXML1
                          APP      TrainImagesClassifier
-                         OPTIONS  -inxml ${TEMP}/cl${classifier}_OutXML1.xml
+                         OPTIONS  -inxml ${BASELINE_FILES}/cl${classifier}_OutXML1.xml
 
                          VALID    ${ascii_comparison}
                                   ${ascii_ref_path}/${OUTMODELFILE}
 
 OTB_TEST_APPLICATION(NAME apTvClTrainSVMImagesClassifierQB1_InXML1
                       APP  TrainImagesClassifier
-                      OPTIONS -inxml ${TEMP}/clsvmModelQB1_OutXML.xml
+                      OPTIONS -inxml ${BASELINE_FILES}/clsvmModelQB1_OutXML.xml
                               -rand 121212
                       VALID   --compare-ascii ${NOTOL}
                               ${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
 
 OTB_TEST_APPLICATION(NAME apTvClTrainSVMImagesClassifierQB1_allOpt_InXML
                       APP  TrainImagesClassifier
-                      OPTIONS -inxml ${TEMP}/clsvmModelQB1_OutXML.xml
+                      OPTIONS -inxml ${BASELINE_FILES}/clsvmModelQB1_OutXML.xml
                               -sample.mv 100
                               -sample.mt 100
                               -sample.vtr 0.5
 
 OTB_TEST_APPLICATION(NAME apTvClImageSVMClassifierQB3_InXML
                       APP  ImageClassifier
-                      OPTIONS -inxml  ${TEMP}/clLabeledImageQB3_OutXML.xml
+                      OPTIONS -inxml  ${BASELINE_FILES}/clLabeledImageQB3_OutXML.xml
                       VALID   --compare-image ${NOTOL}
                               ${OTBAPP_BASELINE}/clLabeledImageQB3.tif
                               ${TEMP}/clLabeledImageQB3.tif)

Testing/Applications/Projections/CMakeLists.txt

 OTB_TEST_APPLICATION(NAME  apTvPrOrthorectification_UTM_InXML1
                      APP  OrthoRectification
                      OPTIONS 
-                     -inxml  ${TEMP}/apTvPrOrthorectifTest_UTM_OutXML1.xml
+                     -inxml  ${BASELINE_FILES}/apTvPrOrthorectifTest_UTM_OutXML1.xml
                      VALID   --compare-image ${EPSILON_4}
                               ${BASELINE}/owTvOrthorectifTest_UTM.tif
                  			  ${TEMP}/apTvPrOrthorectifTest_UTM_OutXML1.tif)

Testing/Applications/Utils/CMakeLists.txt

 
 OTB_TEST_APPLICATION(NAME  apTvUtSmoothingTest_InXML
                      APP  Smoothing
-                     OPTIONS -inxml ${TEMP}/apTvUtSmoothingTest_OutXML.xml
+                     OPTIONS -inxml ${BASELINE_FILES}/apTvUtSmoothingTest_OutXML.xml
                              -type mean                         
                      VALID   --compare-image ${NOTOL}
                              ${BASELINE}/apTvUtSmoothingTest.tif