diff --git a/Example/CMakeLists.txt b/Example/CMakeLists.txt index 30232f6ae2f2e16849e026564dca20163ecb779d..dc4ca2b298304873e7f1b8e43eb45404fc621cf2 100644 --- a/Example/CMakeLists.txt +++ b/Example/CMakeLists.txt @@ -2,4 +2,5 @@ include(WrapperMacros) OTB_CREATE_APPLICATION(NAME Addition SOURCES otbAddition.cxx) OTB_CREATE_APPLICATION(NAME Smoothing SOURCES otbSmoothing.cxx) -OTB_CREATE_APPLICATION(NAME TestApplication SOURCES otbTestApplication.cxx) \ No newline at end of file +OTB_CREATE_APPLICATION(NAME Rescale SOURCES otbRescale.cxx) +OTB_CREATE_APPLICATION(NAME TestApplication SOURCES otbTestApplication.cxx) diff --git a/Example/otbRescale.cxx b/Example/otbRescale.cxx new file mode 100644 index 0000000000000000000000000000000000000000..41d088677c041dc87f9c1b1171ce4dbc0a6bcddf --- /dev/null +++ b/Example/otbRescale.cxx @@ -0,0 +1,119 @@ +/*========================================================================= + + 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 "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "otbStreamingMinMaxVectorImageFilter.h" +#include "otbVectorRescaleIntensityImageFilter.h" + +namespace otb +{ +namespace Wrapper +{ + + +class Rescale : public Application +{ +public: + /** Standard class typedefs. */ + typedef Rescale Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(Rescale, otb::Application); + + /** Filters typedef */ + typedef otb::StreamingMinMaxVectorImageFilter<VectorImageType> MinMaxFilterType; + typedef otb::VectorRescaleIntensityImageFilter<VectorImageType> RescaleImageFilterType; + + +private: + Rescale() + { + SetName("Rescale"); + SetDescription("Rescale the image between two given values."); + m_RescaleFilter = RescaleImageFilterType::New(); + m_MinMaxFilter = MinMaxFilterType::New(); + } + + virtual ~Rescale() + { + } + + void DoCreateParameters() + { + AddParameter(ParameterType_InputImage, "in", "Input Image"); + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + + AddParameter(ParameterType_Float, "outmin", "Output min value"); + AddParameter(ParameterType_Float, "outmax", "Output max value"); + SetParameterFloat("outmin", 0); + SetParameterFloat("outmax", 255); + } + + void DoUpdateParameters() + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() + { + VectorImageType::Pointer inImage = GetParameterImage("in"); + + std::cout<<"first step"<<std::endl; + + m_MinMaxFilter = MinMaxFilterType::New(); + std::cout<<"minmax instanciated"<<std::endl; + m_RescaleFilter = RescaleImageFilterType::New(); + + m_MinMaxFilter->SetInput( inImage ); + m_MinMaxFilter->Update(); + std::cout<<"Input min value: "<<m_MinMaxFilter->GetMinimum()<<std::endl; + std::cout<<"Input max value: "<<m_MinMaxFilter->GetMaximum()<<std::endl; + + m_RescaleFilter->SetInput( inImage ); + m_RescaleFilter->SetInputMinimum( m_MinMaxFilter->GetMinimum() ); + m_RescaleFilter->SetInputMaximum( m_MinMaxFilter->GetMaximum() ); + std::cout<<"input min/max set"<<std::endl; + + m_RescaleFilter->SetOutputMinimum( GetParameterFloat("outmin") ); + m_RescaleFilter->SetOutputMaximum( GetParameterFloat("outmax") ); + + std::cout<<"output min/max set"<<std::endl; + m_RescaleFilter->UpdateOutputInformation(); + std::cout<<"UpdateOutputInformation done"<<std::endl; + + SetParameterOutputImage("out", m_RescaleFilter->GetOutput()); + std::cout<<"output updated"<<std::endl; + } + + RescaleImageFilterType::Pointer m_RescaleFilter; + MinMaxFilterType::Pointer m_MinMaxFilter; +}; + + + +} +} + +OTB_APPLICATION_EXPORT(otb::Wrapper::Rescale) + diff --git a/Testing/Java/CMakeLists.txt b/Testing/Java/CMakeLists.txt index b4ad74bdcd93daf6b82fd3e3e29cf0c19df5def3..a1b1f118ea0e8444525c562e563f9a85c8e4d363 100644 --- a/Testing/Java/CMakeLists.txt +++ b/Testing/Java/CMakeLists.txt @@ -14,3 +14,11 @@ add_test( NAME jaTvSmoothing ${JAVA_COMMAND} -cp ${CMAKE_JAVA_INCLUDE_PATH}:JavaSmoothingTest.jar SmoothingTest ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif ${TEMP}/jaTvSmoothing_ ) + +add_jar( JavaRescaleTest JavaRescaleTest.java ) +add_dependencies( JavaRescaleTest org_otb_Application_jar ) +add_test( NAME jaTvRescale + COMMAND ${TEST_DRIVER} Execute + ${JAVA_COMMAND} -cp ${CMAKE_JAVA_INCLUDE_PATH}:JavaRescaleTest.jar RescaleTest + ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif + ${TEMP}/jaTvRescale ) diff --git a/Testing/Java/JavaRescaleTest.java b/Testing/Java/JavaRescaleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c842b4ee04e924505fd1ecf2a3595959d8ebfb48 --- /dev/null +++ b/Testing/Java/JavaRescaleTest.java @@ -0,0 +1,27 @@ +/* + * Example on the use of the Rescale + */ + +import org.otb.application.*; + + +class RescaleTest { + + public static void main( String argv[] ) { + + vectorstring appAvailable = Registry.GetAvailableApplications(); + System.out.println( "Available applications :" ); + + for (int i = 0; i < appAvailable.size(); i++) + { + System.out.println( appAvailable.get(i) ); + } + + System.out.println( "Creating application " + "Rescale"); + Application_Pointer app = Registry.CreateApplication("Rescale"); + + System.out.println( Registry.CreateApplication("Rescale").GetDescription() ); + + } + +} \ No newline at end of file diff --git a/Testing/Lua/CMakeLists.txt b/Testing/Lua/CMakeLists.txt index 9752bd30d294dce173e6b3841cca828a25ac8716..642512e59474b1d52cef80b935412264edb9f3e4 100644 --- a/Testing/Lua/CMakeLists.txt +++ b/Testing/Lua/CMakeLists.txt @@ -10,3 +10,10 @@ add_test( NAME luTvSmoothing ${CMAKE_CURRENT_SOURCE_DIR}/LuaSmoothingTest.lua ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif ${TEMP}/rbTvSmoothing_ ) + +add_test( NAME luTvRescale + COMMAND ${TEST_DRIVER} Execute + ${CMAKE_BINARY_DIR}/Code/Wrappers/SWIG/otbApplicationLua + ${CMAKE_CURRENT_SOURCE_DIR}/LuaRescaleTest.lua + ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif + ${TEMP}/rbTvRescale ) diff --git a/Testing/Lua/LuaRescaleTest.lua b/Testing/Lua/LuaRescaleTest.lua new file mode 100644 index 0000000000000000000000000000000000000000..fdca6b65711bdfea12ad2decd5432ab8129e273e --- /dev/null +++ b/Testing/Lua/LuaRescaleTest.lua @@ -0,0 +1,9 @@ +print ( "Lua test begin" ) + +r = otbApplication.Registry +apps = r:GetAvailableApplications() + +print ( "otbApplication.Registry:GetAvailableApplications OK" ) +print ( "apps" ) +print ( apps ) +os.exit ( 0 ) \ No newline at end of file diff --git a/Testing/PyQt/CMakeLists.txt b/Testing/PyQt/CMakeLists.txt index c904be3b0e0d3b6806ff78f909cd840558c89378..f6b808e42af5bf785db0511aafcbc51d1b5d0714 100644 --- a/Testing/PyQt/CMakeLists.txt +++ b/Testing/PyQt/CMakeLists.txt @@ -10,3 +10,9 @@ add_test( NAME pqTvSmoothing ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PyQtTest.py ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif ${TEMP}/pyTvSmoothing_ ) + +add_test( NAME pqTvRescale + COMMAND ${TEST_DRIVER} Execute + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PyQtTest.py + ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif + ${TEMP}/pyTvRescale ) \ No newline at end of file diff --git a/Testing/Python/CMakeLists.txt b/Testing/Python/CMakeLists.txt index 7d3c7d2888d9fa07f4b885decdcedfb76a9afc8f..86ad1a6aaf1eaebdd655000e0d5a1543cacf784a 100644 --- a/Testing/Python/CMakeLists.txt +++ b/Testing/Python/CMakeLists.txt @@ -9,3 +9,9 @@ add_test( NAME pyTvSmoothing ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonSmoothingTest.py ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif ${TEMP}/pyTvSmoothing_ ) + +add_test( NAME pyTvRescale + COMMAND ${TEST_DRIVER} Execute + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonRescaleTest.py + ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif + ${TEMP}/pyTvRescale) \ No newline at end of file diff --git a/Testing/Python/PythonRescaleTest.py b/Testing/Python/PythonRescaleTest.py new file mode 100644 index 0000000000000000000000000000000000000000..c2eaa0f6569c9e9d68fc17a2969084ae7a9a9ef2 --- /dev/null +++ b/Testing/Python/PythonRescaleTest.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +# +# Example on the use of the Rescale +# +from sys import argv +import otbApplication as otb + +print "Available applications : " + str(otb.Registry.GetAvailableApplications()) + +app = otb.Registry.CreateApplication("Rescale") +print app.GetParametersKeys() + +app.SetParameterString("in", argv[1]) + +app.SetParameterFloat("outmin", 1) +app.SetParameterFloat("outmax", 100) +app.SetParameterString("out", argv[2] + ".tif") +app.Execute() + +print dir(app) diff --git a/Testing/Ruby/CMakeLists.txt b/Testing/Ruby/CMakeLists.txt index 099aa0fba66b005cff7df5331aed92f6482f55df..9e3a712ddd0ff3df21504c15c9c7e77d104d04a5 100644 --- a/Testing/Ruby/CMakeLists.txt +++ b/Testing/Ruby/CMakeLists.txt @@ -9,3 +9,10 @@ add_test( NAME rbTvSmoothing ${RUBY_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/RubySmoothingTest.rb ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif ${TEMP}/rbTvSmoothing_ ) + +add_test( NAME rbTvRescale + COMMAND ${TEST_DRIVER} Execute + ${RUBY_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/RubyRescaleTest.rb + ${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif + ${TEMP}/rbTvRescale ) + diff --git a/Testing/Ruby/RubyRescaleTest.rb b/Testing/Ruby/RubyRescaleTest.rb new file mode 100644 index 0000000000000000000000000000000000000000..43e49adb1ada2e660d814ec43ac44994cf0a8e55 --- /dev/null +++ b/Testing/Ruby/RubyRescaleTest.rb @@ -0,0 +1,15 @@ +# +# Example on the use of the Rescale +# +require 'otbapplication' + +if ARGV.length < 2 then + puts( "Usage: RubyRescaleTest input outputbasename" ) + exit( 1 ) +end + +tag = ARGV[0]; + +r = Otbapplication::Registry +applist = r.get_available_applications() +puts( applist )