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

Création d'une classe otbImageList dérivant de otbObjectList pour la gestion des listes d'images.

parent f2992d14
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 _otbImageList_h
#define _otbImageList_h
#include "otbObjectList.h"
namespace otb
{
/** \class ImageList
* \brief This class represent a list of images.
*
* It is derived from the otbObjectList class, which allows to manipulate an ITK/OTB
* object list with the appropriate formalism (iterators, accessors).
* \sa ObjectList
*/
template <class TImage>
class ImageList
: public ObjectList<TImage>
{
public:
/** Standards typedefs */
typedef ImageList Self;
typedef ObjectList<TImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkTypeMacro(ImageList,ObjectList);
/** Creation through object factory macro */
itkNewMacro(Self);
/** Template parameter typedefs */
typedef TImage ImageType;
typedef typename Superclass::ObjectPointerType ImagePointerType;
typedef typename Superclass::Iterator Iterator;
typedef typename Superclass::ConstIterator ConstIterator;
typedef typename Superclass::ReverseIterator ReverseIterator;
typedef typename Superclass::ReverseConstIterator ReverseConstIterator;
protected:
/** Constructor */
ImageList(){};
/** Destructor */
~ImageList(){};
/**PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os,indent);
};
private:
ImageList(const Self&) ; //purposely not implemented
void operator=(const Self&) ; //purposely not implemented
};
} // End namespace otb
#endif
......@@ -237,6 +237,20 @@ ADD_TEST(coTvObjectList ${COMMON_TESTS}
${INPUTDATA}/poupees.png
${INPUTDATA}/sbuv.png
)
# ------- otb::ImageList -------------------------------------------
ADD_TEST(coTuImageListNew ${COMMON_TESTS}
otbImageListNew)
ADD_TEST(coTvImageList ${COMMON_TESTS}
--compare-image ${TOL} ${INPUTDATA}/amst.png
${TEMP}/coImageList_amst.png
otbImageList
${INPUTDATA}/amst.png
${TEMP}/coImageList_amst.png
)
# ------- Fichiers sources CXX -----------------------------------
SET(BasicCommon_SRCS
......@@ -264,6 +278,8 @@ otbPathListToHistogramGenerator.cxx
otbHistogramStatisticsFunction.cxx
otbObjectListNew.cxx
otbObjectList.cxx
otbImageListNew.cxx
otbImageList.cxx
)
......
......@@ -50,4 +50,6 @@ REGISTER_TEST(otbPathListToHistogramGenerator);
REGISTER_TEST(otbHistogramStatisticsFunction);
REGISTER_TEST(otbObjectListNew);
REGISTER_TEST(otbObjectList);
REGISTER_TEST(otbImageListNew);
REGISTER_TEST(otbImageList);
}
/*=========================================================================
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 "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbImageList.h"
#include "otbImage.h"
int otbImageList(int argc, char * argv[])
{
try
{
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
const unsigned int Dimension = 2;
typedef unsigned char InputPixelType;
typedef otb::Image<InputPixelType,Dimension> InputImageType;
typedef otb::ImageFileReader<InputImageType> ReaderType;
typedef otb::ImageFileWriter<InputImageType> WriterType;
typedef otb::ImageList<InputImageType> ImageListType;
// Reading image
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFilename);
reader->Update();
// Instantiating ImageList object
ImageListType::Pointer imageList = ImageListType::New();
// Appending one image to the list
imageList->PushBack(reader->GetOutput());
// Getting the image from the list and writing it to file
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFilename);
writer->SetInput(imageList->Back());
writer->Update();
}
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;
}
/*=========================================================================
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 "otbImageList.h"
#include "otbImage.h"
int otbImageListNew(int argc, char * argv[])
{
try
{
const unsigned int Dimension = 2;
typedef unsigned char InputPixelType;
typedef otb::Image<InputPixelType,Dimension> InputImageType;
typedef otb::ImageList<InputImageType> ImageListType;
// Instantiating ImageList object
ImageListType::Pointer imageList = ImageListType::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.
Finish editing this message first!
Please register or to comment