From 3f6bd809d2a9dde388417468b2349f6cb129f3be Mon Sep 17 00:00:00 2001
From: Otmane Lahlou <otmane.lahlou@c-s.fr>
Date: Tue, 12 May 2009 11:45:44 +0200
Subject: [PATCH] ENH : last update for the segment between segment 
 computation

---
 ...eSpatialObjectListToRightAnglePointSetFilter.txx | 13 ++++++++++---
 Examples/FeatureExtraction/CMakeLists.txt           |  4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx b/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx
index 84b0283b9e..ab1934f837 100644
--- a/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx
+++ b/Code/FeatureExtraction/otbLineSpatialObjectListToRightAnglePointSetFilter.txx
@@ -38,7 +38,7 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet>
   this->SetNumberOfRequiredOutputs(1);
 
   m_ThresholdDistance = 20.;
-  m_ThresholdAngle = M_PI/36.;  //36 cause we want 5 degrees threshold
+  m_ThresholdAngle = M_PI/30.;  //36 cause we want 6 degrees threshold
 }
 
 /**
@@ -116,8 +116,15 @@ LineSpatialObjectListToRightAnglePointSetFilter<TImage,TLinesList ,TPointSet>
 		  RightAngleCoordinate = this->ComputeAngleRightCoordinate(*itLinesListTest, *itLinesListCur);
 		  
 		  /** Compute the distance between the two segments and the right angle formed by this segments*/
-		  if(this->ComputeDistanceFromPointToSegment(RightAngleCoordinate,*itLinesListTest) <m_ThresholdDistance &&
-		     this->ComputeDistanceFromPointToSegment(RightAngleCoordinate,*itLinesListCur) <m_ThresholdDistance)
+		  double dist1 = this->ComputeDistanceFromPointToSegment(RightAngleCoordinate,*itLinesListTest);
+		  double dist2 = this->ComputeDistanceFromPointToSegment(RightAngleCoordinate,*itLinesListCur) ;
+		  
+		  /** Use Pythagore to compute the distance between the two segments*/
+		  double SegmentDistance = vcl_sqrt(dist1*dist1 + dist2*dist2);
+		  
+// 		  if(this->ComputeDistanceFromPointToSegment(RightAngleCoordinate,*itLinesListTest) <m_ThresholdDistance &&
+// 		     this->ComputeDistanceFromPointToSegment(RightAngleCoordinate,*itLinesListCur) <m_ThresholdDistance)
+		  if(SegmentDistance < m_ThresholdDistance)
 		    {
 		      /** If Right Angle & not so far from segments:  Add it to the pointSet*/
 		      this->AddRightAngleToPointSet(RightAngleCoordinate , *itLinesListTest , *itLinesListCur );
diff --git a/Examples/FeatureExtraction/CMakeLists.txt b/Examples/FeatureExtraction/CMakeLists.txt
index 6306a0359d..aa321a3592 100644
--- a/Examples/FeatureExtraction/CMakeLists.txt
+++ b/Examples/FeatureExtraction/CMakeLists.txt
@@ -348,8 +348,8 @@ ADD_TEST(RightAngleDetectionExample  ${EXE_TESTS2}
 	${TEMP}/RighAngleOutput.tif
 	${TEMP}/PrettyRightAngleInput.png	
 	${TEMP}/PrettyRightAngleOutput.png
-	0.09
-	20.
+	0.1
+	35.
 )
 
 ADD_EXECUTABLE(otbFeatureExtractionExamplesTests1 otbFeatureExtractionExamplesTests1.cxx)
-- 
GitLab