diff --git a/Code/BasicFilters/otbCountImageFunction.h b/Code/BasicFilters/otbCountImageFunction.h
index 4db9d0389cdfee49447e4d38a6650f15a4586d86..fdbd57299ad95061bbd9f663b7bca7b1df93cdbb 100644
--- a/Code/BasicFilters/otbCountImageFunction.h
+++ b/Code/BasicFilters/otbCountImageFunction.h
@@ -77,11 +77,12 @@ public:
   itkStaticConstMacro(ImageDimension, unsigned int,
                       InputImageType::ImageDimension);
 
+  /** Set the input image (reimplemented since we need to set the detector input) */
+  virtual void SetInputImage( const InputImageType * ptr );
 
-
-  /** Evalulate the function at specified index */
-  virtual RealType EvaluateAtIndex( const IndexType& index );
-   virtual RealType EvaluateAtIndex( const IndexType& index ) const;
+  /** Evalulate the function at specified index */ 
+  virtual RealType EvaluateAtIndex( const IndexType& index ) const;
+  
   /** Evaluate the function at non-integer positions */
   virtual RealType Evaluate( const PointType& point ) const
     { 
@@ -112,8 +113,6 @@ protected:
   CountImageFunction();
   ~CountImageFunction(){};
   
-  /**Update method*/
-  virtual void Modified();
 
   void PrintSelf(std::ostream& os, itk::Indent indent) const;
 
@@ -127,7 +126,6 @@ private:
   DetectorPointerType m_Detector;
 
   unsigned int m_NeighborhoodRadius;
-  bool m_HasBeenGenerated;
 };
 
 } // end namespace otb
diff --git a/Code/BasicFilters/otbCountImageFunction.txx b/Code/BasicFilters/otbCountImageFunction.txx
index 975297ec9c6d6577820c5b2115a202f98292398e..b790707f7d0e292afbbaefd2b2cd495590f6d89f 100644
--- a/Code/BasicFilters/otbCountImageFunction.txx
+++ b/Code/BasicFilters/otbCountImageFunction.txx
@@ -36,11 +36,18 @@ CountImageFunction<TInputImage,TDetector , TCount>
 {
   m_NeighborhoodRadius = 1;
   m_Detector = DetectorType::New();
-
-  m_HasBeenGenerated = false;
 }
 
 
+template <class TInputImage, class TDetector ,class TCount >
+void
+CountImageFunction< TInputImage, TDetector , TCount >
+::SetInputImage(const InputImageType * ptr)
+{
+  Superclass::SetInputImage(ptr);
+  m_Detector->SetInput(ptr);
+}
+
 /**
  *
  */
@@ -61,30 +68,12 @@ template <class TInputImage, class TDetector ,class TCount >
 typename CountImageFunction< TInputImage, TDetector , TCount >
 ::RealType
 CountImageFunction<TInputImage,TDetector , TCount>
-::EvaluateAtIndex(const IndexType& index)
-{
-  // generate data again
-  if(!m_HasBeenGenerated)
-    {
-      m_Detector->SetInput(this->GetInputImage());
-      m_Detector->Update();
-      m_HasBeenGenerated = true;
-
-    }
-  // Call the const implementation
-  return this->EvaluateAtIndex(index);
-}
-
-template <class TInputImage, class TDetector ,class TCount >
-typename CountImageFunction< TInputImage, TDetector , TCount >
-::RealType
-CountImageFunction<TInputImage,TDetector , TCount>
-::EvaluateAtIndex(const IndexType& index) const
+::EvaluateAtIndex(const IndexType& index) const 
 {
+  m_Detector->Update();
   CountType  countDensity;
-  return countDensity(m_Detector->GetOutput(),this->GetNeighborhoodRadius(),index );
+  return countDensity(m_Detector->GetOutput(),m_NeighborhoodRadius,index );
 }
-
 /**
  * SetDetector method
  */
@@ -94,6 +83,10 @@ CountImageFunction<TInputImage,TDetector , TCount>
 ::SetDetector( DetectorType* detector)
 {
   m_Detector = detector;
+  if(this->GetInputImage())
+    {
+      m_Detector->SetInput(this->GetInputImage());
+    }
 }
 
 /**
@@ -107,23 +100,6 @@ CountImageFunction<TInputImage,TDetector , TCount>
 {
   return m_Detector;
 }
-
-// /**
-//  * Modified
-//  */
-template <class TInputImage, class TDetector ,class TCount >
-void
-CountImageFunction<TInputImage,TDetector , TCount>
-::Modified()
-{
-  m_HasBeenGenerated = false ;
-  Superclass::Modified();
-  m_Detector->Modified();
-}
-
-
-
-
 } // end namespace otb
 
 #endif
diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt
index 63a0929ed4eec17be18a81d148e3035ed03e5c27..a8317545fbc03c2513b866a56f64b614772ece67 100644
--- a/Testing/Code/BasicFilters/CMakeLists.txt
+++ b/Testing/Code/BasicFilters/CMakeLists.txt
@@ -1120,7 +1120,15 @@ ADD_TEST(bfTuCountImageFunctionNew ${BASICFILTERS_TESTS11}
 	 otbCountImageFunctionNew
 	 )
 
-
+ADD_TEST(bfTvCountImageFunction ${BASICFILTERS_TESTS11}
+--compare-ascii ${TOL}
+	    ${BASELINE_FILES}/bfTvCountImageFunctionOutputAscii.txt
+	    ${TEMP}/bfTvCountImageFunctionOutputAscii.txt
+	otbCountImageFunctionTest
+	 ${INPUTDATA}/QB_Suburb.png
+	 ${TEMP}/bfTvCountImageFunctionOutputAscii.txt
+	 5 2
+)
 
 # A enrichir
 SET(BasicFilters_SRCS1
@@ -1283,6 +1291,7 @@ ENDIF(USE_FFTWD)
 SET(BasicFilters_SRCS11
 otbExtractROIResample.cxx
 otbCountImageFunctionNew.cxx
+otbCountImageFunctionTest.cxx	
 )
 
 
diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx
index aec76493c850a9430a7d2e969925763e785be544..18fa0e979aaf7e6e63c8c3ee767e16d5b4e90180 100644
--- a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx
+++ b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx
@@ -29,4 +29,5 @@ void RegisterTests()
 {
 REGISTER_TEST(otbExtractROIResample);
 REGISTER_TEST(otbCountImageFunctionNew); 
+REGISTER_TEST(otbCountImageFunctionTest);  
 }
diff --git a/Testing/Code/BasicFilters/otbCountImageFunction.cxx b/Testing/Code/BasicFilters/otbCountImageFunction.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..1edc301a424ffa72f34428d26521b4a762f629c2
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbCountImageFunction.cxx
@@ -0,0 +1,50 @@
+/*=========================================================================
+
+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 <stdio.h>
+
+#include "otbCountImageFunction.h"
+#include "otbSiftFastImageFilter.h"
+#include "otbSimplePointCountStrategy.h"
+#include "itkPointSet.h"
+#include "itkVariableLengthVector.h"
+#include "otbImage.h"
+
+int otbCountImageFunctionNew(int, char* [] )
+{
+
+  const   unsigned int                                      Dimension = 2;
+  typedef float                                             PixelType; 
+
+  typedef otb::Image< PixelType, Dimension >                ImageType;
+  typedef ImageType::IndexType                              IndexType;
+  typedef itk::VariableLengthVector<PixelType>              RealVectorType;
+  typedef itk::PointSet<RealVectorType,Dimension>           PointSetType;
+  typedef otb::SiftFastImageFilter<ImageType,PointSetType>  DetectorType;
+  
+  typedef otb::Count<PointSetType,unsigned int ,IndexType>  CounterType;
+  
+  typedef otb::CountImageFunction< ImageType,DetectorType,
+                                             CounterType>   FunctionType;
+  
+  /**Instancitation of an object*/
+  FunctionType::Pointer    filter =     FunctionType::New();
+
+  return EXIT_SUCCESS;
+}
+
diff --git a/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx b/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..462646c226f98ee8bf5a7d8fd71503da61fafe85
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx
@@ -0,0 +1,103 @@
+/*=========================================================================
+
+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 "otbImage.h"
+#include "otbImageFileReader.h"
+
+#include <stdio.h>
+#include "otbCountImageFunction.h"
+#include "otbSiftFastImageFilter.h"
+#include "otbSimplePointCountStrategy.h"
+#include "itkPointSet.h"
+#include "itkVariableLengthVector.h"
+
+#include <iostream>
+
+int otbCountImageFunctionTest(int argc, char* argv[] )
+{
+  const char *  infname = argv[1];            
+  const char * outfname = argv[2];
+  const unsigned char scales = atoi(argv[3]);
+  const unsigned char radius = atoi(argv[4]);
+  const   unsigned int                                      Dimension = 2;
+  typedef float                                             PixelType; 
+
+  typedef otb::Image< PixelType, Dimension >                ImageType;
+  typedef ImageType::IndexType                              IndexType;
+  
+  typedef otb::ImageFileReader<ImageType>                   ReaderType;
+  
+  typedef itk::VariableLengthVector<PixelType>              RealVectorType;
+  typedef itk::PointSet<RealVectorType,Dimension>           PointSetType;
+  typedef otb::SiftFastImageFilter<ImageType,PointSetType>  DetectorType;
+  
+  typedef otb::Count<PointSetType,unsigned int ,IndexType>  CounterType;
+  
+  typedef otb::CountImageFunction< ImageType,DetectorType,
+                                             CounterType>   FunctionType;
+
+
+  /** Instanciation of the reader */
+  ReaderType::Pointer reader = ReaderType::New();
+  reader->SetFileName(infname);
+  reader->Update();
+  
+  ImageType::SizeType                     size;
+  size = reader->GetOutput()->GetLargestPossibleRegion().GetSize();
+  
+  /**Instancitation of an object*/
+  FunctionType::Pointer    filter =     FunctionType::New();
+  
+  /** Instanciation of the detector : */
+  DetectorType::Pointer detector = filter->GetDetector();
+  detector->SetNumberOfScales(scales);
+  
+
+  filter->SetInputImage(reader->GetOutput()); 
+  filter->SetNeighborhoodRadius(radius);
+  filter->SetDetector(detector);  /*Set the number of scales for the detector**/
+
+  /** First try*/
+  ImageType::IndexType index ; 
+  index[0] = size[0]/2 ;
+  index[1] = size[1]/4;
+
+  std::ofstream outfile(outfname);
+  outfile << "At Index: "   << index << std::endl;
+  outfile << "\t density :" << filter->EvaluateAtIndex(index) << std::endl;
+
+  /** Second Try*/
+  index[0] = size[0]/4 ;
+  index[1] = size[1]/4;
+
+  outfile << "At Index: "   << index << std::endl;
+  outfile << "\t density :" << filter->EvaluateAtIndex(index) << std::endl;
+
+  /** Third Try*/
+  index[0] = size[0]/2 ;
+  index[1] = size[1]/2;
+
+  outfile << "At Index: "   << index << std::endl;
+  outfile << "\t density :" << filter->EvaluateAtIndex(index) << std::endl;
+  
+  outfile.close();
+  
+
+  return EXIT_SUCCESS;
+}
+
diff --git a/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx b/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx
index a64baa87e08e45a328533cd8a649f3973883e878..3af21c02573eb32856f51e32ed9b7de5dbbb0145 100644
--- a/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx
+++ b/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx
@@ -118,8 +118,5 @@ int otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii(int argc, char * ar
     }
   outfile.close(); 
 
-
-  outfile.close();
-
   return EXIT_SUCCESS;
 }