diff --git a/Code/Projections/otbImageToGenericRSOutputParameters.h b/Code/Projections/otbImageToGenericRSOutputParameters.h index 3777457604bebcb69fcf72c84ba511efdf397afe..d2244cf22f1da7956213f6ad9228738ff1ebc694 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 490db2d252ac2836c8f2c1212470c35c7fe6f35d..502784ca56b1fd5559dd935155129a42027b6d1d 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); }