From 1eaeaf60e91136e614e5f775d6b4d0c7a2710db8 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@orfeo-toolbox.org>
Date: Wed, 22 Feb 2012 13:43:00 +0100
Subject: [PATCH] ENH: Make the application output the disparity interval
 corresponding to min/max in DEM (in avgdem mode)

---
 .../otbStereoRectificationGridGenerator.cxx      | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx b/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx
index 3e62f0b47d..fe6e13f1a7 100644
--- a/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx
+++ b/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx
@@ -154,6 +154,14 @@ private:
     AddParameter(ParameterType_Float,"epi.elevation.avgdem.value","Average elevation value");
     SetParameterDescription("epi.elevation.avgdem.value","Average elevation value estimated from DEM");
     SetParameterRole("epi.elevation.avgdem.value",Role_Output);
+
+    AddParameter(ParameterType_Float,"epi.elevation.avgdem.mindisp","Minimum disparity from DEM");
+    SetParameterDescription("epi.elevation.avgdem.mindisp","Disparity corresponding to estimated minimum elevation over the left image");
+    SetParameterRole("epi.elevation.avgdem.mindisp",Role_Output);
+
+    AddParameter(ParameterType_Float,"epi.elevation.avgdem.maxdisp","Maximum disparity from DEM");
+    SetParameterDescription("epi.elevation.avgdem.maxdisp","Disparity corresponding to estimated maximum elevation over the left image");
+    SetParameterRole("epi.elevation.avgdem.maxdisp",Role_Output);
     
     AddChoice("epi.elevation.dem","Elevation from DEM");
     SetParameterDescription("epi.elevation.dem","Local elevations from the provided DEM");
@@ -279,6 +287,14 @@ private:
     SetParameterInt("epi.rectsizey",m_DeformationFieldSource->GetRectifiedImageSize()[1]);
     SetParameterFloat("epi.baseline",m_DeformationFieldSource->GetMeanBaselineRatio());
 
+    if(GetParameterString("epi.elevation") == "avgdem")
+      {
+      SetParameterFloat("epi.elevation.avgdem.mindisp",(m_StatisticsFilter->GetMinimum()-m_StatisticsFilter->GetMean())
+                        /m_DeformationFieldSource->GetMeanBaselineRatio());
+      SetParameterFloat("epi.elevation.avgdem.maxdisp",(m_StatisticsFilter->GetMaximum()-m_StatisticsFilter->GetMean())
+                        /m_DeformationFieldSource->GetMeanBaselineRatio());
+      }
+    
 
     SetParameterOutputImage("io.outleft",m_DeformationFieldSource->GetLeftDeformationFieldOutput());
     SetParameterOutputImage("io.outright",m_DeformationFieldSource->GetRightDeformationFieldOutput());
-- 
GitLab