From 9ca25812f61bbae610f97e50331bc1c5562ceb9a Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@c-s.fr>
Date: Thu, 26 Apr 2007 09:27:22 +0000
Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20des=20images=20utilis?=
 =?UTF-8?q?=C3=A9e=20pour=20tester=20l'extraction=20de=20route.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../otbSpectralAngleDistanceImageFilter.txx   |  4 ++--
 Code/Common/otbDrawPathListFilter.h           |  3 +++
 Testing/Code/BasicFilters/CMakeLists.txt      |  4 ++--
 Testing/Code/FeatureExtraction/CMakeLists.txt | 24 ++++++++++++++-----
 .../otbVectorizationPathListFilter.cxx        | 22 +++++++++++++++++
 5 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/Code/BasicFilters/otbSpectralAngleDistanceImageFilter.txx b/Code/BasicFilters/otbSpectralAngleDistanceImageFilter.txx
index c13d097ee0..4a8be991ea 100644
--- a/Code/BasicFilters/otbSpectralAngleDistanceImageFilter.txx
+++ b/Code/BasicFilters/otbSpectralAngleDistanceImageFilter.txx
@@ -94,8 +94,8 @@ SpectralAngleDistanceImageFilter<TInputImage,TOutputImage>
 	}
       // Spectral angle normalisation
       dist = dist/(M_PI/2);
-   //ponderation par un carre
-   dist = sqrt(dist)*255;
+   //square ponderation
+   dist = sqrt(dist);
    outputIt.Set(static_cast<OutputPixelType>(dist));
     ++inputIt;
     ++outputIt;
diff --git a/Code/Common/otbDrawPathListFilter.h b/Code/Common/otbDrawPathListFilter.h
index 055fe88c31..5e9a3c4cf4 100644
--- a/Code/Common/otbDrawPathListFilter.h
+++ b/Code/Common/otbDrawPathListFilter.h
@@ -92,6 +92,9 @@ public:
   itkGetMacro(UseInternalPathValue,bool);
   itkSetMacro(UseInternalPathValue,bool);
   itkBooleanMacro(UseInternalPathValue);
+  
+  itkSetMacro(PathValue,OutputImagePixelType);
+  itkGetMacro(PathValue,OutputImagePixelType);
 
   /** ImageDimension constants */
   itkStaticConstMacro(InputImageDimension, unsigned int,
diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt
index bb2a347c01..c5484eb538 100755
--- a/Testing/Code/BasicFilters/CMakeLists.txt
+++ b/Testing/Code/BasicFilters/CMakeLists.txt
@@ -209,9 +209,9 @@ ADD_TEST(bfTvStreamingShrinkImageFilterQBMUL ${BASICFILTERS_TESTS}
 		    ${BASELINE}/bfTvSpectralAngleDistanceOutput.hdr
 		    ${TEMP}/bfTvSpectralAngleDistanceOutput.hdr
 		    otbSpectralAngleDistanceImageFilter
-		    ${INPUTDATA}/poupees.jpg
+		    ${INPUTDATA}/InputForRoadDetection.tif
 	            ${TEMP}/bfTvSpectralAngleDistanceOutput.hdr
-		    210 432
+		    232 198
 )
 
 # A enrichir
diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt
index 3eba3c1e71..992e3b0e30 100755
--- a/Testing/Code/FeatureExtraction/CMakeLists.txt
+++ b/Testing/Code/FeatureExtraction/CMakeLists.txt
@@ -478,10 +478,10 @@ ADD_TEST(feTvNeighborhoodScalarProductFilter ${FEATUREEXTRACTION_TESTS}
 		      ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr
 		      ${TEMP}/feTvNeigborhoodScalarProductDirectionOutput.hdr
         otbNeighborhoodScalarProductFilter
-        ${INPUTDATA}/InputForRoadDetection.tif
+        ${BASELINE}/bfTvSpectralAngleDistanceOutput.hdr
         ${TEMP}/feTvNeigborhoodScalarProductModulusOutput.hdr
 	${TEMP}/feTvNeigborhoodScalarProductDirectionOutput.hdr
-        1.0
+        2.0
         )
 
 # -------            otb::RemoveIsolatedByDirectionFilter   -------------
@@ -509,7 +509,7 @@ ADD_TEST(feTvRemoveWrongDirectionFilter ${FEATUREEXTRACTION_TESTS}
 		      ${BASELINE}/feTvRemoveWrongDirectionOutput.hdr
 		      ${TEMP}/feTvRemoveWrongDirectionOutput.hdr
         otbRemoveWrongDirectionFilter
-       ${BASELINE}/feTvNeigborhoodScalarProductModulusOutput.hdr
+       ${BASELINE}/feTvRemoveIsolatedByDirectionOutput.hdr
        ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr
        ${TEMP}/feTvRemoveWrongDirectionOutput.hdr
         )
@@ -524,7 +524,7 @@ ADD_TEST(feTvNonMaxRemovalByDirectionFilter ${FEATUREEXTRACTION_TESTS}
 		      ${BASELINE}/feTvNonMaxRemovalByDirectionOutput.hdr
 		      ${TEMP}/feTvNonMaxRemovalByDirectionOutput.hdr
         otbNonMaxRemovalByDirectionFilter
-       ${BASELINE}/feTvNeigborhoodScalarProductModulusOutput.hdr
+       ${BASELINE}/feTvRemoveWrongDirectionOutput.hdr
        ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr
        ${TEMP}/feTvNonMaxRemovalByDirectionOutput.hdr
         )
@@ -534,7 +534,7 @@ ADD_TEST(feTvNonMaxRemovalByDirectionFilter ${FEATUREEXTRACTION_TESTS}
 ADD_TEST(feTuVectorizationPathListFilterNew ${FEATUREEXTRACTION_TESTS} 
          otbVectorizationPathListFilterNew) 
 
-ADD_TEST(feTvVectorizationPathListFilter ${FEATUREEXTRACTION_TESTS}  
+ADD_TEST(feTvVectorizationPathListFilterAsciiOutput ${FEATUREEXTRACTION_TESTS}  
 --compare-ascii ${EPS}  
 		${BASELINE_FILES}/feTvVectorizationPathListOutput.txt
 		${TEMP}/feTvVectorizationPathListOutput.txt
@@ -542,9 +542,21 @@ ADD_TEST(feTvVectorizationPathListFilter ${FEATUREEXTRACTION_TESTS}
        ${BASELINE}/feTvNonMaxRemovalByDirectionOutput.hdr
        ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr
        ${TEMP}/feTvVectorizationPathListOutput.txt
+       ${TEMP}/feTvVectorizationPathListOutput.png
+       0.0005
         )
 
-
+ADD_TEST(feTvVectorizationPathListFilterImageOutput ${FEATUREEXTRACTION_TESTS}  
+--compare-image ${EPSILON}
+		${BASELINE}/feTvVectorizationPathListOutput.png
+		${TEMP}/feTvVectorizationPathListOutput.png
+        otbVectorizationPathListFilter
+       ${BASELINE}/feTvNonMaxRemovalByDirectionOutput.hdr
+       ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr
+       ${TEMP}/feTvVectorizationPathListOutput.txt
+       ${TEMP}/feTvVectorizationPathListOutput.png
+       0.0005
+        )
 
 # A enrichir
 SET(BasicFeatureExtraction_SRCS
diff --git a/Testing/Code/FeatureExtraction/otbVectorizationPathListFilter.cxx b/Testing/Code/FeatureExtraction/otbVectorizationPathListFilter.cxx
index f6e14288ad..ff3ac475d5 100644
--- a/Testing/Code/FeatureExtraction/otbVectorizationPathListFilter.cxx
+++ b/Testing/Code/FeatureExtraction/otbVectorizationPathListFilter.cxx
@@ -32,12 +32,18 @@ int otbVectorizationPathListFilter(int argc, char * argv[])
       const char * modfname = argv[1];
       const char * dirfname = argv[2];
       const char * outfname = argv[3];
+      const char * outImagefname = argv[4];
+      const double thresh = atof(argv[5]);
 
       const unsigned int Dimension = 2;
       typedef double PixelType;
+      typedef unsigned char OutputPixelType;
       typedef otb::Image<PixelType,Dimension> ImageType;
+      typedef otb::Image<OutputPixelType,Dimension> OutputImageType;
+      typedef otb::ImageFileWriter<OutputImageType> WriterType;
       typedef otb::ImageFileReader<ImageType> ReaderType;
       typedef itk::PolyLineParametricPath<Dimension> PathType;
+      typedef otb::DrawPathListFilter<OutputImageType,PathType,OutputImageType> DrawFilterType;
       typedef otb::VectorizationPathListFilter<ImageType,ImageType,PathType> VectorizationPathListFilterType;
       typedef VectorizationPathListFilterType::OutputPathListType PathListType;
       typedef PathListType::ConstIterator PathListIteratorType;
@@ -53,6 +59,7 @@ int otbVectorizationPathListFilter(int argc, char * argv[])
 
       filter->SetInput(modReader->GetOutput());
       filter->SetInputDirection(dirReader->GetOutput());
+      filter->SetAmplitudeThreshold(thresh);
       filter->Update();
       
       PathListType::Pointer pathList = filter->GetOutput();
@@ -80,6 +87,21 @@ int otbVectorizationPathListFilter(int argc, char * argv[])
 	  ++counter;
 	}
       file.close();
+
+      OutputImageType::Pointer output = OutputImageType::New();
+      output->SetRegions(modReader->GetOutput()->GetLargestPossibleRegion());
+      output->Allocate();
+      output->FillBuffer(255);
+
+      DrawFilterType::Pointer drawer = DrawFilterType::New();
+      drawer->SetInput(output);
+      drawer->SetInputPath(filter->GetOutput());
+      drawer->SetPathValue(0);
+      
+      WriterType::Pointer writer = WriterType::New();
+      writer->SetFileName(outImagefname);
+      writer->SetInput(drawer->GetOutput());
+      writer->Update();
     }
   catch( itk::ExceptionObject & err ) 
     { 
-- 
GitLab