diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index 545a14d606a31d2d153764a5a3abf373d93af2c6..1cda1209c336ddb64d998b326fd7c54740a2b9ae 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -21,6 +21,7 @@ SUBDIRS( Projections Registration Radiometry + SARPolarimetry Fusion Tutorials Markov @@ -77,6 +78,7 @@ ELSE(OTB_BINARY_DIR) DisparityMap Registration Radiometry + SARPolarimetry Fusion Tutorials Markov diff --git a/Examples/SARPolarimetry/CMakeLists.txt b/Examples/SARPolarimetry/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..e4b6c28e20dfc4798146d3e4a774600c0ca45550 --- /dev/null +++ b/Examples/SARPolarimetry/CMakeLists.txt @@ -0,0 +1,42 @@ +PROJECT(ImagePolarimetricSynthesisExamples) +INCLUDE_REGULAR_EXPRESSION("^.*$") + +ADD_EXECUTABLE(PiOver4ExamplePolarimetricSynthesisFilter PiOver4ExamplePolarimetricSynthesisFilter.cxx ) +TARGET_LINK_LIBRARIES(PiOver4ExamplePolarimetricSynthesisFilter OTBSARPolarimetry OTBCommon OTBIO ITKNumerics ITKIO) + + +IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) + +SET(BASELINE ${OTB_DATA_ROOT}/Baseline/Examples/SARPolarimetry) + +SET(INPUTDATA ${OTB_SOURCE_DIR}/Examples/Data) +SET(TEMP ${OTB_BINARY_DIR}/Testing/Temporary) + +SET(EXE_TESTS ${CXX_TEST_PATH}/otbSARPolarimetryExamplesTests) + +#Tolerance sur diff pixel image +SET(TOL 0.0) +SET(EPSILON 0.000000000001) + + +# ------- PiOver4ExamplePolarimetricSynthesisFilterTest ------------------------------ + +# Tutorial example . pi / 4 +ADD_TEST(rdTvPiOver4ExamplePolarimetricSynthesisFilterTest ${SARPOLARIMETRY_TESTS1} +# --compare-image ${EPSILON} +# ${BASELINE}/ARVIMultiChannelRAndBAndNIRVegetationIndex.tif +# ${TEMP}/ARVIMultiChannelRAndBAndNIRVegetationIndex.tif + PiOver4ExamplePolarimetricSynthesisFilterTest + ${INPUTDATA}/RSAT_imagery_HH.tif + ${INPUTDATA}/RSAT_imagery_HV.tif + ${INPUTDATA}/RSAT_imagery_VH.tif + ${INPUTDATA}/RSAT_imagery_VV.tif + ${TEMP}/resPiOver4PolarimetricSynthesis.tif + ) + + +ADD_EXECUTABLE(otbSARPolarimetryExamplesTests PiOver4ExamplePolarimetricSynthesisFilter.cxx ) +TARGET_LINK_LIBRARIES(otbSARPolarimetryExamplesTests OTBSARPolarimetry OTBCommon OTBIO gdal ITKIO ITKCommon ITKBasicFilters) + + +ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Examples/SARPolarimetry/PiOver4ExamplePolarimetricSynthesisFilter.cxx b/Examples/SARPolarimetry/PiOver4ExamplePolarimetricSynthesisFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6515288fd17cf049caff6885afa896b327efb588 --- /dev/null +++ b/Examples/SARPolarimetry/PiOver4ExamplePolarimetricSynthesisFilter.cxx @@ -0,0 +1,214 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +// Software Guide : BeginLatex +// This example illustrates the use of the \doxygen{otb}{PolarimetricSynthesisFilter} +// in order to perform a synthetic image using fully polarimetric data. +// +// We will start by including the header file. +// +// Software Guide : EndLatex + + +// Software Guide : BeginCodeSnippet + +#include "otbPolarimetricSynthesisFilter.h" + +// Software Guide : EndCodeSnippet + +int main( int argc, char* argv[] ) +{ + + + if(argc!=5) + { + std::cout << argv[0] + <<" <input_filename_HH_channel>" + <<" <input_filename_HV_channel>" + <<" <input_filename_VH_channel>" + <<" <input_filename_VV_channel>" + <<" <output_filename>" + << std::endl; + + return EXIT_FAILURE; + } + +// Software Guide : BeginLatex +// +// We begin by declaring the types for the input image and the image reader. +// +// Software Guide : EndLatex + + +// Software Guide : BeginCodeSnippet + + typedef std::complex <double> InputPixelType; + typedef double OutputPixelType; + const unsigned int Dimension = 2; + + typedef otb::Image< InputPixelType, Dimension > InputImageType; + typedef otb::Image< OutputPixelType, Dimension > OutputImageType; + + typedef otb::ImageFileWriter< OutputImageType > WriterType; + +// Software Guide : EndCodeSnippet + +// Software Guide : BeginLatex +// +// The PolarimetricSynthesisFilter can be instantiated +// using the image types defined above. +// +// Software Guide : EndLatex + + +// Software Guide : BeginCodeSnippet + + typedef otb::PolarimetricSynthesisFilter<InputImageType, InputImageType,InputImageType,InputImageType,OutputImageType > FilterType; + +// Software Guide : EndCodeSnippet + +// Software Guide : BeginLatex +// +// An \doxygen{otb}{ImageFileReader} class is also instantiated in order to read +// image data from a file. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + + typedef otb::ImageFileReader< InputImageType > ReaderType; + +// Software Guide : EndCodeSnippet + + +// Software Guide : BeginLatex +// +// An \doxygen{otb}{ImageFileWriter} is instantiated in order to write the +// output image to a file. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + + typedef otb::ImageFileWriter< OutputImageType > WriterType; + +// Software Guide : EndCodeSnippet + + +// Software Guide : BeginLatex +// +// The filter, the reader and the writter are created by invoking their \code{New()} +// methods and assigning the result to SmartPointers. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + + ReaderType::Pointer reader_HH = ReaderType::New(); + ReaderType::Pointer reader_HV = ReaderType::New(); + ReaderType::Pointer reader_VH = ReaderType::New(); + ReaderType::Pointer reader_VV = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + FilterType::Pointer polarimetricSynthesis = FilterType::New(); + + reader_HH->SetFileName( argv[1] ); + reader_HV->SetFileName( argv[2] ); + reader_VH->SetFileName( argv[3] ); + reader_VV->SetFileName( argv[4] ); + writer->SetFileName( argv[5] ); + +// Software Guide : EndCodeSnippet + +// Software Guide : BeginLatex +// +// The image obtained with the reader is passed as input to the +// \doxygen{otb}{PolarimetricSynthesisFilter}. +// +// \index{otb::PolarimetricSynthesisFilter!SetInputHH()} +// \index{otb::PolarimetricSynthesisFilter!SetInputHV()} +// \index{otb::PolarimetricSynthesisFilter!SetInputVH()} +// \index{otb::PolarimetricSynthesisFilter!SetInputVV()} +// \index{otb::FileImageReader!GetOutput()} +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + + polarimetricSynthesis->SetInputHH( reader_HH->GetOutput() ); + polarimetricSynthesis->SetInputHV( reader_HV->GetOutput() ); + polarimetricSynthesis->SetInputVH( reader_VH->GetOutput() ); + polarimetricSynthesis->SetInputVV( reader_VV->GetOutput() ); + +// Software Guide : EndCodeSnippet + +// Software Guide : BeginLatex +// +// The method \code{SetPsiI()} defines the orientation of the emit electromagnetic +// field to be used for the computation. +// The method \code{SetKhiI()} defines the ellipticity of the emit electromagnetic +// field to be used for the computation. +// The method \code{SetPsiR()} defines the orientation of the receive electromagnetic +// field to be used for the computation. +// The method \code{SetKhiR()} defines the ellipticity of the receive electromagnetic +// field to be used for the computation. +// +// Hence if we want to emulate a \pi \over 4 data in emission +// \code{SetPsiI()} is equal to 45.0 and \code{SetKhiI()} to 0.0. +// In our example, we choose the reveiver to be a linear horizontal polarisation. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + + polarimetricSynthesis->SetPsiI( 45. ); + polarimetricSynthesis->SetKhiI( 0. ); + polarimetricSynthesis->SetPsiR( 0. ); + polarimetricSynthesis->SetKhiR( 0. ); + +// Software Guide : EndCodeSnippet + +// Software Guide : BeginLatex +// +// The filter is executed by invoking the \code{Update()} method. If the +// filter is part of a larger image processing pipeline, calling +// \code{Update()} on a downstream filter will also trigger update of this +// filter. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + + polarimetricSynthesis->Update(); + +// Software Guide : EndCodeSnippet + + writer->SetInput( polarimetricSynthesis->GetOutput() ); + + writer->Update(); + + return EXIT_SUCCESS; + +} + diff --git a/Examples/SARPolarimetry/otbSARPolarimetryExamplesTests.cxx b/Examples/SARPolarimetry/otbSARPolarimetryExamplesTests.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d00f2599b2674dd511778a68747d9ff7d0dcedfc --- /dev/null +++ b/Examples/SARPolarimetry/otbSARPolarimetryExamplesTests.cxx @@ -0,0 +1,34 @@ +/*========================================================================= + + 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. + +=========================================================================*/ + +// this file defines the otbMultiScaleTest for the test driver +// and all it expects is that you have a function called RegisterTests +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif +#include <iostream> +#include "otbTestMain.h" + +void RegisterTests() +{ +REGISTER_TEST(PiOver4ExamplePolarimetricSynthesisFilter); +} + +#undef main +#define main PiOver4ExamplePolarimetricSynthesisFilterTest +#include "PiOver4ExamplePolarimetricSynthesisFilter.cxx" +