Commit 14b837a7 authored by Julien Malik's avatar Julien Malik
Browse files

MRG

parents b6f62098 2b017958
......@@ -38,6 +38,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
${OTB_SOURCE_DIR}/Code/Fuzzy
${OTB_SOURCE_DIR}/Code/GeospatialAnalysis
${OTB_SOURCE_DIR}/Code/Gui
${OTB_SOURCE_DIR}/Code/Hyperspectral
${OTB_SOURCE_DIR}/Code/IO
${OTB_SOURCE_DIR}/Code/Learning
${OTB_SOURCE_DIR}/Code/Markov
......@@ -302,6 +303,7 @@ SET(OTB_INCLUDE_RELATIVE_DIRS ${OTB_INCLUDE_RELATIVE_DIRS}
Markov
Fusion
GeospatialAnalysis
Hyperspectral
Testing
UtilitiesAdapters/CurlAdapters
UtilitiesAdapters/OssimAdapters
......
/*=========================================================================
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 __otbAngularProjectionBinaryImageFilter_h
#define __otbAngularProjectionBinaryImageFilter_h
#include <vector>
#include "itkImageToImageFilter.h"
namespace otb {
/** \class AngularProjectionBinaryImageFilter
* \brief Performs \f$ y_i = \cos \theta_i x_1 + \sin \theta_i x_2\f$
*
* This class performs the projections of the 2 input images to a set of N
* output images according to N angular values
*
*/
template < class TInputImage, class TOutputImage, class TPrecision >
class ITK_EXPORT AngularProjectionBinaryImageFilter
: public itk::ImageToImageFilter< TInputImage, TOutputImage >
{
public:
/** Standard typedefs */
typedef AngularProjectionBinaryImageFilter 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(AngularProjectionBinaryImageFilter, ImageToImageFilter);
/** Template parameters typedefs */
typedef TInputImage InputImageType;
typedef typename InputImageType::Pointer InputImagePointerType;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::SizeType InputSizeType;
typedef typename InputImageType::IndexType InputIndexType;
typedef typename InputImageType::PixelType InputPixelType;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::Pointer OutputImagePointerType;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::SizeType OutputSizeType;
typedef typename OutputImageType::IndexType OutputIndexType;
typedef typename OutputImageType::PixelType OutputPixelType;
typedef TPrecision PrecisionType;
/** Dimension */
itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
/** Set/Get Angle set */
std::vector<PrecisionType> GetAngleSet() const
{
return m_AngleSet;
}
void SetAngleSet ( std::vector<PrecisionType> & angle );
void SetInput1 ( const InputImageType * );
const InputImageType * GetInput1 () const;
void SetInput2 ( const InputImageType * );
const InputImageType * GetInput2 () const;
protected:
AngularProjectionBinaryImageFilter();
virtual ~AngularProjectionBinaryImageFilter() { }
virtual void GenerateOutputInformation();
virtual void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, int threadID );
private:
AngularProjectionBinaryImageFilter(const Self&); // not implemented
void operator=(const Self&); // not implemented
std::vector<PrecisionType> m_AngleSet;
}; // end of class
} // end of namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbAngularProjectionBinaryImageFilter.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 __otbAngularProjectionBinaryImageFilter_txx
#define __otbAngularProjectionBinaryImageFilter_txx
#include "otbAngularProjectionBinaryImageFilter.h"
#include <vnl/vnl_math.h>
#include <itkImageRegionConstIterator.h>
#include <itkImageRegionIterator.h>
namespace otb {
template < class TInputImage, class TOutputImage, class TPrecision >
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::AngularProjectionBinaryImageFilter ()
{
this->SetNumberOfRequiredInputs(2);
}
template < class TInputImage, class TOutputImage, class TPrecision >
void
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::SetInput1 ( const InputImageType * inputPtr )
{
this->SetNthInput(0,const_cast<InputImageType*>( inputPtr ));
}
template < class TInputImage, class TOutputImage, class TPrecision >
void
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::SetInput2 ( const InputImageType * inputPtr )
{
this->SetNthInput(1,const_cast<InputImageType*>( inputPtr ));
}
template < class TInputImage, class TOutputImage, class TPrecision >
const TInputImage *
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::GetInput1() const
{
if ( this->GetNumberOfInputs() < 1 )
{
return 0;
}
return static_cast<const TInputImage * > (this->itk::ProcessObject::GetInput(0) );
}
template < class TInputImage, class TOutputImage, class TPrecision >
const TInputImage *
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::GetInput2() const
{
if ( this->GetNumberOfInputs() < 2 )
{
return 0;
}
return static_cast<const TInputImage * > (this->itk::ProcessObject::GetInput(1));
}
template < class TInputImage, class TOutputImage, class TPrecision >
void
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::SetAngleSet ( std::vector<PrecisionType> & angle )
{
m_AngleSet = angle;
this->SetNumberOfOutputs( angle.size() );
for ( unsigned int i = 0; i < this->GetNumberOfOutputs(); i++ )
{
this->SetNthOutput(i, OutputImageType::New());
}
this->Modified();
}
template < class TInputImage, class TOutputImage, class TPrecision >
void
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::GenerateOutputInformation()
{
Superclass::GenerateOutputInformation();
for (unsigned int i = 0; i < this->GetNumberOfOutputs(); i++)
{
this->GetOutput(i)->SetRegions(
this->GetInput()->GetRequestedRegion());
}
}
template < class TInputImage, class TOutputImage, class TPrecision >
void
AngularProjectionBinaryImageFilter< TInputImage, TOutputImage, TPrecision >
::ThreadedGenerateData
( const OutputImageRegionType & outputRegionForThread, int threadId )
{
itk::ProgressReporter reporter(this, threadId,
outputRegionForThread.GetNumberOfPixels() );
InputImageRegionType inputRegionForThread;
this->CallCopyOutputRegionToInputRegion( inputRegionForThread, outputRegionForThread );
itk::ImageRegionConstIterator<InputImageType> iter1
( this->GetInput1(), inputRegionForThread );
iter1.GoToBegin();
itk::ImageRegionConstIterator<InputImageType> iter2
( this->GetInput2(), inputRegionForThread );
iter2.GoToBegin();
std::vector< itk::ImageRegionIterator<OutputImageType> > outIter
( this->GetNumberOfOutputs() );
for ( unsigned int i = 0; i < outIter.size(); i++ )
{
outIter[i] = itk::ImageRegionIterator<OutputImageType>
( this->GetOutput(i), outputRegionForThread );
outIter[i].GoToBegin();
}
while ( !iter1.IsAtEnd() && !iter2.IsAtEnd() )
{
for ( unsigned int i = 0; i < outIter.size(); i++ )
{
outIter[i].Set( vcl_cos( m_AngleSet[i] ) * iter1.Get()
+ vcl_sin( m_AngleSet[i] ) * iter2.Get() );
++outIter[i];
}
++iter1;
++iter2;
reporter.CompletedPixel();
}
}
} // end of namespace otb
#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 __otbBinaryFunctorImageFilter_h
#define __otbBinaryFunctorImageFilter_h
#include "otbMacro.h"
#include "itkBinaryFunctorImageFilter.h"
namespace otb
{
/**
* \class BinaryFunctorImageFilter
* \brief Implements pixel-wise generic operation on one image.
*
* Add the capability to change the number of channel when operation on
* VectorImage compared to the itk::BinaryFunctorImageFilter
*
* The number of channel is provided by the functor: TFunction::OutputSize. If
* this number is lower or equal to zero, the behavior of the itk::BinaryFunctorImageFilter
* remains unchanged.
*
* \sa itk::BinaryFunctorImageFilter
*/
template <class TInputImage1, class TInputImage2, class TOutputImage, class TFunction>
class ITK_EXPORT BinaryFunctorImageFilter : public itk::BinaryFunctorImageFilter<TInputImage1, TInputImage2, TOutputImage, TFunction>
{
public:
/** Standard class typedefs. */
typedef BinaryFunctorImageFilter Self;
typedef itk::BinaryFunctorImageFilter<TInputImage1, TInputImage2, TOutputImage, TFunction> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(BinaryFunctorImageFilter, itk::BinaryFunctorImageFilter);
protected:
BinaryFunctorImageFilter() {}
virtual ~BinaryFunctorImageFilter() {}
private:
BinaryFunctorImageFilter(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
};
} // end namespace otb
#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 __otbBinaryFunctorImageListToSampleListFilter_h
#define __otbBinaryFunctorImageListToSampleListFilter_h
#include "itkProcessObject.h"
#include "itkDataObject.h"
#include "itkDataObjectDecorator.h"
#include "otbImageList.h"
#include "itkImageRegionConstIterator.h"
namespace otb {
/** \class BinaryFunctorImageListToSampleListFilter
* \brief Generate join sample from 2 set of ImageList
*
* This class transform the initial data contained in 2 imageList to
* yield a set of join sample \f$(x_i,y_i)\f$ or a set of parameters
* extracted from the 2 image lists.
*
* The Function gives the possibility to select some of the samples only
* and to transform the output data. Hence, the functor should have also a IsToGenerate
* boolean function...
*
* This filter provides pipeline support for itk::Statistics::ListSample via
* itk::DataObjectDecorator for the output sample list.
*
* \sa SparseWvltToAngleMapperListFilter
*
*/
template < class TInputImageList, class TOutputSampleList, class TFunction >
class ITK_EXPORT BinaryFunctorImageListToSampleListFilter
: public itk::ProcessObject
{
public:
/** Standard class typedefs. */
typedef BinaryFunctorImageListToSampleListFilter Self;
typedef itk::ProcessObject Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(BinaryFunctorImageListToSampleListFilter, itk::ProcessObject);
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** InputList typedefs */
typedef TInputImageList InputImageListType;
typedef typename InputImageListType::Pointer InputImageListPointerType;
typedef typename InputImageListType::ConstIterator InputImageListConstIteratorType;
typedef typename InputImageListType::ImageType InputImageType;
typedef typename InputImageType::Pointer InputImagePointerType;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::SizeType SizeType;
typedef typename InputImageType::ValueType ValueType;
/** OutputSampleList typedefs */
typedef TOutputSampleList OutputSampleListType;
typedef typename OutputSampleListType::Pointer OutputSampleListPointer;
typedef typename OutputSampleListType::ConstPointer OutputSampleListConstPointer;
typedef typename OutputSampleListType::MeasurementVectorType OutputMeasurementVectorType;
typedef typename OutputMeasurementVectorType::ValueType OutputValueType;
/** Functor typedef */
typedef TFunction FunctorType;
typedef itk::ImageRegionConstIterator< InputImageType > ImageConstIteratorType;
/** ListSample is not a DataObject, we need to decorate it to push it down
* a ProcessObject's pipeline */
typedef itk::DataObject::Pointer DataObjectPointer;
typedef itk::DataObjectDecorator< OutputSampleListType > OutputSampleListObjectType;
/** Returns the output sample list */
OutputSampleListType * GetOutputSampleList();
/** Returns the output sample list as a data object */
OutputSampleListObjectType * GetOutput();
/** Get the functor object. The functor is returned by reference.
* (Functors do not have to derive from itk::LightObject, so they do
* not necessarily have a reference count. So we cannot return a
* SmartPointer.) */
FunctorType& GetFunctor()
{
return m_Functor;
}
/** Set the functor object. This replaces the current Functor with a
* copy of the specified Functor. This allows the user to specify a
* functor that has ivars set differently than the default functor.
* This method requires an operator!=() be defined on the functor
* (or the compiler's default implementation of operator!=() being
* appropriate). */
void SetFunctor(const FunctorType& functor)
{
m_Functor = functor;
this->Modified();
}
/** Set/Get the input imageList */
void SetInput1 ( const InputImageListType * );
const InputImageListType * GetInput1() const;
void SetInput2 ( const InputImageListType * );
const InputImageListType * GetInput2() const;
protected:
BinaryFunctorImageListToSampleListFilter();
virtual ~BinaryFunctorImageListToSampleListFilter() { }
/** Standard itk::ProcessObject subclass method. */
virtual DataObjectPointer MakeOutput(unsigned int idx);
void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** This method causes the filter to generate its output. */
virtual void GenerateData();
private:
BinaryFunctorImageListToSampleListFilter(const Self &); // not implemented
void operator=(const Self &); // not implemeted
FunctorType m_Functor;
}; // end of class
} // end of namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbBinaryFunctorImageListToSampleListFilter.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 __otbBinaryFunctorImageListToSampleListFilter_txx
#define __otbBinaryFunctorImageListToSampleListFilter_txx
#include "otbBinaryFunctorImageListToSampleListFilter.h"
#include "itkProgressReporter.h"
namespace otb {
template < class TInputImageList, class TOutputSampleList, class TFunction >
BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::BinaryFunctorImageListToSampleListFilter()
{
this->SetNumberOfRequiredInputs(2);
// Generate the output sample list
typename OutputSampleListObjectType::Pointer outputPtr =
static_cast< OutputSampleListObjectType * >(this->MakeOutput(0).GetPointer());
this->ProcessObject::SetNthOutput(0, outputPtr.GetPointer());
}
template < class TInputImageList, class TOutputSampleList, class TFunction >
typename BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::DataObjectPointer
BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::MakeOutput(unsigned int itkNotUsed(idx))
{
typename OutputSampleListObjectType::Pointer outputPtr = OutputSampleListObjectType::New();
OutputSampleListPointer outputSampleList = OutputSampleListType::New();
outputPtr->Set(outputSampleList);
return static_cast<DataObjectPointer>(outputPtr);
}
template < class TInputImageList, class TOutputSampleList, class TFunction >
typename BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::OutputSampleListType *
BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::GetOutputSampleList()
{
typename OutputSampleListObjectType::Pointer dataObjectPointer
= static_cast<OutputSampleListObjectType * > (this->ProcessObject::GetOutput(0) );
return const_cast<OutputSampleListType *>(dataObjectPointer->Get());
}
template < class TInputImageList, class TOutputSampleList, class TFunction >
typename BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::OutputSampleListObjectType *
BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::GetOutput()
{
return static_cast<OutputSampleListObjectType * >
(this->ProcessObject::GetOutput(0) );
}
template < class TInputImageList, class TOutputSampleList, class TFunction >
void
BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
// Call superclass implementation
Superclass::PrintSelf(os, indent);
}
template < class TInputImageList, class TOutputSampleList, class TFunction >
void
BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::SetInput1( const InputImageListType * inputPtr )
{
// Process object is not const-correct so the const_cast is required here
this->itk::ProcessObject::SetNthInput(0,
const_cast< InputImageListType * >( inputPtr ) );
}
template < class TInputImageList, class TOutputSampleList, class TFunction >
void
BinaryFunctorImageListToSampleListFilter< TInputImageList, TOutputSampleList, TFunction >
::SetInput2( const InputImageListType * inputPtr )
{
// Process object is not const-correct so the const_cast is required here
this->itk::ProcessObject::SetNthInput(1,
const_cast< InputImageListType * >( inputPtr ) );
}
template < class TInputImageList, class TOutputSampleList, class TFunction >
const TInputImageList *