From 0eb37ba97a08cd35e58fd068894b6c4ecc591e1d Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Mon, 12 Mar 2012 16:54:44 +0100 Subject: [PATCH] BUG: Fixing a bug when spacing is not (1,1) --- .../otbStereoRectificationGridGenerator.cxx | 2 ++ .../otbStereorectificationDeformationFieldSource.txx | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx b/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx index f84f022d0f..6831d6db17 100644 --- a/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx +++ b/Applications/DisparityMap/otbStereoRectificationGridGenerator.cxx @@ -252,6 +252,8 @@ private: m_DEMToImageGenerator->SetOutputSpacing(spacing); m_DEMToImageGenerator->SetOutputProjectionRef(GetParameterImage("io.inleft")->GetProjectionRef()); m_DEMToImageGenerator->SetOutputKeywordList(GetParameterImage("io.inleft")->GetImageKeywordlist()); + // 0 by default + m_DEMToImageGenerator->SetDefaultUnknownValue(0); m_DEMToImageGenerator->AboveEllipsoidOn(); diff --git a/Code/DisparityMap/otbStereorectificationDeformationFieldSource.txx b/Code/DisparityMap/otbStereorectificationDeformationFieldSource.txx index 1700ffc5e3..8b490b7818 100644 --- a/Code/DisparityMap/otbStereorectificationDeformationFieldSource.txx +++ b/Code/DisparityMap/otbStereorectificationDeformationFieldSource.txx @@ -172,6 +172,8 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> // First, spacing SpacingType outputSpacing; outputSpacing.Fill(m_Scale * m_GridStep); + outputSpacing[0]*=m_LeftImage->GetSpacing()[0]; + outputSpacing[1]*=m_LeftImage->GetSpacing()[1]; // Then, we retrieve the origin of the left input image double localElevation = m_AverageElevation; @@ -459,8 +461,8 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> // first image // TODO: Take into account height direction ? double alpha1 = otb::CONST_PI - vcl_atan(a1); - double deltax1 = m_Scale * m_GridStep * vcl_cos(alpha1); - double deltay1 = -m_Scale * m_GridStep * vcl_sin(alpha1); + double deltax1 = m_Scale * m_GridStep * m_LeftImage->GetSpacing()[0] * vcl_cos(alpha1); + double deltay1 = -m_Scale * m_GridStep * m_LeftImage->GetSpacing()[1] * vcl_sin(alpha1); // Before moving currentPoint1, we will store its image by the // left to right transform at the m_AverageElevation, to compute @@ -500,8 +502,8 @@ StereorectificationDeformationFieldSource<TInputImage, TOutputImage> { // We want to move 1 pixel away in the direction orthogonal to // epipolar line - double nextdeltax1 = m_Scale * m_GridStep * vcl_sin(alpha1); - double nextdeltay1 = m_Scale * m_GridStep * vcl_cos(alpha1); + double nextdeltax1 = m_Scale * m_LeftImage->GetSpacing()[0] * m_GridStep * vcl_sin(alpha1); + double nextdeltay1 = m_Scale * m_LeftImage->GetSpacing()[1] *m_GridStep * vcl_cos(alpha1); // We can then update nextLineStart1 nextLineStart1[0] = currentPoint1[0] - deltax1 + nextdeltax1; -- GitLab