Skip to content
Snippets Groups Projects
Commit f6ec1a44 authored by Julien Michel's avatar Julien Michel
Browse files

Ajout du filtre de base ImageListToImageListFilter

parent 98e0ebc8
Branches
Tags
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 _otbImageListToImageListFilter_h
#define _otbImageListToImageListFilter_h
#include "otbImageListSource.h"
namespace otb
{
/** \class ImageListSource
* \brief Base class for all the filters taking an image list as input
* to produce an image list.
* \ingroup Images
* \ingroup Lists
*/
template <class TInputImage, class TOutputImage>
class ITK_EXPORT ImageListToImageListFilter
: public ImageListSource<TOutputImage>
{
public:
/** Standard typedefs */
typedef ImageListToImageListFilter Self;
typedef ImageListSource<TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkNewMacro(Self);
/** Creation through object factory macro */
itkTypeMacro(ImageListToImageListFilter, ImageListSource);
/** Template parameters typedefs */
typedef TInputImage InputImageType;
typedef typename InputImageType::ConstPointer InputImagePointer;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::SizeType SizeType;
typedef typename InputImageType::ValueType ValueType;
typedef ImageList<InputImageType> InputImageListType;
typedef typename InputImageListType::Pointer InputImageListPointerType;
typedef typename InputImageListType::ConstPointer InputImageListConstPointer;
/** Derived typedefs */
typedef typename Superclass::OutputImageType OutputImageType;
typedef typename Superclass::OutputImageListType OutputImageListType;
typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType;
typedef typename Superclass::OutputImagePointerType OutputImagePointer;
/** InputImage dimension constant */
itkStaticConstMacro(InputImageDimension, unsigned int,TInputImage::ImageDimension);
/** Overiding the SetInput() and GetInput() methods */
virtual void SetInput( const InputImageListType * imageList);
virtual InputImageListType * GetInput(void);
protected:
/** Constructor */
ImageListToImageListFilter();
/** Destructor */
virtual ~ImageListToImageListFilter() {};
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
ImageListToImageListFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
}// End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbImageListToImageListFilter.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 _otbImageListToImageListFilter_txx
#define _otbImageListToImageListFilter_txx
#include "otbImageListToImageListFilter.h"
namespace otb
{
/**
* Constructor
*/
template <class TInputImage, class TOutputImage>
ImageListToImageListFilter<TInputImage,TOutputImage>
::ImageListToImageListFilter()
{
this->SetNumberOfRequiredInputs(1);
}
/**
* Input Connection
* \param image The input image.
*/
template <class TInputImage, class TOutputImage>
void
ImageListToImageListFilter<TInputImage,TOutputImage>
::SetInput(const InputImageListType *imageList)
{
// A single input image
this->itk::ProcessObject::SetNthInput(0,const_cast<InputImageListType*>(imageList));
}
/**
* Input image retrieval
* \return The input image.
*/
template <class TInputImage, class TOutputImage>
typename ImageListToImageListFilter<TInputImage,TOutputImage>::InputImageListType *
ImageListToImageListFilter<TInputImage,TOutputImage>
::GetInput(void)
{
// If there is no input
if (this->GetNumberOfInputs()<1)
{
// exit
return 0;
}
// else return the first input
return static_cast<InputImageListType * >
(this->itk::ProcessObject::GetInput(0) );
}
/**
* PrintSelf Method
*/
template <class TInputImage, class TOutputImage>
void
ImageListToImageListFilter<TInputImage,TOutputImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // 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.
=========================================================================*/
#include "itkExceptionObject.h"
#include "otbImageListToImageListFilter.h"
#include "otbImage.h"
int otbImageListToImageListFilterNew(int argc, char * argv[])
{
try
{
const unsigned int Dimension = 2;
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
typedef otb::Image<InputPixelType,Dimension> InputImageType;
typedef otb::Image<OutputPixelType,Dimension> OutputImageType;
typedef otb::ImageListToImageListFilter<InputImageType,OutputImageType> ImageToImageListFilterType;
// Instantiating ImageListSource object
ImageToImageListFilterType::Pointer imageList = ImageToImageListFilterType::New();
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject thrown !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Unknown exception thrown !" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment