From 28de0d21bb66fae527e4cb9142cf9c001ec2cc01 Mon Sep 17 00:00:00 2001 From: Otmane Lahlou <otmane.lahlou@c-s.fr> Date: Thu, 9 Sep 2010 10:45:59 +0200 Subject: [PATCH] ENH : simplify generic rs transform filter --- .../otbGenericRSResampleImageFilter.h | 33 +++++++++---------- .../otbGenericRSResampleImageFilter.txx | 20 ++--------- 2 files changed, 17 insertions(+), 36 deletions(-) diff --git a/Code/Projections/otbGenericRSResampleImageFilter.h b/Code/Projections/otbGenericRSResampleImageFilter.h index a127f733ef..2fa232c198 100644 --- a/Code/Projections/otbGenericRSResampleImageFilter.h +++ b/Code/Projections/otbGenericRSResampleImageFilter.h @@ -20,7 +20,6 @@ #include "itkImageToImageFilter.h" #include "otbOptResampleImageFilter.h" -#include "itkLinearInterpolateImageFunction.h" #include "otbGenericRSTransform.h" @@ -56,7 +55,6 @@ public: /** Typedef parameters*/ typedef TInputImage InputImageType; - typedef typename InputImageType::PointType PointType; typedef TOutputImage OutputImageType; typedef TDeormationField DeformationFieldType; @@ -70,9 +68,7 @@ public: typedef typename ResamplerType::IndexType IndexType; typedef typename ResamplerType::RegionType RegionType; typedef typename ResamplerType::InterpolatorType InterpolatorType; - typedef typename ResamplerType::DefaultInterpolatorType DefaultInterpolatorType; - /** Specialisation of OptResampleFilter with a remote * sensing transform */ @@ -121,12 +117,20 @@ public: otbGetObjectMemberConstMacro(Resampler, Interpolator, const InterpolatorType *); /** Set/Get for input and output projections. */ - itkSetStringMacro(InputProjectionRef); - itkGetStringMacro(InputProjectionRef); + void SetInputProjectionRef(const std::string& ref) + { + m_Transform->SetOutputProjectionRef(ref); + this->Modified(); + } + otbGetObjectMemberMacro(Transform,InputProjectionRef,std::string); + + void SetOutputProjectionRef(const std::string& ref) + { + m_Transform->SetInputProjectionRef(ref); + this->Modified(); + } + otbGetObjectMemberMacro(Transform,OutputProjectionRef,std::string); - itkSetStringMacro(OutputProjectionRef); - itkGetStringMacro(OutputProjectionRef); - /** Set/Get Input Keywordlist*/ void SetInputKeywordList(const ImageKeywordlist& kwl) { @@ -161,18 +165,11 @@ protected: virtual void GenerateOutputInformation(); virtual void GenerateInputRequestedRegion(); - - // Method to instanciate the Generic RS transform - void UpdateTransform(); - + private: GenericRSResampleImageFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - - // GenericRSTransform Parameters - std::string m_InputProjectionRef; - std::string m_OutputProjectionRef; - + // Filters pointers ResamplerPointerType m_Resampler; GenericRSTransformPointerType m_Transform; diff --git a/Code/Projections/otbGenericRSResampleImageFilter.txx b/Code/Projections/otbGenericRSResampleImageFilter.txx index 693f9bd1e1..61fa622c24 100644 --- a/Code/Projections/otbGenericRSResampleImageFilter.txx +++ b/Code/Projections/otbGenericRSResampleImageFilter.txx @@ -81,26 +81,10 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField> // Expose the input metadata to the output itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary(); - itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, m_OutputProjectionRef); + itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, this->GetInputProjectionRef()); outputPtr->SetMetaDataDictionary(dict); } -template <class TInputImage, class TOutputImage, class TDeformationField> -void -GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField> -::UpdateTransform() -{ - // Get the input image - const InputImageType* input = this->GetInput(); - - // Instanciate the RS Transform - m_Transform->SetOutputProjectionRef(input->GetProjectionRef()); - m_Transform->SetInputProjectionRef(m_OutputProjectionRef); - m_Transform->SetOutputKeywordList(input->GetImageKeywordlist()); - m_Transform->SetInputKeywordList(this->GetOutputKeywordList()); - m_Transform->InstanciateTransform(); -} - template <class TInputImage, class TOutputImage, class TDeformationField> void GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField> @@ -116,7 +100,7 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField> RegionType requestedRegion = outputPtr->GetRequestedRegion(); // Instanciate the RS transform - this->UpdateTransform(); + m_Transform->InstanciateTransform(); // Generate input requested region m_Resampler->SetInput(inputPtr); -- GitLab