From 2d2bb8968e5e73e8790e3af40c58e7e0c24e4276 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@cnes.fr>
Date: Tue, 10 Nov 2015 17:57:28 +0100
Subject: [PATCH] BUG: Avoid using normalisation filter if not needed (causes
 tests to fail)

---
 .../include/otbPCAImageFilter.txx                | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.txx b/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.txx
index 4ec65fd304..69d298cd12 100644
--- a/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.txx
+++ b/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.txx
@@ -312,10 +312,20 @@ template < class TInputImage, class TOutputImage,
 void
 PCAImageFilter< TInputImage, TOutputImage, TDirectionOfTransformation >
 ::ReverseGenerateData ()
-{    
-    m_Normalizer->GraftOutput( this->GetOutput() );
+{
+
+  if ( m_GivenStdDevValues || m_GivenMeanValues )
+    {
+    m_Normalizer->GraftOutput(this->GetOutput());
     m_Normalizer->Update();
-    this->GraftOutput( m_Normalizer->GetOutput() );
+    this->GraftOutput(m_Normalizer->GetOutput());
+    }
+  else
+    {
+    m_Transformer->GraftOutput( this->GetOutput() );
+    m_Transformer->Update();
+    this->GraftOutput( m_Transformer->GetOutput() );
+    }
 }
 
 template < class TInputImage, class TOutputImage,
-- 
GitLab