From 44e106d8644a64ade0cac91f96508e1608ad627c Mon Sep 17 00:00:00 2001
From: Aurelien Bricier <aurelien.bricier@c-s.fr>
Date: Mon, 22 Nov 2010 16:56:31 +0100
Subject: [PATCH] ENH: re-enabled LocalHistogram support in
 ImageFunctionAdaptor

---
 Code/Common/otbVariableLengthVectorConverter.h   | 10 +++-------
 Code/Common/otbVariableLengthVectorConverter.txx | 15 ++++-----------
 .../otbImageFunctionAdaptor.cxx                  | 16 ++++++++++++++++
 .../otbStandardMetaImageFunctionBuilder.cxx      |  2 ++
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/Code/Common/otbVariableLengthVectorConverter.h b/Code/Common/otbVariableLengthVectorConverter.h
index c4ecd3fa9b..61dc8f8246 100644
--- a/Code/Common/otbVariableLengthVectorConverter.h
+++ b/Code/Common/otbVariableLengthVectorConverter.h
@@ -204,10 +204,8 @@ private:
 };
 
 //Histogram
-template< class TMeasurement, unsigned int VMeasurementVectorSize, class TFrequencyContainer, class TPrecisionType >
-class ITK_EXPORT VariableLengthVectorConverter<typename itk::SmartPointer< const itk::Statistics::Histogram<TMeasurement, 
-                                                                                                            VMeasurementVectorSize, 
-                                                                                                            TFrequencyContainer> >,
+template< class TPixel, class TPrecisionType >
+class ITK_EXPORT VariableLengthVectorConverter<typename itk::SmartPointer< itk::Statistics::Histogram<TPixel> >,
                                                TPrecisionType> :
 public itk::ProcessObject
 {
@@ -226,9 +224,7 @@ public:
 
   typedef TPrecisionType                                                           OutputPrecisionType;
   typedef typename itk::VariableLengthVector<OutputPrecisionType>                  OutputType;
-  typedef typename itk::SmartPointer< const itk::Statistics::Histogram<TMeasurement, 
-                                                                       VMeasurementVectorSize, 
-                                                                       TFrequencyContainer> >   InputType;
+  typedef typename itk::SmartPointer< itk::Statistics::Histogram<TPixel> >         InputType;
 
   OutputType Convert(InputType input);
  
diff --git a/Code/Common/otbVariableLengthVectorConverter.txx b/Code/Common/otbVariableLengthVectorConverter.txx
index ec25d9722f..213290f62a 100644
--- a/Code/Common/otbVariableLengthVectorConverter.txx
+++ b/Code/Common/otbVariableLengthVectorConverter.txx
@@ -49,7 +49,6 @@ VariableLengthVectorConverter< std::vector<std::vector<TInternalInputType> >, TP
       rsltIdx ++;
       }
     }
-  
   return result;
 }
 
@@ -80,7 +79,6 @@ VariableLengthVectorConverter< std::vector<std::vector<std::complex<TInternalInp
       rsltIdx ++;
       }
     }
-  
   return result;
 }
 
@@ -101,20 +99,15 @@ VariableLengthVectorConverter< itk::FixedArray<TInternalInputType, VArrayDimensi
     result[rsltIdx] = static_cast<OutputPrecisionType>(input[i]);
     rsltIdx ++;
     }
-  
   return result;
 }
 
 // Histogram
-template< class TMeasurement, unsigned int VMeasurementVectorSize, class TFrequencyContainer, class TPrecisionType >
-typename VariableLengthVectorConverter< itk::SmartPointer< const itk::Statistics::Histogram<TMeasurement, 
-                                                                                            VMeasurementVectorSize, 
-                                                                                            TFrequencyContainer> >, 
+template< class TPixel, class TPrecisionType >
+typename VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram<TPixel> >, 
                                         TPrecisionType>
 ::OutputType
-VariableLengthVectorConverter< itk::SmartPointer<const itk::Statistics::Histogram<TMeasurement, 
-                                                                                  VMeasurementVectorSize, 
-                                                                                  TFrequencyContainer> >, 
+VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram<TPixel> >, 
                                TPrecisionType>
 ::Convert(InputType input)
 {
@@ -131,7 +124,7 @@ VariableLengthVectorConverter< itk::SmartPointer<const itk::Statistics::Histogra
     result[rsltIdx] = static_cast<OutputPrecisionType>(input->GetFrequency(i));
     rsltIdx ++;
     }
-  
+  std::cout << "Histogram to VLV" << std::endl;
   return result;
 }
 
diff --git a/Testing/Code/FeatureExtraction/otbImageFunctionAdaptor.cxx b/Testing/Code/FeatureExtraction/otbImageFunctionAdaptor.cxx
index c55e6a1cab..9a0c0ddf9d 100644
--- a/Testing/Code/FeatureExtraction/otbImageFunctionAdaptor.cxx
+++ b/Testing/Code/FeatureExtraction/otbImageFunctionAdaptor.cxx
@@ -168,6 +168,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for FMDadaptedFunction() !" << std::endl;
     std::cout << err << std::endl;
+
+    return EXIT_FAILURE;
     }
 
 
@@ -202,6 +204,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for RMFunction() !" << std::endl;
     std::cout << err << std::endl;
+
+    return EXIT_FAILURE;
     }
 
   try
@@ -236,6 +240,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for CMadaptedFunction() !" << std::endl;
     std::cout << err << std::endl;
+
+    return EXIT_FAILURE;
     }
 
   try
@@ -261,6 +267,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for FMFunction() !" << std::endl;
     std::cout << err << std::endl;
+
+    return EXIT_FAILURE;
     }
 
   try
@@ -286,6 +294,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for HMFunction() !" << std::endl;
     std::cout << err << std::endl;
+
+    return EXIT_FAILURE;
     }
 
   try
@@ -312,6 +322,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for RaMFunction() !" << std::endl;
     std::cout << err << std::endl;
+
+    return EXIT_FAILURE;
     }
 
   try
@@ -344,6 +356,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for LHFunction() !" << std::endl;
     std::cout << err << std::endl;
+    
+    return EXIT_FAILURE;
     }
 
   error = vcl_sqrt(error);
@@ -386,6 +400,8 @@ int otbImageFunctionAdaptor(int argc, char * argv[])
     {
     std::cout << "ExceptionObject caught for FMDFunctionType() !" << std::endl;
     std::cout << err << std::endl;
+    
+    return EXIT_FAILURE;
     }
 
 
diff --git a/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx b/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx
index d93605f5df..bff8e54f24 100644
--- a/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx
+++ b/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx
@@ -81,6 +81,8 @@ int otbStandardMetaImageFunctionBuilder(int argc, char* argv[])
 
   p1.push_back(7);
   p1.push_back(128);
+  p1.push_back(0);
+  p1.push_back(1500);
 
   p2.push_back(6);
   
-- 
GitLab