Commit 3862946c authored by Jonathan Guinet's avatar Jonathan Guinet

ENH: StereoSensorModelToElevationMap has been removed

parent 369fc562
OTB_CREATE_APPLICATION(NAME StereoSensorModelToElevationMap
SOURCES otbStereoSensorModelToElevationMap.cxx
LINK_LIBRARIES OTBIO;OTBCommon;OTBBasicFilters)
OTB_CREATE_APPLICATION(NAME FineRegistration
SOURCES otbFineRegistration.cxx
LINK_LIBRARIES OTBIO;OTBCommon;OTBBasicFilters)
......
/*=========================================================================
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 "otbImage.h"
#include "otbStereoSensorModelToElevationMapFilter.h"
#include "otbImageList.h"
#include "otbImageListToVectorImageFilter.h"
#include "otbVectorImage.h"
#include "otbVectorImageToIntensityImageFilter.h"
#include "itkDiscreteGaussianImageFilter.h"
// Elevation handler
#include "otbWrapperElevationParametersHandler.h"
namespace otb
{
namespace Wrapper
{
class StereoSensorModelToElevationMap : public Application
{
public:
/** Standard class typedefs. */
typedef StereoSensorModelToElevationMap Self;
typedef Application Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Standard macro */
itkNewMacro(Self);
itkTypeMacro(StereoSensorModelToElevationMap, otb::Application);
/** Filters typedef */
typedef otb::Image<short, 2> ImageType;
typedef otb::Image<float, 2> HeightImageType;
typedef itk::DiscreteGaussianImageFilter<ImageType, ImageType> GaussianFilterType;
typedef otb::StereoSensorModelToElevationFilter<ImageType, HeightImageType> StereoFilterType;
typedef otb::VectorImage<float, 2> VectorImageType;
typedef otb::ImageList<HeightImageType> ImageListType;
typedef otb::ImageListToVectorImageFilter<ImageListType, VectorImageType> IL2VIFilterType;
/* conversion from VectorImage to Intensity Image */
typedef otb::VectorImageToIntensityImageFilter<FloatVectorImageType, ImageType> IntensityFilterType;
private:
void DoInit()
{
SetName("StereoSensorModelToElevationMap");
SetDescription("Convert a stereo sensor model to elevation map.");
// Documentation
SetDocName("Stereo sensor model to elevation map");
SetDocLongDescription("Produce an elevation map from a pair of stereo images along-track by implicit exploration of their epipolar lines.");
SetDocLimitations("None");
SetDocAuthors("OTB-Team");
SetDocSeeAlso(" ");
AddDocTag(Tags::Stereo);
// Mandatory parameters
AddParameter(ParameterType_InputImage, "ref", "Reference");
SetParameterDescription("ref", "The reference image.");
AddParameter(ParameterType_InputImage, "sec", "Secondary");
SetParameterDescription("sec", "The secondary image.");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "The output image.");
// Optional parameters
AddRAMParameter();
AddParameter(ParameterType_Int, "r", "Radius");
SetParameterDescription("r", "Radius (in pixels) of the metric computation window (default is 3).");
SetDefaultParameterInt("r", 3);
SetMinimumParameterIntValue("r", 0);
MandatoryOff("r");
AddParameter(ParameterType_Float, "ct", "Correlation Threshold");
SetParameterDescription("ct", "Threshold bellow which correlation is considered invalid (default is 0.7).");
SetDefaultParameterFloat("ct", 0.7);
SetMinimumParameterFloatValue("ct", 0.0);
MandatoryOff("ct");
AddParameter(ParameterType_Float, "vt", "Variance Threshold");
SetParameterDescription("vt", "Threshold on the master patch variance bellow which no height exploration is performed (default is 4).");
SetDefaultParameterFloat("vt", 4.0);
SetMinimumParameterFloatValue("vt", 0.0);
MandatoryOff("vt");
AddParameter(ParameterType_Float, "minh", "MinHeightOffset");
SetParameterDescription("minh", "Minimum height offset with respect to local initial height for height exploration (default is -20 meters).");
SetDefaultParameterFloat("minh", -20.0);
MandatoryOff("minh");
AddParameter(ParameterType_Float, "maxh", "MaxHeightOffset");
SetParameterDescription("maxh", "Maximum height offset with respect to local initial height for height exploration (default is 20 meters).");
SetDefaultParameterFloat("maxh", 20.0);
MandatoryOff("maxh");
AddParameter(ParameterType_Float, "step", "HeightStep");
SetParameterDescription("step", "Step of height exploration (default is 1 meter).");
SetDefaultParameterFloat("step", 1.0);
SetMinimumParameterFloatValue("step", 0.0);
MandatoryOff("step");
AddParameter(ParameterType_Float, "ae", "AverageElevation");
SetParameterDescription("ae", "If no DEM is used, provide the initial height value (default is 0 meters)");
SetDefaultParameterFloat("ae", 0.0);
MandatoryOff("ae");
// Elevation
ElevationParametersHandler::AddElevationParameters(this, "elev");
AddParameter(ParameterType_Float, "rgs", "ReferenceGaussianSmoothing");
SetParameterDescription("rgs", "(optional) Perform a gaussian smoothing of the reference image. Parameter is gaussian sigma (in pixels). Default is no smoothing.");
SetDefaultParameterFloat("rgs", 1.0);
SetMinimumParameterFloatValue("rgs", 0.0);
MandatoryOff("rgs");
DisableParameter("rgs");
AddParameter(ParameterType_Float, "sgs", "SecondaryGaussianSmoothing");
SetParameterDescription("sgs", "(optional) Perform a gaussian smoothing of the secondary image. Parameter is gaussian sigma (in pixels). Default is no smoothing.");
SetDefaultParameterFloat("sgs", 1.0);
SetMinimumParameterFloatValue("sgs", 0.0);
MandatoryOff("sgs");
DisableParameter("sgs");
AddParameter(ParameterType_Empty, "s", "SubtractInitialHeight");
SetParameterDescription("s", "If activated, the elevation map will contain only the estimated height offset from the initial height (either average elevation or DEM)");
MandatoryOff("s"); // Not necessary, already optional by default
// Doc example parameter settings
SetDocExampleParameterValue("ref", "sensor_stereo_left.tif");
SetDocExampleParameterValue("sec", "sensor_stereo_right.tif");
SetDocExampleParameterValue("out", "StereoSensorModelToElevationMap.tif");
SetDocExampleParameterValue("elev", "dem");
SetDocExampleParameterValue("elev.dem.path", "DEM_srtm");
SetDocExampleParameterValue("elev.dem.geoid", "DEM_srtm/egm96.grd");
}
void DoUpdateParameters()
{
// The algorithm needs at least 1 samples in the height exploration
if (GetParameterFloat("minh") > GetParameterFloat("maxh"))
{
SetParameterFloat("maxh", GetParameterFloat("minh") + GetParameterFloat("step"));
}
}
void DoExecute()
{
bool referenceSmoothing = IsParameterEnabled("rgs");
bool secondarySmoothing = IsParameterEnabled("sgs");
bool subtractInitialHeight = IsParameterEnabled("s");
FloatVectorImageType::Pointer inputRef = GetParameterImage("ref");
FloatVectorImageType::Pointer inputSec = GetParameterImage("sec");
m_Intensity1 = IntensityFilterType::New();
m_Intensity1->SetInput(inputRef);
m_Intensity2 = IntensityFilterType::New();
m_Intensity2->SetInput(inputSec);
m_Sigma1.Fill(GetParameterFloat("rgs"));
m_Sigma2.Fill(GetParameterFloat("sgs"));
m_Gaussian1 = GaussianFilterType::New();
m_Gaussian1->SetInput(m_Intensity1->GetOutput());
m_Gaussian1->SetVariance(m_Sigma1);
m_Gaussian1->SetUseImageSpacingOff();
m_Gaussian2 = GaussianFilterType::New();
m_Gaussian2->SetInput(m_Intensity2->GetOutput());
m_Gaussian2->SetVariance(m_Sigma2);
m_Gaussian2->SetUseImageSpacingOff();
StereoFilterType::Pointer m_StereoFilter = StereoFilterType::New();
if(referenceSmoothing)
{
m_StereoFilter->SetMasterInput(m_Gaussian1->GetOutput());
}
else
{
m_StereoFilter->SetMasterInput(m_Intensity1->GetOutput());
}
if(secondarySmoothing)
{
m_StereoFilter->SetSlaveInput(m_Gaussian2->GetOutput());
}
else
{
m_StereoFilter->SetSlaveInput(m_Intensity2->GetOutput());
}
// Setup the DEM Handler
otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev");
m_StereoFilter->SetSubtractInitialElevation(subtractInitialHeight);
m_StereoFilter->SetLowerElevation(GetParameterFloat("minh"));
m_StereoFilter->SetHigherElevation(GetParameterFloat("maxh"));
m_StereoFilter->SetCorrelationThreshold(GetParameterFloat("ct"));
m_StereoFilter->SetVarianceThreshold(GetParameterFloat("vt"));
m_StereoFilter->SetElevationStep(GetParameterFloat("step"));
m_StereoFilter->SetRadius(GetParameterInt("r"));
AddProcess(m_StereoFilter,"Processing elevation");
m_StereoFilter->Update();
ImageListType::Pointer il = ImageListType::New();
il->PushBack(m_StereoFilter->GetOutput());
il->PushBack(m_StereoFilter->GetCorrelationOutput());
IL2VIFilterType::Pointer m_Il2vi = IL2VIFilterType::New();
m_Il2vi->SetInput(il);
m_Il2vi->Update();
SetParameterOutputImage("out", m_Il2vi->GetOutput());
}
/* Members */
IntensityFilterType::Pointer m_Intensity1;
IntensityFilterType::Pointer m_Intensity2;
GaussianFilterType::ArrayType m_Sigma1;
GaussianFilterType::ArrayType m_Sigma2;
GaussianFilterType::Pointer m_Gaussian1;
GaussianFilterType::Pointer m_Gaussian2;
StereoFilterType::Pointer m_StereoFilter;
IL2VIFilterType::Pointer m_Il2vi;
};
}
}
OTB_APPLICATION_EXPORT(otb::Wrapper::StereoSensorModelToElevationMap)
SET(EPSILON_10 0.0000000001)
SET(BASELINE_EXAMPLE ${OTB_DATA_ROOT}/Baseline/Examples/DisparityMap)
SET(DEM_DATA ${OTB_DATA_ROOT}/Input/DEM/srtm_directory)
#--- StereoSensorModelToElevationMap ---#
OTB_TEST_APPLICATION(NAME apTvDmStereoSensorModelToElevationMapTest
APP StereoSensorModelToElevationMap
OPTIONS -ref ${EXAMPLEDATA}/sensor_stereo_left.tif
-sec ${EXAMPLEDATA}/sensor_stereo_right.tif
-out ${TEMP}/apTvDmStereoSensorModelToElevationMapTest.tif
-r 3
-ct 0.7
-vt 4.0
-minh -20.0
-maxh 20.0
-step 1.0
-elev.dem ${INPUTDATA}/DEM/srtm_directory/
-elev.geoid ${INPUTDATA}/DEM/egm96.grd
VALID --compare-image ${EPSILON_10}
${BASELINE}/apTvDmStereoSensorModelToElevationMapTest.tif
${TEMP}/apTvDmStereoSensorModelToElevationMapTest.tif)
OTB_TEST_APPLICATION(NAME apTvDmStereoSensorModelToElevationMapWithSmoothing
APP StereoSensorModelToElevationMap
OPTIONS -ref ${EXAMPLEDATA}/sensor_stereo_left.tif
-sec ${EXAMPLEDATA}/sensor_stereo_right.tif
-out ${TEMP}/apTvDmStereoSensorModelToElevationMapWithSmoothing.tif
-r 3
-ct 0.7
-vt 4.0
-minh -20.0
-maxh 20.0
-step 1.0
-elev.dem ${INPUTDATA}/DEM/srtm_directory/
-elev.geoid ${INPUTDATA}/DEM/egm96.grd
-rgs 2.0
-sgs 2.0
VALID --compare-image ${EPSILON_10}
${BASELINE}/apTvDmStereoSensorModelToElevationMapWithSmoothing.tif
${TEMP}/apTvDmStereoSensorModelToElevationMapWithSmoothing.tif)
#--- FineRegistration ---#
OTB_TEST_APPLICATION(NAME apTvDmFineRegistrationTest
APP FineRegistration
......
/*=========================================================================
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 "otbWrapperApplicationRegistry.h"
int main(int argc,char* argv[])
{
using otb::Wrapper::ApplicationRegistry;
using otb::Wrapper::Application;
if (argc != 5)
{
std::cout << "Usage: 0000478-UncaughtException app_module_path stereo_ref stereo_sec output_file" << std::endl;
return 1;
}
ApplicationRegistry::SetApplicationPath(argv[1]);
Application::Pointer myApp = ApplicationRegistry::CreateApplication("StereoSensorModelToElevationMap");
if (myApp.IsNull())
{
std::cout << "Application not created" << std::endl;
return 1;
}
myApp->Init();
myApp->SetParameterString("ref", argv[2]);
myApp->SetParameterString("sec", argv[3]);
myApp->SetParameterString("out", argv[4]);
myApp->SetParameterString("elev.dem", "FAKE_DEM_PATH");
myApp->SetParameterString("elev.geoid", "FAKE_GEOID_PATH");
std::cout << "Try-catch section" << std::endl;
try
{
myApp->ExecuteAndWriteOutput();
}
catch(...)
{
std::cerr << "An unknown exception has been caught !" << std::endl;
}
return 0;
}
......@@ -5,11 +5,6 @@ TARGET_LINK_LIBRARIES(0000307-ExtractROICompareRegion OTBIO OTBCommon)
ADD_EXECUTABLE(0000479-WriteInt8Image 0000479-WriteInt8Image.cxx)
TARGET_LINK_LIBRARIES(0000479-WriteInt8Image OTBIO OTBCommon)
IF(BUILD_APPLICATIONS)
ADD_EXECUTABLE(0000478-UncaughtException 0000478-UncaughtException.cxx)
TARGET_LINK_LIBRARIES(0000478-UncaughtException OTBIO OTBCommon OTBApplicationEngine)
ENDIF(BUILD_APPLICATIONS)
ADD_EXECUTABLE(AlignementsQB AlignementsQB.cxx)
TARGET_LINK_LIBRARIES(AlignementsQB OTBFeatureExtraction OTBIO OTBCommon)
......
......@@ -268,14 +268,6 @@ ADD_TEST(FA-0000437-WriteImageCentOS ${CXX_TEST_PATH}/0000437-WriteImageCentOS
${OTB_DATA_ROOT}/Baseline/OTB/Fa/FA-0000437-WriteImageCentOSInput.tif
${TEMP}/FA-0000437-WriteImageCentOSOutput.tif)
IF(BUILD_APPLICATIONS)
ADD_TEST(NAME FA-000478-UncaughtException
COMMAND ${CXX_TEST_PATH}/0000478-UncaughtException
$<TARGET_FILE_DIR:otbapp_StereoSensorModelToElevationMap>
${OTB_DATA_ROOT}/Examples/sensor_stereo_left.tif
${OTB_DATA_ROOT}/Examples/sensor_stereo_right.tif
${TEMP}/FA-0000478-output.tif)
ENDIF(BUILD_APPLICATIONS)
ADD_TEST(NAME FA-0000495-StreamingImageFileWriterProgressReporting
COMMAND ${CXX_TEST_PATH}/0000495-StreamingImageFileWriterProgressReporting
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment