From 5d4387d405814353481047ca66a33b76e16e526d Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@gmail.com> Date: Tue, 27 Oct 2009 16:59:55 +0100 Subject: [PATCH] TEST:imagelisttovectorimagefilter2 test Modified --- Code/Common/otbObjectList.h | 12 +-- Code/IO/otbMWImageIO.cxx | 4 +- .../otbImageListToVectorImageFilter2.cxx | 91 +++++++++++++++++++ 3 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 Testing/Code/BasicFilters/otbImageListToVectorImageFilter2.cxx diff --git a/Code/Common/otbObjectList.h b/Code/Common/otbObjectList.h index a5d6574479..67b079f7d6 100644 --- a/Code/Common/otbObjectList.h +++ b/Code/Common/otbObjectList.h @@ -39,10 +39,10 @@ class ITK_EXPORT ObjectList : public itk::DataObject { public: /** Standard typedefs */ - typedef ObjectList Self; - typedef itk::DataObject Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef ObjectList Self; + typedef itk::DataObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; /** Type macro */ itkTypeMacro(ObjectList,DataObject); @@ -52,8 +52,8 @@ public: /** Template parameter typedefs */ typedef TObject ObjectType; - typedef itk::SmartPointer<ObjectType> ObjectPointerType; - typedef std::vector<ObjectPointerType> InternalContainerType; + typedef itk::SmartPointer<ObjectType> ObjectPointerType; + typedef std::vector<ObjectPointerType> InternalContainerType; /** * Set the minimum capacity of the vector. diff --git a/Code/IO/otbMWImageIO.cxx b/Code/IO/otbMWImageIO.cxx index dd98340a4b..3b926aa0a2 100644 --- a/Code/IO/otbMWImageIO.cxx +++ b/Code/IO/otbMWImageIO.cxx @@ -138,7 +138,7 @@ void MWImageIO::Read(void* buffer) for (int LineNo = lPremiereLigne;LineNo <lPremiereLigne + lNbLignes; LineNo++ ) { offset = headerLength + numberOfBytesPerLines * static_cast<std::streamoff>(LineNo); - offset += static_cast<std::streamoff> ( this->GetComponentSize() * lPremiereColonne ); + offset += static_cast<std::streamoff>( this->GetComponentSize() * lPremiereColonne ); m_File.seekg(offset, std::ios::beg); m_File.read( static_cast<char *>( p + cpt ), numberOfBytesToBeRead ); numberOfBytesRead = m_File.gcount(); @@ -308,7 +308,7 @@ void MWImageIO::Write(const void* buffer) for (unsigned long LineNo = lPremiereLigne;LineNo <lPremiereLigne + lNbLignes; LineNo++ ) { offset = headerLength + numberOfBytesPerLines * static_cast<std::streamoff>(LineNo); - offset += static_cast<std::streamoff> ( this->GetComponentSize() * lPremiereColonne ); + offset += static_cast<std::streamoff>( this->GetComponentSize() * lPremiereColonne ); m_File.seekp(offset, std::ios::beg); m_File.write( static_cast<const char *>( p + cpt ), numberOfBytesToBeWrite ); // m_File.write( (char *)( floatImage + cpt ), numberOfBytesToBeWriteFloat ); diff --git a/Testing/Code/BasicFilters/otbImageListToVectorImageFilter2.cxx b/Testing/Code/BasicFilters/otbImageListToVectorImageFilter2.cxx new file mode 100644 index 0000000000..a4bb87df50 --- /dev/null +++ b/Testing/Code/BasicFilters/otbImageListToVectorImageFilter2.cxx @@ -0,0 +1,91 @@ +/*========================================================================= + + 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 "otbImageListToVectorImageFilter.h" +#include "otbVectorImage.h" +#include "otbImage.h" +#include "otbImageList.h" +#include "otbImageFileReader.h" + + +int otbImageListToVectorImageFilter2(int argc, char * argv[]) +{ + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + + char * infname1 = argv[1]; + char * infname2 = argv[2]; + char * infname3 = argv[3]; +// char * outfname = argv[4]; + + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::VectorImage<PixelType,Dimension> VectorImageType; +// typedef VectorImageType::Pointer VectorImagePointerType; + typedef otb::ImageList<ImageType> ImageListType; + + // IO + typedef otb::ImageFileReader<ImageType> ReaderType; +// typedef otb::ImageFileWriter<VectorImageType> WriterType; + + typedef otb::ImageListToVectorImageFilter<ImageListType,VectorImageType> ImageListToVectorImageFilterType; + + // Instantiating object + ImageListToVectorImageFilterType::Pointer filter = ImageListToVectorImageFilterType::New(); + + // Building image list + + ReaderType::Pointer reader1, reader2, reader3; + + reader1 = ReaderType::New(); + reader1->SetFileName(infname1); + + reader2 = ReaderType::New(); + reader2->SetFileName(infname2); + + reader3 = ReaderType::New(); + reader3->SetFileName(infname3); + + ImageListType::Pointer imageList = ImageListType::New(); + imageList->PushBack(reader1->GetOutput()); + imageList->PushBack(reader2->GetOutput()); + imageList->PushBack(reader3->GetOutput()); + + filter->SetInput(imageList); + + VectorImageType::Pointer m_OutputImage = VectorImageType::New(); + m_OutputImage = filter->GetOutput(); + + m_OutputImage->UpdateOutputInformation(); + + unsigned int nbComp1 = m_OutputImage->GetNumberOfComponentsPerPixel(); + + imageList->PopBack(); + + m_OutputImage->UpdateOutputInformation(); + + unsigned int nbComp2 = m_OutputImage->GetNumberOfComponentsPerPixel (); + std::cout << "component 1: " << nbComp1 << std::endl; + std::cout << "component 2: " << nbComp2 << std::endl; + + if ( nbComp2 != nbComp1 - 1) + + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} -- GitLab