Commit 0294240b authored by Julien Michel's avatar Julien Michel

Supression du ChangeInformationFilter

parent 4f7df410
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbOrthoRectificationFilter_h
#define __otbOrthoRectificationFilter_h
#include "otbOrthoRectificationFilterBase.h"
#include "itkImageToImageFilter.h"
#include "itkChangeInformationImageFilter.h"
namespace otb
{
/** \class OrthoRectificationFilter
*
* \brief Class for Orthorectifying an image
*
* This class is used to apply map projection and sensor model transformation
* to orthorectify an image, with or without DEM.
*
*/
template <class TInputImage,
class TOutputImage,
class TMapProjection,
class TInterpolatorPrecision=double>
class ITK_EXPORT OrthoRectificationFilter : public itk::ImageToImageFilter< TInputImage, TOutputImage>
{
public :
/** Standard class typedefs */
typedef OrthoRectificationFilter Self;
typedef itk::ImageToImageFilter< TInputImage, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef OrthoRectificationFilterBase< TInputImage,
TOutputImage,
TMapProjection,
TInterpolatorPrecision > OrthoRectificationFilterBaseType;
typedef typename OrthoRectificationFilterBaseType::Pointer OrthoRectificationFilterBasePointer;
typedef itk::ChangeInformationImageFilter<TInputImage > ChangeInfoFilterType;
typedef typename ChangeInfoFilterType::Pointer ChangeInfoFilterPointer;
typedef typename OrthoRectificationFilterBaseType::InputImageType InputImageType;
typedef typename OrthoRectificationFilterBaseType::OutputImageType OutputImageType;
typedef typename OrthoRectificationFilterBaseType::MapProjectionType MapProjectionType;
typedef typename OrthoRectificationFilterBaseType::InterpolatorType InterpolatorType;
typedef typename OrthoRectificationFilterBaseType::IndexType IndexType;
typedef typename OrthoRectificationFilterBaseType::SizeType SizeType;
typedef typename OrthoRectificationFilterBaseType::PointType PointType;
typedef typename OrthoRectificationFilterBaseType::RegionType RegionType;
typedef typename OrthoRectificationFilterBaseType::OriginPointType OriginPointType;
typedef typename OrthoRectificationFilterBaseType::SpacingType SpacingType;
/** Method for creation through the object factory. */
itkNewMacro( Self );
/** Run-time type information (and related methods). */
itkTypeMacro( OrthoRectificationFilter, itk::ImageToImageFilter );
/** Accessors */
virtual void SetMapProjection (MapProjectionType* _arg)
{
m_OrthoRectificationFilter->SetMapProjection( _arg);
this->Modified();
}
virtual MapProjectionType * GetMapProjection()
{
return (m_OrthoRectificationFilter->GetMapProjection());
}
/** Specify where are DEM files, and load useful ones */
virtual void SetDEMDirectory(const std::string& directory)
{
m_OrthoRectificationFilter->SetDEMDirectory(directory);
this->Modified();
}
/** Methods to decide to use DEM */
virtual void EnableDEM()
{
m_OrthoRectificationFilter->EnableDEM();
this->Modified();
}
virtual void DisableDEM()
{
m_OrthoRectificationFilter->DisableDEM();
this->Modified();
}
virtual void SetOutputStartIndex(const IndexType index)
{
m_OrthoRectificationFilter->SetOutputStartIndex(index);
this->Modified();
}
virtual const IndexType & GetOutputStartIndex()const
{
return ( m_OrthoRectificationFilter->GetOutputStartIndex());
}
virtual void SetOutputSpacing(const SpacingType spacing)
{
m_OrthoRectificationFilter->SetOutputSpacing(spacing);
this->Modified();
}
virtual const SpacingType & GetOutputSpacing()const
{
return (m_OrthoRectificationFilter->GetOutputSpacing());
}
virtual void SetOutputOrigin(const OriginPointType origin)
{
m_OrthoRectificationFilter->SetOutputOrigin(origin);
this->Modified();
}
virtual const OriginPointType & GetOutputOrigin()const
{
return (m_OrthoRectificationFilter->GetOutputOrigin());
}
virtual void SetInterpolator(InterpolatorType * interpol)
{
m_OrthoRectificationFilter->SetInterpolator(interpol);
this->Modified();
}
virtual const InterpolatorType * GetInterpolator()const
{
return (m_OrthoRectificationFilter->GetInterpolator());
}
virtual void SetSize(const SizeType size)
{
m_OrthoRectificationFilter->SetSize(size);
this->Modified();
}
virtual const SizeType & GetSize()const
{
return (m_OrthoRectificationFilter->GetSize());
}
protected:
OrthoRectificationFilter();
~OrthoRectificationFilter();
void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** Main computation method */
virtual void GenerateData(void);
/** Generate Output Information */
virtual void GenerateOutputInformation(void);
virtual void GenerateInputRequestedRegion(void);
private:
OrthoRectificationFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
/** Orthorectification filter */
OrthoRectificationFilterBasePointer m_OrthoRectificationFilter;
ChangeInfoFilterPointer m_ChangeInfoFilter;
};
} // namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbOrthoRectificationFilter.txx"
#endif
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _otbOrthoRectificationFilter_txx
#define _otbOrthoRectificationFilter_txx
#include "otbOrthoRectificationFilter.h"
namespace otb
{
template < class TInputImage,
class TOutputImage,
class TMapProjection,
class TInterpolatorPrecision>
OrthoRectificationFilter< TInputImage,
TOutputImage,
TMapProjection,
TInterpolatorPrecision>
::OrthoRectificationFilter() : itk::ImageToImageFilter<TInputImage, TOutputImage>()
{
m_OrthoRectificationFilter=OrthoRectificationFilterBaseType::New();
m_ChangeInfoFilter = ChangeInfoFilterType::New();
m_OrthoRectificationFilter->SetInput(m_ChangeInfoFilter->GetOutput());
PointType originNull;
originNull.Fill(0);
m_ChangeInfoFilter->ChangeOriginOn();
m_ChangeInfoFilter->SetOutputOrigin(originNull);
SpacingType spacing;
spacing.Fill(1);
m_ChangeInfoFilter->SetOutputSpacing(spacing);
}
template < class TInputImage,
class TOutputImage,
class TMapProjection,
class TInterpolatorPrecision>
OrthoRectificationFilter< TInputImage,
TOutputImage,
TMapProjection,
TInterpolatorPrecision>
::~OrthoRectificationFilter()
{
}
template < class TInputImage,
class TOutputImage,
class TMapProjection,
class TInterpolatorPrecision>
void
OrthoRectificationFilter< TInputImage,
TOutputImage,
TMapProjection,
TInterpolatorPrecision>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "m_OrthoRectification:\n" << m_OrthoRectificationFilter<<"\n";
os << indent << "m_ChangeInfoFilter:\n" << m_ChangeInfoFilter <<"\n";
}
template < class TInputImage,
class TOutputImage,
class TMapProjection,
class TInterpolatorPrecision>
void
OrthoRectificationFilter< TInputImage,
TOutputImage,
TMapProjection,
TInterpolatorPrecision>
::GenerateOutputInformation()
{
// This must be done so that the orthoRectificationFilter can generate its ouptut information correctly.
m_ChangeInfoFilter->SetInput(this->GetInput());
m_OrthoRectificationFilter->GenerateOutputInformation();
this->GetOutput()->CopyInformation(m_OrthoRectificationFilter->GetOutput());
}
template < class TInputImage,
class TOutputImage,
class TMapProjection,
class TInterpolatorPrecision>
void
OrthoRectificationFilter< TInputImage,
TOutputImage,
TMapProjection,
TInterpolatorPrecision>
::GenerateInputRequestedRegion(void)
{
typename InputImageType::Pointer inputPtr = const_cast<InputImageType *>(this->GetInput());
if(!inputPtr)
{
return;
}
m_OrthoRectificationFilter->GetOutput()->UpdateOutputInformation();
m_OrthoRectificationFilter->GetOutput()->SetRequestedRegion(this->GetOutput()->GetRequestedRegion());
m_OrthoRectificationFilter->GetOutput()->PropagateRequestedRegion();
inputPtr->SetRequestedRegion(m_OrthoRectificationFilter->GetInput()->GetRequestedRegion());
}
template < class TInputImage,
class TOutputImage,
class TMapProjection,
class TInterpolatorPrecision>
void
OrthoRectificationFilter< TInputImage,
TOutputImage,
TMapProjection,
TInterpolatorPrecision>
::GenerateData(void)
{
// This is done here instead of inside the GenerateData() method so that the pipeline negociation
// use the minipipeline instead of default ITK methods.
m_OrthoRectificationFilter->GraftOutput(this->GetOutput());
m_OrthoRectificationFilter->Update();
this->GraftOutput(m_OrthoRectificationFilter->GetOutput());
}
} //namespace otb
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment