From 57eb5df0e82d2d30a2ac640a7da694332fdf64e4 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@c-s.fr>
Date: Tue, 20 Feb 2007 09:11:02 +0000
Subject: [PATCH] =?UTF-8?q?Correction=20test=20extract=20segment=20en=20er?=
 =?UTF-8?q?reur.=20Le=20viewer=20se=20d=C3=A9clenche=20maintenant=20sur=20?=
 =?UTF-8?q?un=20simple=20appel=20=C3=A0=20Show().?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Code/Visu/otbImageViewer.txx                          |  8 ++++----
 Testing/Code/FeatureExtraction/CMakeLists.txt         |  6 +++---
 Testing/Code/FeatureExtraction/otbExtractSegments.cxx | 11 +++++++++--
 Testing/Code/Visu/otbImageViewer.cxx                  |  4 ----
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/Code/Visu/otbImageViewer.txx b/Code/Visu/otbImageViewer.txx
index 6164c2262a..1b01a7d460 100644
--- a/Code/Visu/otbImageViewer.txx
+++ b/Code/Visu/otbImageViewer.txx
@@ -224,10 +224,6 @@ namespace otb
 	  }
 	// Create the quicklook
 	m_Shrink->SetInput(m_InputImage);
-// 	m_ShrinkFactor = static_cast<unsigned int>((size[0]/wscroll < size[1]/hscroll ? 
-// 						    static_cast<double>(size[0])/static_cast<double>(hscroll)
-// 						    : static_cast<double>(size[1])/static_cast<double>(wscroll))
-// 						   /m_QuicklookRatioCoef);
 	if(size[0]/hscroll < size[1]/wscroll)
 	  {
 	    m_ShrinkFactor = static_cast<unsigned int>(vcl_ceil((static_cast<double>(size[0])/static_cast<double>(wscroll))/m_QuicklookRatioCoef));
@@ -375,6 +371,10 @@ namespace otb
   ImageViewer<TPixel>
   ::Show(void)
   {
+    if(!m_Built)
+      {
+	this->Build();
+      }
     // otbMsgDebugMacro(<<"Entering show method.");
     Fl::check();
     if(m_UseScroll)
diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt
index 9f96d8dabe..9f79a22419 100755
--- a/Testing/Code/FeatureExtraction/CMakeLists.txt
+++ b/Testing/Code/FeatureExtraction/CMakeLists.txt
@@ -408,12 +408,12 @@ ADD_TEST(feTuExtractSegmentsNew ${FEATUREEXTRACTION_TESTS}
         otbExtractSegmentsNew)
         
 ADD_TEST(feTvExtractSegments ${FEATUREEXTRACTION_TESTS}  
-  --compare-image ${TOL}  ${BASELINE}/feFiltreExtractSegments_ImageLine.png
-                          ${TEMP}/feFiltreExtractSegments_ImageLine.png
+  --compare-image ${TOL}  ${BASELINE}/feFiltreExtractSegments_ImageLine.hdr
+                          ${TEMP}/feFiltreExtractSegments_ImageLine.hdr
         otbExtractSegments
 	${INPUTDATA}/ImageLine_hd.bsq.hdr
 	${INPUTDATA}/ImageLineDir.bsq.hdr
-	${TEMP}/feFiltreExtractSegments_ImageLine.png
+	${TEMP}/feFiltreExtractSegments_ImageLine.hdr
 	2 0.3 20 20 2 10 0.5)                
 
 # -------            otb::ForwardFourierMellinTransformImageFilter   -------------
diff --git a/Testing/Code/FeatureExtraction/otbExtractSegments.cxx b/Testing/Code/FeatureExtraction/otbExtractSegments.cxx
index c052f56687..3561b262bf 100755
--- a/Testing/Code/FeatureExtraction/otbExtractSegments.cxx
+++ b/Testing/Code/FeatureExtraction/otbExtractSegments.cxx
@@ -28,6 +28,7 @@
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 #include "otbExtractSegmentsImageFilter.h"
+#include "itkRescaleIntensityImageFilter.h"
 
 int otbExtractSegments( int argc, char * argv[] )
 {
@@ -48,7 +49,7 @@ int otbExtractSegments( int argc, char * argv[] )
 	float  FillGapsAngularBeam((float)::atof(argv[10]));
         
         typedef double	                                        InputPixelType;
-        typedef unsigned char	   	                        OutputPixelType;
+        typedef double	   	                                OutputPixelType;
         const   unsigned int        	                        Dimension = 2;
 
         typedef otb::Image< InputPixelType,  Dimension >        InputImageType;
@@ -57,6 +58,7 @@ int otbExtractSegments( int argc, char * argv[] )
         typedef otb::ImageFileReader< InputImageType  >         ReaderType1;
         typedef otb::ImageFileReader< InputImageType  >         ReaderType2;
         typedef otb::ImageFileWriter< OutputImageType >         WriterType;
+	typedef itk::RescaleIntensityImageFilter<OutputImageType,OutputImageType> RescalerType;
 
 	
         typedef otb::ExtractSegmentsImageFilter< InputImageType, OutputImageType >   FilterType;
@@ -87,6 +89,10 @@ int otbExtractSegments( int argc, char * argv[] )
         ReaderType1::Pointer reader1 = ReaderType1::New();
         ReaderType2::Pointer reader2 = ReaderType2::New();
         WriterType::Pointer writer = WriterType::New();
+	RescalerType::Pointer rescaler = RescalerType::New();
+
+	rescaler->SetOutputMinimum(0);
+	rescaler->SetOutputMaximum(1);
 
         reader1->SetFileName( inputFilename1  );
         reader2->SetFileName( inputFilename2  );
@@ -94,7 +100,8 @@ int otbExtractSegments( int argc, char * argv[] )
         
         filter->SetInputImage( reader1->GetOutput() );
         filter->SetInputImageDirection( reader2->GetOutput() );
-        writer->SetInput( filter->GetOutput() );
+	rescaler->SetInput(filter->GetOutput());
+        writer->SetInput( rescaler->GetOutput() );
         
         writer->Update();
 
diff --git a/Testing/Code/Visu/otbImageViewer.cxx b/Testing/Code/Visu/otbImageViewer.cxx
index bf1cfe6372..ec05c1faee 100644
--- a/Testing/Code/Visu/otbImageViewer.cxx
+++ b/Testing/Code/Visu/otbImageViewer.cxx
@@ -42,11 +42,7 @@ int otbImageViewer( int argc, char * argv[] )
       viewer->SetImage(reader->GetOutput());      
 	
       // build the app
-      otbMsgDebugMacro(<<"Build.");
-      viewer->Build();
-      otbMsgDebugMacro(<<"Show");
       viewer->Show();
-      viewer->Update();
       Fl::check();
     } 
   catch( itk::ExceptionObject & err ) 
-- 
GitLab