Skip to content
Snippets Groups Projects
Commit 98f92af8 authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

ENH: Suppression of the unused otb::PointSetBasedResamplingFilter classe

parent 11fcfc1a
No related branches found
No related tags found
No related merge requests found
/*=========================================================================
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 __otbPointSetBasedResamplingFilter_h
#define __otbPointSetBasedResamplingFilter_h
#include "itkImageToImageFilter.h"
#include "itkTransform.h"
#include "itkInterpolateImageFunction.h"
namespace otb
{
/** \class PointSetBasedResamplingFilter
* \brief
*
* \ingroup DisparityMap
*/
template <class TInputImage, class TPointSet, class TOutputImage>
class ITK_EXPORT PointSetBasedResamplingFilter
: public itk::ImageToImageFilter<TInputImage,TOutputImage>
{
public:
/** Standard typedefs */
typedef PointSetBasedResamplingFilter Self;
typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkNewMacro(Self);
/** Creation through object factory macro */
itkTypeMacro(PointSetBasedResamplingFilter,ImageToImageFilter);
/** Template parameters typedefs */
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef TPointSet PointSetType;
typedef typename InputImageType::ConstPointer InputImageConstPointerType;
typedef typename OutputImageType::Pointer OutputImagePointerType;
typedef typename PointSetType::Pointer PointSetPointerType;
typedef typename OutputImageType::IndexType IndexType;
typedef typename OutputImageType::SizeType SizeType;
typedef typename OutputImageType::SpacingType SpacingType;
typedef typename OutputImageType::PointType PointType;
typedef typename OutputImageType::ValueType OutputPixelType;
/** Transform typedefs */
typedef itk::Transform<double,InputImageType::ImageDimension,OutputImageType::ImageDimension> TransformType;
typedef typename TransformType::Pointer TransformPointerType;
typedef typename TransformType::ParametersType ParametersType;
/** Typedef for the generic interpolator. */
typedef itk::InterpolateImageFunction<InputImageType,double> InterpolatorType;
typedef typename InterpolatorType::Pointer InterpolatorPointerType;
/** Using Decorator pattern for enabling the Transform to be passed in the data pipeline */
typedef itk::DataObjectDecorator<TransformType> TransformOutputType;
typedef typename TransformOutputType::Pointer TransformOutputPointerType;
typedef typename TransformOutputType::ConstPointer TransformOutputConstPointerType;
/**
* Set the pointset containing the disparity.
* \param pointset The pointset containing the disparity.
*/
void SetPointSet(const TPointSet * pointset);
/**
* Get the pointset containing the disparity.
* \return The pointset containing the disparity.
*/
const TPointSet * GetPointSet(void);
itkSetMacro(MetricThreshold,double);
itkGetMacro(MetricThreshold,double);
itkSetMacro(OutputSize,SizeType);
itkGetConstReferenceMacro(OutputSize,SizeType);
itkSetMacro(OutputSpacing,SpacingType);
itkGetConstReferenceMacro(OutputSpacing,SpacingType);
itkSetMacro(OutputOrigin,PointType);
itkGetConstReferenceMacro(OutputOrigin,PointType);
/** Set/Get the Transfrom. */
itkSetObjectMacro(Transform,TransformType);
itkGetObjectMacro(Transform,TransformType);
/** Set/Get the Interpolator. */
itkSetObjectMacro(Interpolator,InterpolatorType);
itkGetObjectMacro(Interpolator,InterpolatorType);
protected:
/** Constructor */
PointSetBasedResamplingFilter();
/** Destructor */
virtual ~PointSetBasedResamplingFilter() {};
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** Main computation method */
virtual void GenerateData(void);
/** Generate output information */
virtual void GenerateOutputInformation(void);
/**
* \return The parameters of the transform associated with the nearest suitable point in pointset.
*/
ParametersType GetNearestPointTransformParameters(IndexType &index);
private:
PointSetBasedResamplingFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
/**
* The threshold of metric value.
*/
double m_MetricThreshold;
/** The output size */
SizeType m_OutputSize;
/** The output spacing. */
SpacingType m_OutputSpacing;
/** The output origin */
PointType m_OutputOrigin;
/** Default value */
OutputPixelType m_DefaultValue;
/**
* The transform used for local registration.
*/
TransformPointerType m_Transform;
/**
* The interpolator used for local registration.
*/
InterpolatorPointerType m_Interpolator;
};
}// End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbPointSetBasedResamplingFilter.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 __otbPointSetBasedResamplingFilter_txx
#define __otbPointSetBasedResamplingFilter_txx
#include "otbPointSetBasedResamplingFilter.h"
#include "itkImageRegionIteratorWithIndex.h"
namespace otb
{
/**
* Constructor
*/
template <class TInputImage, class TPointSet, class TOutputImage>
PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::PointSetBasedResamplingFilter()
{
this->SetNumberOfRequiredInputs(2);
m_MetricThreshold = 0.0;
m_OutputSize.Fill(100);
m_OutputSpacing.Fill(1.0);
m_OutputOrigin.Fill(0.0);
m_DefaultValue = 0;
m_Interpolator = 0; // has to be provided by the user
m_Transform = 0; // has to be provided by the user
}
/**
* Set the pointset containing the disparity.
* \param pointset The pointset containing the disparity.
*/
template <class TInputImage, class TPointSet, class TOutputImage>
void
PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::SetPointSet(const TPointSet * pointset)
{
this->itk::ProcessObject::SetNthInput(1,const_cast<PointSetType *>(pointset));
}
/**
* Get the pointset containing the disparity.
* \return The pointset containing the disparity.
*/
template <class TInputImage, class TPointSet, class TOutputImage>
const TPointSet *
PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::GetPointSet(void)
{
return static_cast<const PointSetType *>(this->itk::ProcessObject::GetInput(1));
}
/** Generate output information */
template <class TInputImage, class TPointSet, class TOutputImage>
void
PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::GenerateOutputInformation(void)
{
OutputImagePointerType outputPtr = this->GetOutput();
typename OutputImageType::RegionType largest;
largest.SetSize(m_OutputSize);
IndexType index;
index.Fill(0);
largest.SetIndex(index);
outputPtr->SetLargestPossibleRegion(largest);
outputPtr->SetSpacing(m_OutputSpacing);
outputPtr->SetOrigin(m_OutputOrigin);
}
/** Main computation method */
template <class TInputImage, class TPointSet, class TOutputImage>
void
PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::GenerateData(void)
{
this->AllocateOutputs();
OutputImagePointerType outputPtr = this->GetOutput();
InputImageConstPointerType inputPtr = this->GetInput();
outputPtr->FillBuffer(0);
m_Interpolator->SetInputImage(inputPtr);
typedef itk::ImageRegionIteratorWithIndex<OutputImageType> IteratorType;
IteratorType outputIt(outputPtr,outputPtr->GetRequestedRegion());
for (outputIt.GoToBegin();!outputIt.IsAtEnd();++outputIt)
{
PointType outputPoint,inputPoint;
IndexType index;
typename TransformType::Pointer inverseTransform;
index = outputIt.GetIndex();
m_Transform->SetParameters(this->GetNearestPointTransformParameters(index));
m_Transform->GetInverse(inverseTransform);
outputPtr->TransformIndexToPhysicalPoint(index,outputPoint);
inputPoint = inverseTransform->TransformPoint(outputPoint);
otbMsgDevMacro(<<"back point: "<<inputPoint<<"(inverse trasform param: "<<inverseTransform->GetParameters()<<")");
if (m_Interpolator->IsInsideBuffer(inputPoint))
{
outputIt.Set(m_Interpolator->Evaluate(inputPoint));
}
else
{
outputIt.Set(m_DefaultValue);
}
}
}
/**
* \return The parameters of the transform associated with the nearest suitable point in pointset.
*/
template <class TInputImage, class TPointSet, class TOutputImage>
typename PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::ParametersType
PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::GetNearestPointTransformParameters(IndexType &index)
{
typedef typename PointSetType::PointsContainer::ConstIterator PointSetIteratorType;
typedef typename PointSetType::PointsContainer PointsContainerType;
typedef typename PointSetType::PointDataContainer::ConstIterator PointDataIteratorType;
typedef typename PointSetType::PointDataContainer PointDataContainerType;
PointSetIteratorType it = this->GetPointSet()->GetPoints()->Begin();
PointDataIteratorType itData = this->GetPointSet()->GetPointData()->Begin();
OutputImagePointerType outputPtr = this->GetOutput();
double distance = -1.;
ParametersType parameters(m_Transform->GetNumberOfParameters());
PointType indexPoint;
outputPtr->TransformIndexToPhysicalPoint(index,indexPoint);
for (;it!=this->GetPointSet()->GetPoints()->End()&&itData!=this->GetPointSet()->GetPointData()->End();++it,++itData)
{
// If the point has a sufficient score
if (vcl_abs(itData.Value()[0])>m_MetricThreshold)
{
ParametersType tmpParameters(m_Transform->GetNumberOfParameters());
PointType inputPoint, outputPoint;
for (unsigned int i = 0; i<m_Transform->GetNumberOfParameters();++i)
{
tmpParameters[i]=itData.Value()[i+1];
}
inputPoint[0] = it.Value()[0];
inputPoint[1] = it.Value()[1];
m_Transform->SetParameters(tmpParameters);
outputPoint = m_Transform->TransformPoint(inputPoint);
// compute the distance to current point
double d = vcl_pow(outputPoint[0]-indexPoint[0],2) + vcl_pow(outputPoint[1]-indexPoint[1],2);
if (distance<0||distance>d)
{
distance = d;
parameters = tmpParameters;
}
}
}
return parameters;
}
/**
* PrintSelf Method
*/
template <class TInputImage, class TPointSet, class TOutputImage>
void
PointSetBasedResamplingFilter<TInputImage, TPointSet, TOutputImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // End namespace otb
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment