diff --git a/Testing/Code/Radiometry/CMakeLists.txt b/Testing/Code/Radiometry/CMakeLists.txt index 054d1e9136577cf1f4609b957bfc413bc34680e1..52a141d1cdde17dd1c2bfd9b9ea9a8df2ab844a2 100644 --- a/Testing/Code/Radiometry/CMakeLists.txt +++ b/Testing/Code/Radiometry/CMakeLists.txt @@ -1504,6 +1504,13 @@ ADD_TEST(raTvSarRadiometricCalibrationToImageWithComplexPixelFilter_TSX_PANGKALA 1000 1000 250 250 # Extract ) +ADD_TEST(raTvSarRadiometricCalibrationToImageCompareFilter_TSX_PANGKALANBUUN ${RADIOMETRY_TESTS9} + otbSarRadiometricCalibrationToImageFilterCompareTest + ${LARGEINPUT}/TERRASARX/PANGKALANBUUN/IMAGEDATA/IMAGE_HH_SRA_stripFar_008.cos + 1000 1000 250 250 # Extract +) + + ADD_TEST(raTvSarRadiometricCalibrationToImageWithComplexPixelFilter_TSX_TORONTO ${RADIOMETRY_TESTS9} --compare-image ${EPSILON_12} ${BASELINE}/raTvSarRadiometricCalibrationToImageFilter_TSX_TORONTO.tif @@ -1676,6 +1683,7 @@ otbSarBrightnessFunctor.cxx otbSarBrightnessFunction.cxx otbSarBrightnessToImageFilterTest.cxx otbTestVNLMinimize.cxx +otbSarRadiometricCalibrationToImageFilterCompareTest.cxx ) diff --git a/Testing/Code/Radiometry/otbRadiometryTests9.cxx b/Testing/Code/Radiometry/otbRadiometryTests9.cxx index 2feacadd2a535c43667d7d71235729ec6f242b07..74c345a8df03c1a6bca1f42f54f8ecdb0d8d487b 100644 --- a/Testing/Code/Radiometry/otbRadiometryTests9.cxx +++ b/Testing/Code/Radiometry/otbRadiometryTests9.cxx @@ -44,4 +44,5 @@ void RegisterTests() REGISTER_TEST(otbSarBrightnessFunction); REGISTER_TEST(otbSarBrightnessToImageFilterTest); REGISTER_TEST(otbTestVNLMinimize); + REGISTER_TEST(otbSarRadiometricCalibrationToImageFilterCompareTest); } diff --git a/Testing/Code/Radiometry/otbSarRadiometricCalibrationToImageFilterCompareTest.cxx b/Testing/Code/Radiometry/otbSarRadiometricCalibrationToImageFilterCompareTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..973ef954f33d2511e2499efa9de55ad011a192ce --- /dev/null +++ b/Testing/Code/Radiometry/otbSarRadiometricCalibrationToImageFilterCompareTest.cxx @@ -0,0 +1,93 @@ +/*========================================================================= + + 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 "otbImage.h" +#include "otbSarRadiometricCalibrationToImageFilter.h" +#include "otbImageFileReader.h" +#include "otbExtractROI.h" +#include "itkComplexToModulusImageFilter.h" +#include "otbStreamingCompareImageFilter.h" + +int otbSarRadiometricCalibrationToImageFilterCompareTest(int argc, char * argv[]) +{ + const unsigned int Dimension = 2; + typedef float RealType; + typedef std::complex<RealType> PixelType; + typedef otb::Image<PixelType, Dimension> InputImageType; + typedef otb::Image<RealType, Dimension> OutputImageType; + typedef otb::ImageFileReader<InputImageType> ReaderType; + typedef otb::SarRadiometricCalibrationToImageFilter<InputImageType, OutputImageType> FilterComplexType; + typedef otb::SarRadiometricCalibrationToImageFilter<OutputImageType, OutputImageType> FilterRealType; + typedef otb::ExtractROI<RealType, RealType> ExtractorType; + typedef itk::ComplexToModulusImageFilter<InputImageType, OutputImageType> ModulusType; + typedef otb::StreamingCompareImageFilter<OutputImageType> CompareFilterType; + + // Instantiating object + FilterComplexType::Pointer filterComplex = FilterComplexType::New(); + FilterRealType::Pointer filterReal = FilterRealType::New(); + ReaderType::Pointer reader = ReaderType::New(); + ExtractorType::Pointer extractorComplex = ExtractorType::New(); + ExtractorType::Pointer extractorReal = ExtractorType::New(); + ModulusType::Pointer modulus = ModulusType::New(); + CompareFilterType::Pointer compare = CompareFilterType::New(); + + reader->SetFileName(argv[1]); + filterComplex->SetInput(reader->GetOutput()); + + modulus->SetInput(reader->GetOutput()); + filterReal->SetInput(modulus->GetOutput()); + + filterComplex->UpdateOutputInformation(); + filterReal->UpdateOutputInformation(); + + if (argc > 2) + { + // Generate an extract from the large input + OutputImageType::RegionType region; + OutputImageType::IndexType id; + id[0] = atoi(argv[2]); id[1] = atoi(argv[3]); + OutputImageType::SizeType size; + size[0] = atoi(argv[4]); size[1] = atoi(argv[5]); + region.SetIndex(id); + region.SetSize(size); + + extractorComplex->SetExtractionRegion(region); + extractorComplex->SetInput(filterComplex->GetOutput()); + + extractorReal->SetExtractionRegion(region); + extractorReal->SetInput(filterReal->GetOutput()); + + compare->SetInput1(extractorComplex->GetOutput()); + compare->SetInput2(extractorReal->GetOutput()); + } + else + { + compare->SetInput1(filterComplex->GetOutput()); + compare->SetInput2(filterReal->GetOutput()); + } + + compare->Update(); + if(compare->GetMAE() > 0.00000001) + { + std::cout << "MAE : " << compare->GetMAE() << std::endl; + return EXIT_FAILURE; + } + + + return EXIT_SUCCESS; +}