From 7fc6050a65ea6726b6394531de8a4d46c9ce72b0 Mon Sep 17 00:00:00 2001
From: Otmane Lahlou <otmane.lahlou@c-s.fr>
Date: Wed, 28 Jan 2009 13:46:28 +0100
Subject: [PATCH] ENH: fixing bugs otbCountImageFilter

---
 Code/BasicFilters/otbCountImageFilter.txx     |  2 --
 .../otbSiftFastImageFilter.txx                |  6 ++--
 .../otbSimplePointCountStrategy.h             | 28 +++++++++++--------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Code/BasicFilters/otbCountImageFilter.txx b/Code/BasicFilters/otbCountImageFilter.txx
index 016674514e..d03536bbef 100644
--- a/Code/BasicFilters/otbCountImageFilter.txx
+++ b/Code/BasicFilters/otbCountImageFilter.txx
@@ -71,8 +71,6 @@ CountImageFilter<TInputImage, TDetector, TCount, TOutputImage >
     itk::ImageRegionIterator<OutputImageType> 
                        itOutput(outputImage, outputImage->GetLargestPossibleRegion());
     
-    CountMethodType    CountMethod;
-    
     itInput.GoToBegin();
     itOutput.GoToBegin();
     
diff --git a/Code/FeatureExtraction/otbSiftFastImageFilter.txx b/Code/FeatureExtraction/otbSiftFastImageFilter.txx
index 342533fd76..04f677069f 100755
--- a/Code/FeatureExtraction/otbSiftFastImageFilter.txx
+++ b/Code/FeatureExtraction/otbSiftFastImageFilter.txx
@@ -43,13 +43,11 @@ namespace otb
   SiftFastImageFilter<TInputImage,TOutputPointSet>
   ::GenerateData()
   {
+    
     // Get the input image pointer
     const InputImageType *     inputPtr       = this->GetInput();
     OutputPointSetPointerType  outputPointSet = this->GetOutput();
-
-   
-
-
+    
     typename InputImageType::SizeType size = inputPtr->GetLargestPossibleRegion().GetSize();
 
     // Rescale data in the [0,1] range
diff --git a/Code/FeatureExtraction/otbSimplePointCountStrategy.h b/Code/FeatureExtraction/otbSimplePointCountStrategy.h
index 693ed129b6..d5a8953d36 100644
--- a/Code/FeatureExtraction/otbSimplePointCountStrategy.h
+++ b/Code/FeatureExtraction/otbSimplePointCountStrategy.h
@@ -48,23 +48,27 @@ public:
       
       int accu = 0;
       double surface = M_PI*size*size;
-
-      typedef typename TPointSet::PointsContainer::ConstIterator         iteratorType;
-      
-      iteratorType it = pointSet->GetPoints()->Begin();
       
-      while( it != pointSet->GetPoints()->End())
+      if(pointSet->GetNumberOfPoints() != 0)
 	{
-	  float distX2 =( index[0]-it.Value()[0])*( index[0]-it.Value()[0]);
-	  float distY2 =( index[1]-it.Value()[1])*( index[1]-it.Value()[1]);
-	  float dist = vcl_sqrt(distX2 + distY2);
+	  typedef typename TPointSet::PointsContainer::ConstIterator     iteratorType;
+	  iteratorType it = pointSet->GetPoints()->Begin();
 	  
-	  if(dist <= size)
-	    accu++;
+	  while( it != pointSet->GetPoints()->End())
+	    {
+	      float distX2 =( index[0]-it.Value()[0])*( index[0]-it.Value()[0]);
+	      float distY2 =( index[1]-it.Value()[1])*( index[1]-it.Value()[1]);
+	      float dist = vcl_sqrt(distX2 + distY2);
+	      
+	      if(dist <= size)
+		accu++;
 	  
-	  ++it;
+	      ++it;
+	    }
 	}
-            
+      else
+	return 0.;
+
       return static_cast<float>(accu/surface);
     }
 }; 
-- 
GitLab