Skip to content
Snippets Groups Projects
Commit 7b2b61ea authored by Gaëlle USSEGLIO's avatar Gaëlle USSEGLIO
Browse files

UPDATE: Correction for origin/spacing into SARDEMToAmplitude and Add some tests

parent dad4d6b7
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 2.8.9)
project(DiapOTBModule)
#set(DiapOTBModule_LIBRARIES DiapOTBModule)
......@@ -15,4 +15,4 @@ endif()
# Execute and Copy during installation
install(DIRECTORY python_src DESTINATION ${CMAKE_INSTALL_PREFIX})
install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_diapOTBEnv.sh ${CMAKE_INSTALL_PREFIX})")
install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/diapOTBEnv.sh PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ DESTINATION ${CMAKE_INSTALL_PREFIX})
......@@ -157,7 +157,7 @@ public:
}
// Loop on colunm
for (int k = std::max(col1, firstCol_into_outputRegion); k<= std::min(col2, nbCol_into_outputRegion); k++)
for (int k = std::max(col1, firstCol_into_outputRegion); k<= std::min(col2, nbCol_into_outputRegion+firstCol_into_outputRegion); k++)
{
a = (cS - k) / dc;
b = 1.0 - a;
......
......@@ -206,11 +206,6 @@ protected:
// SAR Image KeyWorldList
ImageKeywordlist m_SarImageKwl;
// Information about SAR Image
std::string m_SatellitePass;
unsigned int m_NbColSAR;
unsigned int m_NbLineSAR;
// Multiplying gain to obtain a mean radiometry at 100
double m_Gain;
......
......@@ -55,12 +55,6 @@ namespace otb
// Check if sarImageKWL not NULL
assert(&sarImageKWL && "SAR Image Metadata don't exist.");
m_SarImageKwl = sarImageKWL;
// satellite Pass (ascending or descending)
m_SatellitePass = m_SarImageKwl.GetMetadataByKey("support_data.orbit_pass");
// NbCol and NbLine
m_NbColSAR = atoi(m_SarImageKwl.GetMetadataByKey("support_data.number_samples").c_str());
m_NbLineSAR = atoi(m_SarImageKwl.GetMetadataByKey("support_data.number_lines").c_str());
}
/**
......@@ -130,7 +124,14 @@ namespace otb
// Set the margin
int nbLinesSAR = m_SarImagePtr->GetLargestPossibleRegion().GetSize()[1];
int nbLinesDEM = m_DemImagePtr->GetLargestPossibleRegion().GetSize()[1];
m_Margin = (nbLinesSAR/nbLinesDEM)*5;
if (nbLinesSAR > nbLinesDEM)
{
m_Margin = (nbLinesSAR/nbLinesDEM)*5;
}
else
{
m_Margin = 100;
}
}
/**
......@@ -158,24 +159,23 @@ namespace otb
{
// Call superclass implementation
Superclass::GenerateOutputInformation();
//Superclass::GenerateInputRequestedRegion();
// Get pointers to the input and output
ImageInConstPointer inputPtr = this->GetInput();
ImageOutPointer outputPtr = this->GetOutput();
// The output is defined with the m_SarImageKwl
// Origin, Spacing and Size (image geometry)
// Origin, Spacing and Size (SAR image geometry)
ImageOutSizeType outputSize;
outputSize[0] = m_NbColSAR;
outputSize[1] = m_NbLineSAR;
outputSize[0] = m_SarImagePtr->GetLargestPossibleRegion().GetSize()[0];
outputSize[1] = m_SarImagePtr->GetLargestPossibleRegion().GetSize()[1];
ImageOutPointType outOrigin;
outOrigin.Fill(0.5);
outOrigin = m_SarImagePtr->GetOrigin();
ImageOutSpacingType outSP;
outSP.Fill(1);
outSP = m_SarImagePtr->GetSpacing();
// Define Output Largest Region
ImageOutRegionType outputLargestPossibleRegion = inputPtr->GetLargestPossibleRegion();
ImageOutRegionType outputLargestPossibleRegion = m_SarImagePtr->GetLargestPossibleRegion();
outputLargestPossibleRegion.SetSize(outputSize);
outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion);
outputPtr->SetOrigin(outOrigin);
......@@ -197,8 +197,8 @@ namespace otb
// Use the image transformations to insure an input requested region
// that will provide the proper range
const ImageOutSizeType & outputRequestedRegionSize = outputRegion.GetSize();
const ImageOutIndexType & outputRequestedRegionIndex = outputRegion.GetIndex();
ImageOutIndexType outputRequestedRegionIndex = outputRegion.GetIndex();
// Here we are breaking traditional pipeline steps because we need to access the input field data
// so as to compute the input image requested region
// The inverse localisation (SAR to DEM) is performed in order to determine the DEM region (input)
......@@ -208,8 +208,12 @@ namespace otb
int nbLinesDEM = m_DemImagePtr->GetLargestPossibleRegion().GetSize()[1];
// Margin to apply on inverse localisation for the four sides.
int margin = std::max(nbColDEM, nbLinesDEM)*0.01; // %1 of the largest dimension
int margin = 100;
if (std::max(nbColDEM, nbLinesDEM) > 2000)
{
margin = std::max(nbColDEM, nbLinesDEM)*0.01; // %1 of the largest dimension
}
// Indice for the SAR bloc (determined by the Pipeline)
ImageOutIndexType id[4] ;
id[0][0] = outputRequestedRegionIndex[0];
......@@ -673,7 +677,7 @@ namespace otb
{
// Compute corresponding input region
ImageInRegionType inputRegionForThread = OutputRegionToInputRegion(outputRegionForThread);
// Iterator on output (SAR geometry)
OutputIterator OutIt(this->GetOutput(), outputRegionForThread);
......@@ -681,7 +685,7 @@ namespace otb
const ImageOutSizeType & outputRegionForThreadSize = outputRegionForThread.GetSize();
unsigned int nbCol = static_cast<unsigned int>(outputRegionForThreadSize[0]);
unsigned int firstCol = static_cast<unsigned int>(outputRegionForThread.GetIndex()[0]);
unsigned int firstCol = static_cast<unsigned int>(outputRegionForThread.GetIndex()[0]+this->GetOutput()->GetOrigin()[0]);
const ImageInSizeType & inputRegionForThreadSize = inputRegionForThread.GetSize();
unsigned int nbDEMLines = static_cast<unsigned int>(inputRegionForThreadSize[1]);
......@@ -740,7 +744,7 @@ namespace otb
{
OutIt.GoToBeginOfLine();
// indice of current line
int ind_Line = OutIt.GetIndex()[1];
int ind_Line = OutIt.GetIndex()[1] + int(this->GetOutput()->GetOrigin()[1]);
///////////////////////////// Polygon Construction and Check intersection /////////////////////////////
InIt_UL.GoToBegin();
......
......@@ -56,6 +56,19 @@ otb_add_test(NAME otbSARStreamingDEMInformationFilterTest
${DATA_TEST}/s1a_s6_slc_0180416T195057_vv_cap_verde.tif
)
otb_add_test(NAME otbSARAmplitudeEstimationImageFilterTest
COMMAND otbDiapasonModuleTestDriver otbSARAmplitudeEstimationImageFilterTest
${OUTPUT_TEST}/otbSARDEMProjectionImageFilterTestOutput.tif
${DATA_TEST}/N14W025.hgt
${DATA_TEST}/s1a_s6_slc_0180416T195057_vv_cap_verde.tif
99.0213
1
-1
${OUTPUT_TEST}/otbSARAmplitudeEstimationImageFilterTestOutput.tif
)
set_tests_properties(otbSARAmplitudeEstimationImageFilterTest PROPERTIES DEPENDS otbSARDEMProjectionImageFilterTest)
#test application
otb_test_application(NAME otbSARMultiLookTest
APP SARMultiLook
......@@ -70,3 +83,30 @@ otb_test_application(NAME otbSARDoppler0Test
OPTIONS -in ${DATA_TEST}/s1a_s6_slc_0180416T195057_vv_cap_verde.tif
-outfile ${OUTPUT_TEST}/otbSARDoppler0TestOutput.txt)
otb_test_application(NAME otbSARDEMProjectionTest
APP SARDEMProjection
OPTIONS -indem ${DATA_TEST}/N14W025.hgt
-insar ${DATA_TEST}/s1a_s6_slc_0180416T195057_vv_cap_verde.tif
-out ${OUTPUT_TEST}/otbSARDEMProjectionTestOutput.tif)
set_tests_properties(otbSARDEMProjectionTest PROPERTIES ENVIRONMENT OTB_GEOID_FILE=${DATA_TEST}/egm96.grd)
otb_test_application(NAME otbSARAmplitudeEstimationTest
APP SARAmplitudeEstimation
OPTIONS -indem ${DATA_TEST}/N14W025.hgt
-insar ${DATA_TEST}/s1a_s6_slc_0180416T195057_vv_cap_verde.tif
-indemproj ${OUTPUT_TEST}/otbSARDEMProjectionTestOutput.tif
-ingain 99.0213
-indirectiondemc 1
-indirectiondeml -1
-out ${OUTPUT_TEST}/otbSARAmplitudeEstimationTestOutput.tif)
set_tests_properties(otbSARAmplitudeEstimationTest PROPERTIES DEPENDS otbSARDEMProjectionTest)
otb_test_application(NAME otbSARDEMToAmplitudeTest
APP SARDEMToAmplitude
OPTIONS -indem ${DATA_TEST}/N14W025.hgt
-insar ${DATA_TEST}/s1a_s6_slc_0180416T195057_vv_cap_verde.tif
-out ${OUTPUT_TEST}/otbSARDEMToAmplitudeTestOutput.tif)
set_tests_properties(otbSARDEMToAmplitudeTest PROPERTIES ENVIRONMENT OTB_GEOID_FILE=${DATA_TEST}/egm96.grd)
......@@ -30,10 +30,10 @@
int otbSARAmplitudeEstimationImageFilterTest(int argc, char * argv[])
{
// Verify the number of parameters in the command line
if (argc != 5)
if (argc != 8)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputVectorFile inputDEMFile inputSARImageFile outputImageFile" << std::endl;
std::cerr << argv[0] << " inputVectorFile inputDEMFile inputSARImageFile inputGain intputDirectionC inputDirectionL outputImageFile" << std::endl;
return EXIT_FAILURE;
}
......@@ -69,18 +69,20 @@ int otbSARAmplitudeEstimationImageFilterTest(int argc, char * argv[])
reader_SAR->SetFileName(argv[3]);
// Writer argument
writer->SetFileName(argv[4]);
writer->SetFileName(argv[7]);
//double gain = atof(argv[4].c_str());
double gain = 75.0884;
// Retrive DEM informations (values for cap_verde image from data repository)
double gain = atof(argv[4]);
int directionC = atoi(argv[5]);
int directionL = atoi(argv[6]);;
// Start the first pipelines (Read SAR image metedata and MNT metadata)
ImageSARInType::Pointer SARPtr = reader_SAR->GetOutput();
reader_SAR->UpdateOutputInformation();
ImageMNTInType::Pointer MNTPtr = reader_MNT->GetOutput();
reader_MNT->UpdateOutputInformation();
// Instanciate the filter (use SARDEMPolygonsAnalysisImageFilter with SARAmplitudeEstimationFunctor
// Instanciate the filter (use SARDEMPolygonsAnalysisImageFilter with SARAmplitudeEstimationFunctor
// to estimate amplitude image)
typedef otb::SARDEMPolygonsAnalysisImageFilter<ImageVectorType, ImageOutType, ImageMNTInType, ImageSARInType, AmpFunctorType> FilterType;
FilterType::Pointer filter = FilterType::New();
......@@ -88,7 +90,7 @@ int otbSARAmplitudeEstimationImageFilterTest(int argc, char * argv[])
filter->SetSARImageKeyWorList(SARPtr->GetImageKeywordlist());
filter->SetSARImagePtr(SARPtr);
filter->SetDEMImagePtr(MNTPtr);
filter->SetDEMInformation(gain,1, 1);
filter->SetDEMInformation(gain,directionC, directionL);
filter->initializeMarginAndRSTransform();
std::cout<<"Print AmplitudeEstimation filter information: "<< std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment