diff --git a/Testing/Code/SARPolarimetry/CMakeLists.txt b/Testing/Code/SARPolarimetry/CMakeLists.txt index c291daf45d2e66c98f55facf982901265abd93a8..961233edba385a049325618b63dece8dbfbb49bb 100644 --- a/Testing/Code/SARPolarimetry/CMakeLists.txt +++ b/Testing/Code/SARPolarimetry/CMakeLists.txt @@ -280,10 +280,7 @@ ADD_TEST(saTvReciprocalCovarianceToCoherencyDegreeImageFilter ${SARPOLARIMETRY_T --compare-image ${EPSILON_12} ${BASELINE}/saTvMLCToCoherencyDegreeImageFilter.tif ${TEMP}/saTvMLCToCoherencyDegreeImageFilter.tif otbReciprocalCovarianceToCoherencyDegreeImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif ${TEMP}/saTvMLCToCoherencyDegreeImageFilter.tif ) @@ -296,10 +293,7 @@ ADD_TEST(saTvReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter --compare-image ${EPSILON_12} ${BASELINE}/saTvMLCToCircularCoherencyDegreeImageFilter.tif ${TEMP}/saTvMLCToCircularCoherencyDegreeImageFilter.tif otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif ${TEMP}/saTvMLCToCircularCoherencyDegreeImageFilter.tif ) @@ -312,10 +306,7 @@ ADD_TEST(saTvReciprocalHAlphaImageFilter ${SARPOLARIMETRY_TESTS2} --compare-image ${EPSILON_12} ${BASELINE}/saTvReciprocalHAlphaImageFilter.tif ${TEMP}/saTvReciprocalHAlphaImageFilter.tif otbReciprocalHAlphaImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCoherency.tif ${TEMP}/saTvReciprocalHAlphaImageFilter.tif ) @@ -328,10 +319,7 @@ ADD_TEST(saTvReciprocalCoherencyToMuellerImageFilter ${SARPOLARIMETRY_TESTS2} --compare-image ${EPSILON_12} ${BASELINE}/saTvReciprocalCoherencyToMuellerImageFilter.tif ${TEMP}/saTvReciprocalCoherencyToMuellerImageFilter.tif otbReciprocalCoherencyToMuellerImageFilter - ${INPUTDATA}/RSAT_imagery_HH.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_HV.tif - ${INPUTDATA}/RSAT_imagery_VV.tif + ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCoherency.tif ${TEMP}/saTvReciprocalCoherencyToMuellerImageFilter.tif ) diff --git a/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx index 470766ddda6d0efa2ba48fed50c4cb9a1dd4e8e6..dc20a0fa8a650156a0c2838abe874de69fda04c3 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalCoherencyToMuellerImageFilter.cxx @@ -26,62 +26,33 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalCoherencyToMuellerImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" int otbReciprocalCoherencyToMuellerImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - - typedef otb::Image<InputPixelType, Dimension> InputImageType; + typedef otb::VectorImage<InputPixelType, Dimension> ImageType; typedef otb::VectorImage<PixelType, Dimension> RealImageType; - typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCoherencyFilterType; - typedef otb::ReciprocalCoherencyToMuellerImageFilter<ImageType, RealImageType> FilterType; + typedef otb::ReciprocalCoherencyToMuellerImageFilter<ImageType, RealImageType> FilterType; - typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileWriter<RealImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCoherencyFilterType::Pointer sinclairToCoherencyFilter - = SinclairToCoherencyFilterType::New(); - sinclairToCoherencyFilter->SetInputHH(reader1->GetOutput()); - sinclairToCoherencyFilter->SetInputHV(reader2->GetOutput()); - sinclairToCoherencyFilter->SetInputVH(reader3->GetOutput()); - sinclairToCoherencyFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(sinclairToCoherencyFilter->GetOutput()); + filter->SetInput(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx index 711447f3f7f1fa35ca397930d553a6d4c90a370b..efb2b54a0b53c74be0981f577c48a67db9a1ed27 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx @@ -26,61 +26,30 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalCovarianceToCoherencyDegreeImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" int otbReciprocalCovarianceToCoherencyDegreeImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - - typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<InputPixelType, Dimension> ImageType; - typedef otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCovarianceFilterType; typedef otb::ReciprocalCovarianceToCoherencyDegreeImageFilter<ImageType, ImageType> FilterType; - - typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileWriter<ImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCovarianceFilterType::Pointer sinclairToCovarianceFilter - = SinclairToCovarianceFilterType::New(); - sinclairToCovarianceFilter->SetInputHH(reader1->GetOutput()); - sinclairToCovarianceFilter->SetInputHV(reader2->GetOutput()); - sinclairToCovarianceFilter->SetInputVH(reader3->GetOutput()); - sinclairToCovarianceFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(sinclairToCovarianceFilter->GetOutput()); + filter->SetInput(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx index 4f72e660613f624f60c43b2f83dc665d50c1246a..b18dae2c436f12a9a15294eab736831f873b1925 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx @@ -25,7 +25,7 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h" -#include "otbComplexToVectorImageCastFilter.h" + int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int argc, char * argv[]) { @@ -40,13 +40,10 @@ int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int argc, char * arg typedef otb::ReciprocalCovarianceToReciprocalCoherencyImageFilter<ImageType, ImageType> FilterType; - typedef otb::ImageFileReader<ImageType> ReaderType; - typedef otb::ImageFileWriter<RealImageType> WriterType; - typedef otb::ComplexToVectorImageCastFilter<ImageType, RealImageType> CasterType; + typedef otb::ImageFileWriter<ImageType> WriterType; ReaderType::Pointer reader = ReaderType::New(); - CasterType::Pointer caster = CasterType::New(); WriterType::Pointer writer = WriterType::New(); reader->SetFileName(inputFilename); @@ -54,10 +51,8 @@ int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int argc, char * arg FilterType::Pointer filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - caster->SetInput(filter->GetOutput()); - writer->SetFileName(outputFilename); - writer->SetInput(caster->GetOutput()); + writer->SetInput(filter->GetOutput()); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx index 982b869b5ae80e44b08588c46ed9d8648ac1b121..0b1e45502a21eceeb88daccbc1bca397cc51eba1 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalHAlphaImageFilter.cxx @@ -26,73 +26,35 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalHAlphaImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" -#include "otbMultiChannelExtractROI.h" int otbReciprocalHAlphaImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<InputPixelType, Dimension> ImageType; typedef otb::VectorImage<PixelType, Dimension> RealImageType; - typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCoherencyFilterType; - + typedef otb::ReciprocalHAlphaImageFilter<ImageType, RealImageType> FilterType; - typedef otb::MultiChannelExtractROI<PixelType, PixelType> ExtractType; - typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileWriter<RealImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCoherencyFilterType::Pointer sinclairToCoherencyFilter - = SinclairToCoherencyFilterType::New(); - sinclairToCoherencyFilter->SetInputHH(reader1->GetOutput()); - sinclairToCoherencyFilter->SetInputHV(reader2->GetOutput()); - sinclairToCoherencyFilter->SetInputVH(reader3->GetOutput()); - sinclairToCoherencyFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(sinclairToCoherencyFilter->GetOutput()); - - ExtractType::Pointer extract = ExtractType::New(); - extract->SetInput(filter->GetOutput()); - extract->SetStartX(10); - extract->SetStartY(10); - extract->SetSizeX(30); - extract->SetSizeY(30); + filter->SetInput(reader->GetOutput()); writer->SetFileName(outputFilename); - writer->SetInput(extract->GetOutput()); + writer->SetInput(filter->GetOutput()); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx b/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx index 6aa021331e5db71232d5dfec706f8393fd63b8d6..bbea66e5b19ba625b2a72fb4608c9899a27c5832 100644 --- a/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx @@ -25,69 +25,33 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h" -#include "otbSinclairReciprocalImageFilter.h" -#include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" -#include "otbComplexToVectorImageCastFilter.h" int otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter(int argc, char * argv[]) { - const char * inputFilename1 = argv[1]; - const char * inputFilename2 = argv[2]; - const char * inputFilename3 = argv[3]; - const char * inputFilename4 = argv[4]; - - const char * outputFilename = argv[5]; + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; typedef double PixelType; typedef std::complex<PixelType> InputPixelType; const unsigned int Dimension = 2; - - typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<InputPixelType, Dimension> ImageType; - typedef otb::VectorImage<PixelType, Dimension> RealImageType; - typedef otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor< - InputImageType::PixelType, - InputImageType::PixelType, - InputImageType::PixelType, - ImageType::PixelType> FunctionType; - - typedef otb::SinclairReciprocalImageFilter<InputImageType, - InputImageType, InputImageType, - ImageType, FunctionType > SinclairToCovarianceFilterType; typedef otb::ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter<ImageType, ImageType> FilterType; - typedef otb::ComplexToVectorImageCastFilter<ImageType, RealImageType> CasterType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<RealImageType> WriterType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - ReaderType::Pointer reader3 = ReaderType::New(); - ReaderType::Pointer reader4 = ReaderType::New(); + ReaderType::Pointer reader = ReaderType::New(); WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(inputFilename1); - reader2->SetFileName(inputFilename2); - reader3->SetFileName(inputFilename3); - reader4->SetFileName(inputFilename4); - - SinclairToCovarianceFilterType::Pointer sinclairToCovarianceFilter - = SinclairToCovarianceFilterType::New(); - sinclairToCovarianceFilter->SetInputHH(reader1->GetOutput()); - sinclairToCovarianceFilter->SetInputHV(reader2->GetOutput()); - sinclairToCovarianceFilter->SetInputVH(reader3->GetOutput()); - sinclairToCovarianceFilter->SetInputVV(reader4->GetOutput()); + reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(sinclairToCovarianceFilter->GetOutput()); - - CasterType::Pointer caster = CasterType::New(); - caster->SetInput(filter->GetOutput()); - + filter->SetInput(reader->GetOutput()); + writer->SetFileName(outputFilename); - writer->SetInput(caster->GetOutput()); + writer->SetInput(filter->GetOutput()); writer->Update(); return EXIT_SUCCESS; diff --git a/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx b/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx index 6508a756f79946e8a8be9330f6e9a8481ffdc707..7b4a9b852aeecad3b105303b1b0b9631e61d43a2 100644 --- a/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbSinclairImageFilter.cxx @@ -32,8 +32,8 @@ #include "otbSinclairToCircularCovarianceMatrixFunctor.h" #include "otbSinclairToCoherencyMatrixFunctor.h" #include "otbSinclairToMuellerMatrixFunctor.h" -#include "otbComplexToVectorImageCastFilter.h" -#include "otbExtractROI.h" +#include "otbMultiChannelExtractROI.h" + int otbSinclairImageFilterNew(int argc, char * argv[]) { @@ -66,111 +66,39 @@ int generic_SinclairImageFilter(int argc, char * argv[]) typedef otb::Image<TInputPixel> InputImageType; typedef otb::VectorImage<TOutputPixel> OutputImageType; typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ExtractROI<TInputPixel, TInputPixel > ExtractROIType; + typedef otb::MultiChannelExtractROI<TOutputPixel, TOutputPixel > 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->SetInputHH(reader1->GetOutput()); + filter->SetInputHV(reader2->GetOutput()); + filter->SetInputVH(reader2->GetOutput()); + filter->SetInputVV(reader3->GetOutput()); + filter->UpdateOutputInformation(); + typename ExtractROIType::Pointer extract = ExtractROIType::New(); + extract->SetStartX(10); + extract->SetStartY(10); + extract->SetSizeX(30); + extract->SetSizeY(30); + extract->SetInput(filter->GetOutput()); + typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outputFilename); - writer->SetInput( filter->GetOutput() ); + writer->SetInput( extract->GetOutput() ); writer->Update(); return EXIT_SUCCESS; } -template<class TInputPixel, class TOutputPixel, class TFunction> -int generic_SinclairImageFilterWithCast(int argc, char * argv[]) -{ - const char * outputFilename = argv[4]; - - typedef otb::VectorImage<TOutputPixel> OutputImageType; - typedef otb::VectorImage<typename TOutputPixel::value_type> OutputRealImageType; - typedef otb::ImageFileWriter<OutputRealImageType> WriterType; - typedef typename otb::ComplexToVectorImageCastFilter<OutputImageType, OutputRealImageType> CasterType; - - 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(); - - writer->SetFileName(outputFilename); - - caster->SetInput( filter->GetOutput() ); - writer->SetInput( caster->GetOutput() ); - writer->Update(); - - return EXIT_SUCCESS; -} - - int otbSinclairImageFilter(int argc, char * argv[]) { const unsigned int Dimension = 2; @@ -186,7 +114,7 @@ int otbSinclairImageFilter(int argc, char * argv[]) argc--; argv++; if (strArgv == "SinclairToCovarianceMatrix") - return (generic_SinclairImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, @@ -194,7 +122,7 @@ int otbSinclairImageFilter(int argc, char * argv[]) OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToCircularCovarianceMatrix") - return (generic_SinclairImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToCircularCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, @@ -202,7 +130,7 @@ int otbSinclairImageFilter(int argc, char * argv[]) OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToCoherencyMatrix") - return (generic_SinclairImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToCoherencyMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, diff --git a/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx b/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx index 3eefb9a8d5cc86870b4efb36c6ce61a34c765b85..148f3dc71c468c7d05665b88214dec8a985a5d77 100644 --- a/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx +++ b/Testing/Code/SARPolarimetry/otbSinclairReciprocalImageFilter.cxx @@ -31,8 +31,7 @@ #include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" #include "otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h" #include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" -#include "otbComplexToVectorImageCastFilter.h" -#include "otbExtractROI.h" +#include "otbMultiChannelExtractROI.h" int otbSinclairReciprocalImageFilterNew(int argc, char * argv[]) @@ -40,96 +39,58 @@ int otbSinclairReciprocalImageFilterNew(int argc, char * argv[]) typedef std::complex<float> ComplexType; typedef otb::Image<ComplexType, 2> CplxImageType; typedef otb::VectorImage<ComplexType, 2> VCplxImageType; - + typedef otb::SinclairReciprocalImageFilter<CplxImageType, CplxImageType, CplxImageType, VCplxImageType> FilterType; - + // Instantiating object FilterType::Pointer filter = FilterType::New(); - - + + return EXIT_SUCCESS; } -#define generic_SinclairReciprocalImageFilterMacro(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::SinclairReciprocalImageFilter<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_SinclairReciprocalImageFilter(int argc, char * argv[]) { + const char * inputFilename1 = argv[1]; + const char * inputFilename2 = argv[2]; + const char * inputFilename3 = argv[3]; const char * outputFilename = argv[4]; - + + typedef otb::Image<TInputPixel> InputImageType; typedef otb::VectorImage<TOutputPixel> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; typedef otb::ImageFileWriter<OutputImageType> WriterType; - - generic_SinclairReciprocalImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); + + typedef otb::MultiChannelExtractROI<TOutputPixel, TOutputPixel > ExtractROIType; + typedef otb::SinclairReciprocalImageFilter<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(); + + reader1->SetFileName(inputFilename1); + reader2->SetFileName(inputFilename2); + reader3->SetFileName(inputFilename3); + + filter->SetInputHH(reader1->GetOutput()); + filter->SetInputHV(reader2->GetOutput()); + filter->SetInputVH(reader2->GetOutput()); + filter->SetInputVV(reader3->GetOutput()); + + typename ExtractROIType::Pointer extract = ExtractROIType::New(); + extract->SetStartX(10); + extract->SetStartY(10); + extract->SetSizeX(30); + extract->SetSizeY(30); + extract->SetInput( filter->GetOutput() ); typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outputFilename); - - writer->SetInput( filter->GetOutput() ); - writer->Update(); - - return EXIT_SUCCESS; -} - -template<class TInputPixel, class TOutputPixel, class TFunction> -int generic_SinclairReciprocalImageFilterWithCast(int argc, char * argv[]) -{ - const char * outputFilename = argv[4]; - - typedef otb::VectorImage<TOutputPixel> OutputImageType; - typedef otb::VectorImage<typename TOutputPixel::value_type> OutputRealImageType; - typedef otb::ImageFileWriter<OutputRealImageType> WriterType; - typedef typename otb::ComplexToVectorImageCastFilter<OutputImageType, OutputRealImageType> CasterType; - - generic_SinclairReciprocalImageFilterMacro( TInputPixel, TOutputPixel, TFunction, argc, argv); - - typename WriterType::Pointer writer = WriterType::New(); - typename CasterType::Pointer caster = CasterType::New(); - - writer->SetFileName(outputFilename); - caster->SetInput( filter->GetOutput() ); - writer->SetInput( caster->GetOutput() ); + writer->SetInput( extract->GetOutput() ); writer->Update(); return EXIT_SUCCESS; @@ -142,30 +103,30 @@ int otbSinclairReciprocalImageFilter(int argc, char * argv[]) typedef std::complex <double> InputPixelType; typedef std::complex <double> OutputPixelType; typedef double OutputRealPixelType; - + typedef otb::Image<InputPixelType, Dimension> InputImageType; typedef otb::VectorImage<OutputPixelType, Dimension> OutputImageType; typedef otb::VectorImage<OutputRealPixelType, Dimension> OutputRealImageType; - + std::string strArgv(argv[1]); argc--; argv++; if (strArgv == "SinclairToReciprocalCovarianceMatrix") - return (generic_SinclairReciprocalImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairReciprocalImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToReciprocalCircularCovarianceMatrix") - return (generic_SinclairReciprocalImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairReciprocalImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToReciprocalCircularCovarianceMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType, OutputImageType::PixelType> > (argc, argv)); else if (strArgv == "SinclairToReciprocalCoherencyMatrix") - return (generic_SinclairReciprocalImageFilterWithCast<InputPixelType, OutputPixelType, + return (generic_SinclairReciprocalImageFilter<InputPixelType, OutputPixelType, otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor<InputImageType::PixelType, InputImageType::PixelType, InputImageType::PixelType,