Skip to content
Snippets Groups Projects
Commit 28de0d21 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH : simplify generic rs transform filter

parent 3b60f38c
Branches
Tags
No related merge requests found
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "itkImageToImageFilter.h" #include "itkImageToImageFilter.h"
#include "otbOptResampleImageFilter.h" #include "otbOptResampleImageFilter.h"
#include "itkLinearInterpolateImageFunction.h"
#include "otbGenericRSTransform.h" #include "otbGenericRSTransform.h"
...@@ -56,7 +55,6 @@ public: ...@@ -56,7 +55,6 @@ public:
/** Typedef parameters*/ /** Typedef parameters*/
typedef TInputImage InputImageType; typedef TInputImage InputImageType;
typedef typename InputImageType::PointType PointType;
typedef TOutputImage OutputImageType; typedef TOutputImage OutputImageType;
typedef TDeormationField DeformationFieldType; typedef TDeormationField DeformationFieldType;
...@@ -70,9 +68,7 @@ public: ...@@ -70,9 +68,7 @@ public:
typedef typename ResamplerType::IndexType IndexType; typedef typename ResamplerType::IndexType IndexType;
typedef typename ResamplerType::RegionType RegionType; typedef typename ResamplerType::RegionType RegionType;
typedef typename ResamplerType::InterpolatorType InterpolatorType; typedef typename ResamplerType::InterpolatorType InterpolatorType;
typedef typename ResamplerType::DefaultInterpolatorType DefaultInterpolatorType;
/** Specialisation of OptResampleFilter with a remote /** Specialisation of OptResampleFilter with a remote
* sensing transform * sensing transform
*/ */
...@@ -121,12 +117,20 @@ public: ...@@ -121,12 +117,20 @@ public:
otbGetObjectMemberConstMacro(Resampler, Interpolator, const InterpolatorType *); otbGetObjectMemberConstMacro(Resampler, Interpolator, const InterpolatorType *);
/** Set/Get for input and output projections. */ /** Set/Get for input and output projections. */
itkSetStringMacro(InputProjectionRef); void SetInputProjectionRef(const std::string& ref)
itkGetStringMacro(InputProjectionRef); {
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*/ /** Set/Get Input Keywordlist*/
void SetInputKeywordList(const ImageKeywordlist& kwl) void SetInputKeywordList(const ImageKeywordlist& kwl)
{ {
...@@ -161,18 +165,11 @@ protected: ...@@ -161,18 +165,11 @@ protected:
virtual void GenerateOutputInformation(); virtual void GenerateOutputInformation();
virtual void GenerateInputRequestedRegion(); virtual void GenerateInputRequestedRegion();
// Method to instanciate the Generic RS transform
void UpdateTransform();
private: private:
GenericRSResampleImageFilter(const Self &); //purposely not implemented GenericRSResampleImageFilter(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented void operator =(const Self&); //purposely not implemented
// GenericRSTransform Parameters
std::string m_InputProjectionRef;
std::string m_OutputProjectionRef;
// Filters pointers // Filters pointers
ResamplerPointerType m_Resampler; ResamplerPointerType m_Resampler;
GenericRSTransformPointerType m_Transform; GenericRSTransformPointerType m_Transform;
......
...@@ -81,26 +81,10 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField> ...@@ -81,26 +81,10 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField>
// Expose the input metadata to the output // Expose the input metadata to the output
itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary(); 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); 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> template <class TInputImage, class TOutputImage, class TDeformationField>
void void
GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField> GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField>
...@@ -116,7 +100,7 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField> ...@@ -116,7 +100,7 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage, TDeformationField>
RegionType requestedRegion = outputPtr->GetRequestedRegion(); RegionType requestedRegion = outputPtr->GetRequestedRegion();
// Instanciate the RS transform // Instanciate the RS transform
this->UpdateTransform(); m_Transform->InstanciateTransform();
// Generate input requested region // Generate input requested region
m_Resampler->SetInput(inputPtr); m_Resampler->SetInput(inputPtr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment