From e1cbca65fec8fec091769b3575853ec1d994de55 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Tue, 25 Oct 2011 11:14:57 +0200 Subject: [PATCH] ENH: Adding an isotropic spacing mode, off by default --- .../otbImageToGenericRSOutputParameters.h | 6 ++++++ .../otbImageToGenericRSOutputParameters.txx | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Code/Projections/otbImageToGenericRSOutputParameters.h b/Code/Projections/otbImageToGenericRSOutputParameters.h index 3777457604..d2244cf22f 100644 --- a/Code/Projections/otbImageToGenericRSOutputParameters.h +++ b/Code/Projections/otbImageToGenericRSOutputParameters.h @@ -99,6 +99,11 @@ public: itkSetMacro(OutputSize, SizeType); itkGetMacro(OutputSize, SizeType); + /** Isotropic spacing flag */ + itkSetMacro(EstimateIsotropicSpacing,bool); + itkGetMacro(EstimateIsotropicSpacing,bool); + itkBooleanMacro(EstimateIsotropicSpacing); + /** * Method to Force the use of the spacing selected by the user * The output size is computed using this spacing @@ -175,6 +180,7 @@ private: bool m_ForceSpacing; bool m_ForceSize; + bool m_EstimateIsotropicSpacing; }; // end of class ImageToGenericRSOutputParameters diff --git a/Code/Projections/otbImageToGenericRSOutputParameters.txx b/Code/Projections/otbImageToGenericRSOutputParameters.txx index 490db2d252..502784ca56 100644 --- a/Code/Projections/otbImageToGenericRSOutputParameters.txx +++ b/Code/Projections/otbImageToGenericRSOutputParameters.txx @@ -31,6 +31,7 @@ ImageToGenericRSOutputParameters<TImage> m_Transform = GenericRSTransformType::New(); m_ForceSpacing = false; m_ForceSize = false; + m_EstimateIsotropicSpacing = false; } /** @@ -217,8 +218,19 @@ ImageToGenericRSOutputParameters<TImage> // Evaluate spacing SpacingType outputSpacing; - outputSpacing[0] = sizeCartoX / OxLength; - outputSpacing[1] = -sizeCartoY / OyLength; + + + if(m_EstimateIsotropicSpacing) + { + double isotropicSpacing = std::min(sizeCartoX / OxLength, sizeCartoY / OyLength); + outputSpacing[0] = isotropicSpacing; + outputSpacing[1] = -isotropicSpacing; + } + else + { + outputSpacing[0] = sizeCartoX / OxLength; + outputSpacing[1] = -sizeCartoY / OyLength; + } this->SetOutputSpacing(outputSpacing); } -- GitLab