From 5c9a2e2768e78828912b77407152a51ad2f1c192 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@orfeo-toolbox.org>
Date: Tue, 8 Jul 2014 13:52:01 +0200
Subject: [PATCH] BUG: Fixing the phr mode of superimpose and fusion

---
 .../Projections/otbBundleToPerfectSensor.cxx         | 12 +++++++-----
 Applications/Projections/otbSuperimpose.cxx          |  4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Applications/Projections/otbBundleToPerfectSensor.cxx b/Applications/Projections/otbBundleToPerfectSensor.cxx
index af9700336b..3bbe1712c1 100644
--- a/Applications/Projections/otbBundleToPerfectSensor.cxx
+++ b/Applications/Projections/otbBundleToPerfectSensor.cxx
@@ -162,6 +162,8 @@ private:
   void DoExecute()
   {
     FloatVectorImageType* panchroV = GetParameterImage("inp");
+    FloatVectorImageType* xs = GetParameterImage("inxs");
+
     if ( panchroV->GetNumberOfComponentsPerPixel() != 1 )
       {
       itkExceptionMacro(<< "The panchromatic image must be a single channel image")
@@ -179,7 +181,7 @@ private:
     FloatImageType::Pointer panchro = channelSelect->GetOutput();
 
 
-    FloatVectorImageType* xs = GetParameterImage("inxs");
+   
 
     typedef otb::BCOInterpolateImageFunction<FloatVectorImageType> InterpolatorType;
     typedef otb::GenericRSResampleImageFilter<FloatVectorImageType, FloatVectorImageType>  ResamplerType;
@@ -292,8 +294,8 @@ private:
       int colStartXS = atoi(tmpStr.c_str());
       
       // Compute shift between MS and P (in Pan pixels)
-      int lineShift_MS_P =int(vcl_floor((timeDelta/(linePeriodPan/1000))  + 0.5));
-      int colShift_MS_P = colStartXS*4 - colStartPan - 4;
+      int lineShift_MS_P =int(vcl_floor((timeDelta/(linePeriodPan/1000))  + 0.5))+0.375;
+      int colShift_MS_P = colStartXS*4 - colStartPan-4+0.375;
       
       // Apply the scaling
       typedef itk::ScalableAffineTransform<double, 2>  TransformType;
@@ -305,8 +307,8 @@ private:
       // shift in each direction
       // TODO : clarify formula
       TransformType::OutputVectorType offset;
-      offset[0] = -1.5 + static_cast<double>(colShift_MS_P);
-      offset[1] = -1.5 + static_cast<double>(lineShift_MS_P);
+      offset[0] = static_cast<double>(colShift_MS_P);
+      offset[1] = static_cast<double>(lineShift_MS_P);
       transform->Translate(offset);
 
       otbAppLogINFO(<< "Offset computed between MS and P (in Pan pixels) in PHR mode= "<< offset << std::endl);
diff --git a/Applications/Projections/otbSuperimpose.cxx b/Applications/Projections/otbSuperimpose.cxx
index 9c3bb683ab..32e5f8a76c 100644
--- a/Applications/Projections/otbSuperimpose.cxx
+++ b/Applications/Projections/otbSuperimpose.cxx
@@ -338,8 +338,8 @@ private:
       int colStartXS = atoi(tmpStr.c_str());
       
       // Compute shift between MS and P (in Pan pixels)
-      int lineShift_MS_P =int(vcl_floor((timeDelta/(linePeriodPan/1000))  + 0.5));
-      int colShift_MS_P = colStartXS*4 - colStartPan - 4;
+      int lineShift_MS_P =int(vcl_floor((timeDelta/(linePeriodPan/1000))  + 0.5)) + 0.375;
+      int colShift_MS_P = colStartXS*4 - colStartPan - 4 + 0.375;
       
       // Apply the scaling
       TransformType::Pointer transform = TransformType::New();
-- 
GitLab