diff --git a/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.h b/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.h index 4dba1c28d31b6b1c40e6817ab769670ab6e46810..3ea9e445a4bd4f44b5f15c174312d0b67307d85c 100644 --- a/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.h +++ b/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.h @@ -79,8 +79,7 @@ public: typedef typename InputImageType::ValueType ValueType; typedef typename InputImageType::PixelType PixelType; typedef typename InputImageType::SpacingType SpacingType; - /** Size and spacing vector typedefs */ - typedef std::vector<SpacingType> SpacingVectorType; + /** Size vector typedefs */ typedef std::vector<SizeType> SizeVectorType; /** Accessors */ itkSetMacro(NumberOfIterations, int); @@ -92,10 +91,11 @@ public: itkGetConstReferenceMacro(InfFiltre,OutputImageListPointerType); itkGetConstReferenceMacro(SupDeci,OutputImageListPointerType); itkGetConstReferenceMacro(InfDeci,OutputImageListPointerType); - /* /\** Spacings list getters *\/ */ -/* virtual std::vector<typename TOutputImage::SpacingType> GetSpacing(); */ -/* /\** Size list getters *\/ */ -/* virtual std::vector<typename TOutputImage::SizeType> GetSize(); */ + /** + * Get the vector of sizes + * \return The vector of sizes + */ + std::vector<typename TOutputImage::SizeType> GetSize(); protected: /** Constructor */ @@ -107,14 +107,6 @@ protected: virtual void GenerateData(); /** Printself method */ virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; - /** - * Resample an image according to specific size and spacing. - * \param image The image to down sample. - * \param size The new size of the image. - * \param spacing The new spacing of the image. - * \return The resampled image. - */ - InputImagePointerType ResampleImage(InputImagePointerType image, SizeType size, SpacingType spacing); private: /** Number of iterations of the algorithm */ @@ -129,8 +121,6 @@ protected: OutputImageListPointerType m_SupDeci; /** Inf details from subsampling operations */ OutputImageListPointerType m_InfDeci; - /** Spacings vector */ - SpacingVectorType m_Spacing; /** Sizes vector */ SizeVectorType m_Size; }; diff --git a/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.txx b/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.txx index 855817e9134ea6e9226686fd64ad58e8e6844c2a..a6dfc168cddd66a709a7900efcdd88ba6d7ca779 100644 --- a/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.txx +++ b/Code/MultiScale/otbMorphologicalPyramidAnalyseFilter.txx @@ -19,15 +19,12 @@ PURPOSE. See the above copyright notices for more information. #define _otbMorphologicalPyramidAnalyseFilter_txx #include "otbMorphologicalPyramidAnalyseFilter.h" + #include "itkSubtractImageFilter.h" #include "itkMaximumImageFilter.h" #include "itkImageDuplicator.h" -#include "itkResampleImageFilter.h" -#include "itkIdentityTransform.h" -#include "itkLinearInterpolateImageFunction.h" +#include "otbMorphologicalPyramidResampler.h" #include "itkProgressAccumulator.h" -#include "itkImageRegionConstIterator.h" -#include "itkImageRegionIterator.h" #include "otbMacro.h" namespace otb @@ -53,120 +50,16 @@ namespace otb MorphologicalPyramidAnalyseFilter<TInputImage,TOutputImage,TMorphoFilter> ::~MorphologicalPyramidAnalyseFilter(){} - // template <class TInputImage, class TOutputImage, class TMorphoFilter> - // std::vector<typename TOutputImage::SpacingType> - // MorphologicalPyramidAnalyseFilter<TInputImage,TOutputImage,TMorphoFilter> - // ::GetSpacing(void) - // { - // return m_Spacing; - // } - // template <class TInputImage, class TOutputImage, class TMorphoFilter> - // std::vector<typename TOutputImage::SizeType> - // MorphologicalPyramidAnalyseFilter<TInputImage,TOutputImage,TMorphoFilter> - // ::GetSize(void) - // { - // return m_Size; - // } - /** - * Resample an image according to specific size and spacing. - * \param image The image to down sample. - * \param size The new size of the image. - * \param spacing The new spacing of the image. - * \return The resampled image. + * Get the vector of sizes + * \return The vector of sizes */ template <class TInputImage, class TOutputImage, class TMorphoFilter> - typename MorphologicalPyramidAnalyseFilter<TInputImage,TOutputImage,TMorphoFilter> - ::InputImagePointerType + std::vector<typename TOutputImage::SizeType> MorphologicalPyramidAnalyseFilter<TInputImage,TOutputImage,TMorphoFilter> - ::ResampleImage(InputImagePointerType image, SizeType size, SpacingType spacing) + ::GetSize(void) { - otbMsgDebugMacro(<<"Call to the ResampleImage method"); - // local variables - unsigned int i; - InputImagePointerType result; - - // Filters definition - typedef itk::ResampleImageFilter<InputImageType,InputImageType> ResampleFilterType; - typedef itk::IdentityTransform<double,InputImageType::ImageDimension> TransformType; - typedef itk::LinearInterpolateImageFunction<InputImageType,double> InterpolatorType; - typedef itk::ImageRegionConstIterator<InputImageType> ConstIteratorType; - typedef itk::ImageRegionIterator<InputImageType> IteratorType; - - // Resampling Filter instantiation - typename ResampleFilterType::Pointer resampler = ResampleFilterType::New(); - typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); - typename TransformType::Pointer transform = TransformType::New(); - resampler->SetTransform(transform); - resampler->SetInterpolator(interpolator); - - // Resampling filter set up - resampler->SetOutputSpacing(spacing); - resampler->SetOutputOrigin(image->GetOrigin()); - resampler->SetSize(size); - //resampler->ReleaseDataFlagOn(); - - // Compute the resampled image - resampler->SetInput(image); - resampler->Update(); - result = resampler->GetOutput(); - otbMsgDebugMacro(<<"Resampling done."); - - // // Spacing, scale and size variables declarations -// // For special cases management -// typename InputImageType::RegionType::IndexType inputStart; -// typename InputImageType::RegionType::IndexType outputStart; -// typename InputImageType::RegionType::SizeType inputSize; -// typename InputImageType::RegionType inputRegion; -// typename InputImageType::RegionType outputRegion; - -// // Spmetimes the last line is black -// // In this case, we simply duplicate it -// if(spacing[0]*static_cast<float>(size[0]-1)>=(this->GetInput()->GetSpacing()[0] -// *static_cast<float>(image->GetLargestPossibleRegion().GetSize()[0]-1))) -// { -// inputStart[0]=size[0]-2; -// inputStart[1]=0; -// outputStart[0]=size[0]-1; -// outputStart[1]=0; -// inputSize[0]=1; -// inputSize[1]=size[1]; -// inputRegion.SetSize(inputSize); -// outputRegion.SetSize(inputSize); -// inputRegion.SetIndex(inputStart); -// outputRegion.SetIndex(outputStart); -// ConstIteratorType inputIt(result, inputRegion); -// IteratorType outputIt(result,outputRegion); -// // Last line duplication -// for(inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd();++inputIt,++outputIt) -// { -// outputIt.Set(inputIt.Get()); -// } -// } -// // Spmetimes the last column is black -// // In this case, we simply duplicate it -// if(spacing[1]*static_cast<float>(size[1]-1)>=(this->GetInput()->GetSpacing()[1] -// *static_cast<float>(image->GetLargestPossibleRegion().GetSize()[1]-1))) -// { -// inputStart[1]=size[1]-2; -// inputStart[0]=0; -// outputStart[1]=size[1]-1; -// outputStart[0]=0; -// inputSize[1]=1; -// inputSize[0]=size[0]; -// inputRegion.SetSize(inputSize); -// outputRegion.SetSize(inputSize); -// inputRegion.SetIndex(inputStart); -// outputRegion.SetIndex(outputStart); -// ConstIteratorType inputIt(result, inputRegion); -// IteratorType outputIt(result,outputRegion); -// // Last column duplication -// for(inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd();++inputIt,++outputIt) -// { -// outputIt.Set(inputIt.Get()); -// } -// } - return result; + return m_Size; } /** * Main computation method @@ -182,7 +75,8 @@ namespace otb typedef itk::SubtractImageFilter<InputImageType,InputImageType,OutputImageType> SubtractFilterType; typedef itk::MaximumImageFilter<InputImageType,InputImageType,InputImageType> MaxFilterType; typedef itk::ImageDuplicator<InputImageType> DuplicatorType; - + typedef otb::morphologicalPyramid::Resampler<InputImageType,OutputImageType> ResamplerType; + // Input Image duplication to the currentImage Pointer typename DuplicatorType::Pointer duplicator = DuplicatorType::New(); duplicator->SetInputImage(this->GetInput()); @@ -202,9 +96,9 @@ namespace otb typename MorphoFilterType::Pointer morphoFilter; typename MaxFilterType::Pointer max; typename SubtractFilterType::Pointer subtract1,subtract2,subtract3,subtract4; + typename ResamplerType::Pointer resampler1, resampler2; - // Spacing and size vectors declarations - typename InputImageType::SpacingType spacing; + // Size vector declaration typename InputImageType::SizeType size; // local variables declarations and initialisations @@ -249,33 +143,41 @@ namespace otb m_InfFiltre->PushBack(subtract2->GetOutput()); otbMsgDebugMacro("MorphologicalPyramidAnalyseFilter: step "<<i<<" - Image appended to m_InfFiltre"); // New Size/Spacing computation - spacing = morphoFilter->GetOutput()->GetSpacing(); size = morphoFilter->GetOutput()->GetLargestPossibleRegion().GetSize(); - m_Spacing.push_back(spacing); m_Size.push_back(size); otbMsgDebugMacro(<<"New size and spacing :"); for (int j =0; j<InputImageType::ImageDimension;j++) { sizeTmp=size[j]; size[j]=static_cast<int>(round(static_cast<double>(sizeTmp)/this->GetSubSampleScale())); - spacing[j]=spacing[j]*((static_cast<double>(sizeTmp))/(static_cast<double>(size[j]))); - otbMsgDebugMacro(<<" "<<size[j]<<", "<<spacing[j]); } + otbMsgDebugMacro(<<"New size: "<<size); // Image subsampling // Current image becomes the newly subsampled image - currentImage = ResampleImage(morphoFilter->GetOutput(),size,spacing); + resampler1 = ResamplerType::New(); + resampler1->SetInput(morphoFilter->GetOutput()); + resampler1->SetSize(size); + resampler1->Update(); + currentImage=resampler1->GetOutput(); + //currentImage = ResampleImage(morphoFilter->GetOutput(),size,spacing); + otbMsgDebugMacro(<<"MorphologicalPyramidAnalyseFilter: DownSampling OK "<<currentImage->GetLargestPossibleRegion().GetSize()); // New current image is appeneded to the output list OutputImageList->PushBack(currentImage); // Image upsampling - upsampled = ResampleImage(currentImage,m_Size.back(),m_Spacing.back()); - otbMsgDebugMacro(<<"MorphologicalPyramidAnalyseFilter: UpSampling OK "<<upsampled->GetLargestPossibleRegion().GetSize()); + //upsampled = ResampleImage(currentImage,m_Size.back(),m_Spacing.back()); + resampler2 = ResamplerType::New(); + resampler2->SetInput(resampler1->GetOutput()); + resampler2->SetSize(m_Size.back()); + resampler2->Update(); + + otbMsgDebugMacro(<<"MorphologicalPyramidAnalyseFilter: UpSampling OK "<<resampler2->GetOutput()->GetLargestPossibleRegion().GetSize()); // Computation of the details lost in the subsampling operation max=MaxFilterType::New(); max->SetInput1(morphoFilter->GetOutput()); - max->SetInput2(upsampled); + max->SetInput2(resampler2->GetOutput()); max->Update(); otbMsgDebugMacro(<<"MorphologicalPyramidAnalyseFilter: Max OK "<<max->GetOutput()->GetLargestPossibleRegion().GetSize()); @@ -291,7 +193,7 @@ namespace otb // SupDeci detail image computation subtract3 = SubtractFilterType::New(); subtract3->SetInput1(max->GetOutput()); - subtract3->SetInput2(upsampled); + subtract3->SetInput2(resampler2->GetOutput()); subtract3->Update(); otbMsgDebugMacro(<<"MorphologicalPyramidAnalyseFilter: subtract3 OK "<<subtract3->GetOutput()->GetLargestPossibleRegion().GetSize()); m_SupDeci->PushBack(subtract3->GetOutput()); diff --git a/Code/MultiScale/otbMorphologicalPyramidResampler.h b/Code/MultiScale/otbMorphologicalPyramidResampler.h new file mode 100644 index 0000000000000000000000000000000000000000..89258bedc3587b07226d16939d8125c0e74b1f61 --- /dev/null +++ b/Code/MultiScale/otbMorphologicalPyramidResampler.h @@ -0,0 +1,99 @@ +/*========================================================================= + +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 _otbMorphologicalPyramidResampler_h +#define _otbMorphologicalPyramidResampler_h + +#include "itkImageToImageFilter.h" + +namespace otb +{ + namespace morphologicalPyramid + { + /** + * \class Resampler + * \brief This class performs the resampling of the given image to the given size. + * + * This class performs the resampling of the given image to the given size.It is used + * in the MorphologicalPyramidAnalyseFilter and MorphologicalPyramidSynthesisFilter. + * + * The resampling is done by the itk::ResampleImageFilter, templated with the interpolator + * itk::LinearInterpolateImageFunction and the transform itk::ScaleTransform. + * + * \sa MorphologicalPyramidAnalyseFilter + * \sa MorphologicalPyramidSynthesisFilter + * \sa ResampleImageFilter + * \sa LinearInterpolateImageFunction + * \sa ScaleTransform + */ + template <class TInputImage, class TOutputImage> + class Resampler + : public itk::ImageToImageFilter<TInputImage,TOutputImage> + { + public : + /** Standard typedefs */ + typedef Resampler Self; + typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + /** Creation through object factory macro */ + itkNewMacro(Self); + /** Type macro */ + itkTypeMacro(MorphologicalPyramidResampler,ImageToImageFilter); + /** Template parameters typedefs */ + typedef TInputImage InputImageType; + typedef TOutputImage OutputImageType; + typedef typename OutputImageType::Pointer OutputImagePointer; + typedef typename InputImageType::Pointer InputImagePointer; + typedef typename OutputImageType::RegionType OutputImageRegionType; + typedef typename TInputImage::PixelType PixelType ; + typedef typename InputImageType::ConstPointer InputImageConstPointer; + typedef typename OutputImageType::SizeType SizeType; + typedef typename OutputImageType::SpacingType SpacingType; + /** Size parameter accessor */ + itkSetMacro(Size,SizeType); + itkGetMacro(Size,SizeType); + + protected: + /** Constructor */ + Resampler(); + /** Destructor */ + ~Resampler() {}; + /** Generate output information */ + virtual void GenerateOutputInformation(); + /** Configure input requested region to be the largest possible region */ + virtual void GenerateInputRequestedRegion(); + /** Configure output requested region to be the largest possible region */ + virtual void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output)); + /** Main computation method */ + void GenerateData(); + /** PrintSelf method */ + void PrintSelf(std::ostream& os, itk::Indent indent) const; + private : + Resampler(const Self&); // purposely not implemented + void operator=(const Self&); // purposely not implemented + /// Output image size + SizeType m_Size; + }; + } // End namespace morphologicalPyramid +}// End namespace otb + +#ifndef ITK_MANUAL_INSTANTIATION +#include "otbMorphologicalPyramidResampler.txx" +#endif + +#endif diff --git a/Code/MultiScale/otbMorphologicalPyramidResampler.txx b/Code/MultiScale/otbMorphologicalPyramidResampler.txx new file mode 100644 index 0000000000000000000000000000000000000000..720cd923490469ae193e0942f518ebb6a89b1565 --- /dev/null +++ b/Code/MultiScale/otbMorphologicalPyramidResampler.txx @@ -0,0 +1,233 @@ +/*========================================================================= + + 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 __otbMorphologicalPyramidResampler_txx +#define __otbMorphologicalPyramidResampler_txx +#include "otbMorphologicalPyramidResampler.h" +#include "itkResampleImageFilter.h" +#include "itkScaleTransform.h" +#include "itkNearestNeighborInterpolateImageFunction.h" +#include "itkLinearInterpolateImageFunction.h" +#include "itkProgressAccumulator.h" +#include "itkImageRegionConstIterator.h" +#include "itkImageRegionIterator.h" + +namespace otb +{ +namespace morphologicalPyramid +{ +/** + * Constructor + */ +template <class TInputImage,class TOuputImage> +Resampler<TInputImage, TOuputImage> +::Resampler(){} + /** + * Configure input requested region to be the largest possible region. + */ +template <class TInputImage,class TOuputImage> +void +Resampler<TInputImage, TOuputImage> +::GenerateInputRequestedRegion() +{ + // Superclass method call + Superclass::GenerateInputRequestedRegion(); + // Input and output image pointers retrieval + InputImagePointer inputPtr = const_cast<InputImageType *> (this->GetInput()); + OutputImagePointer outputPtr = this->GetOutput(); + // If the pointers are not correct + if ( !inputPtr || !outputPtr ) + { + // exit + return; + } + // else + // Configure input requested region to be the largest possible region + inputPtr->SetRequestedRegion( inputPtr->GetLargestPossibleRegion()); +} +/** + * Configure output requested region to be the largest possible region + */ +template <class TInputImage,class TOuputImage> +void +Resampler<TInputImage, TOuputImage> +::EnlargeOutputRequestedRegion(itk::DataObject *) +{ + this->GetOutput()->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion()); +} +/** + * Generate output information + */ +template <class TInputImage, class TOutputImage> +void +Resampler<TInputImage,TOutputImage> +::GenerateOutputInformation() +{ + // Superclass method call + Superclass::GenerateOutputInformation(); + // Input and output image pointers retrieval + InputImageConstPointer inputPtr = this->GetInput(); + OutputImagePointer outputPtr = this->GetOutput(); + // If the pointers are not correct + if ( !inputPtr || !outputPtr ) + { + // exit + return; + } + unsigned int i; + // Computing output spacing, size and index from input data + const typename InputImageType::SpacingType& inputSpacing = inputPtr->GetSpacing(); + const typename InputImageType::SizeType& inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); + const typename InputImageType::IndexType& inputStartIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); + typename OutputImageType::IndexType outputStartIndex; + typename OutputImageType::SpacingType spacing; + for (i = 0; i < OutputImageType::ImageDimension; i++) + { + outputStartIndex[i] = inputStartIndex[i] ; + } + // Affectation du spacing à l'image de sortie + outputPtr->SetSpacing( inputSpacing ); + // Génération de la région de l'image de sortie + typename OutputImageType::RegionType outputLargestPossibleRegion; + outputLargestPossibleRegion.SetSize(this->GetSize()); + outputLargestPossibleRegion.SetIndex(outputStartIndex); + outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); +} +/** + * Main computation method + */ +template <class TInputImage,class TOuputImage> +void +Resampler<TInputImage, TOuputImage> +::GenerateData() +{ + unsigned int i; + typename OutputImageType::Pointer result; + + // Filters typedefs + typedef itk::ResampleImageFilter<InputImageType,OutputImageType> ResampleFilterType; + typedef itk::ScaleTransform<double,InputImageType::ImageDimension> TransformType; + typedef itk::LinearInterpolateImageFunction<InputImageType,double> InterpolatorType; + typedef itk::ImageRegionConstIterator<OutputImageType> ConstIteratorType; + typedef itk::ImageRegionIterator<OutputImageType> IteratorType; + + // Resampling filter creation + typename ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); + typename TransformType::Pointer transform = TransformType::New(); + + // Scale parameters computation + typename TransformType::ParametersType scales(2); + typename InputImageType::SizeType inputSize = this->GetInput()->GetLargestPossibleRegion().GetSize(); + typename InputImageType::SpacingType inputSpacing = this->GetInput()->GetSpacing(); + scales[0]=static_cast<double>(inputSize[0])/static_cast<double>(m_Size[0]); + scales[1]=static_cast<double>(inputSize[1])/static_cast<double>(m_Size[1]); + transform->SetParameters(scales); + + // Resampling filter set up + resampler->SetTransform(transform); + resampler->SetInterpolator(interpolator); + resampler->SetOutputOrigin(this->GetInput()->GetOrigin()); + resampler->SetSize(this->GetSize()); + resampler->SetOutputSpacing(inputSpacing); + resampler->ReleaseDataFlagOn(); + + // Progress accumulator + itk::ProgressAccumulator::Pointer progress = itk::ProgressAccumulator::New(); + progress->SetMiniPipelineFilter(this); + progress->RegisterInternalFilter(resampler, .5f); + + // Input image connexion + resampler->SetInput(this->GetInput()); + resampler->Update(); + result = resampler->GetOutput(); + + // // variable definition for the following cases +// typename OutputImageType::RegionType::IndexType inputStart; +// typename OutputImageType::RegionType::IndexType outputStart; +// typename OutputImageType::RegionType::SizeType size; +// typename OutputImageType::RegionType inputRegion; +// typename OutputImageType::RegionType outputRegion; + +// // Gestion d'un cas particulier qui fait apparaître une bande +// // noire sur un des bords de l'image +// // Dans ce cas on duplique la dernière ligne de l'image +// if(m_Spacing[0]*static_cast<float>(m_Size[0]-1)>=(this->GetInput()->GetSpacing()[0]*static_cast<float>(this->GetInput()->GetLargestPossibleRegion().GetSize()[0]-1))) +// { +// inputStart[0]=m_Size[0]-2; +// inputStart[1]=0; +// outputStart[0]=m_Size[0]-1; +// outputStart[1]=0; +// size[0]=1; +// size[1]=m_Size[1]; +// inputRegion.SetSize(size); +// outputRegion.SetSize(size); +// inputRegion.SetIndex(inputStart); +// outputRegion.SetIndex(outputStart); +// ConstIteratorType inputIt(result, inputRegion); +// IteratorType outputIt(result,outputRegion); +// // Duplication de la dernière ligne +// for(inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd();++inputIt,++outputIt) +// { +// outputIt.Set(inputIt.Get()); +// } +// } +// // Gestion d'un cas particulier qui fait apparaître une bande +// // noire sur un des bords de l'image +// // Dans ce cas on duplique la dernière colonne de l'image +// if(m_Spacing[1]*static_cast<float>(m_Size[1]-1)>=(this->GetInput()->GetSpacing()[1]*static_cast<float>(this->GetInput()->GetLargestPossibleRegion().GetSize()[1]-1))) +// { +// typename OutputImageType::RegionType::IndexType inputStart; +// typename OutputImageType::RegionType::IndexType outputStart; +// typename OutputImageType::RegionType::SizeType size; +// typename OutputImageType::RegionType inputRegion; +// typename OutputImageType::RegionType outputRegion; +// inputStart[1]=m_Size[1]-2; +// inputStart[0]=0; +// outputStart[1]=m_Size[1]-1; +// outputStart[0]=0; +// size[1]=1; +// size[0]=m_Size[0]; +// inputRegion.SetSize(size); +// outputRegion.SetSize(size); +// inputRegion.SetIndex(inputStart); +// outputRegion.SetIndex(outputStart); +// ConstIteratorType inputIt(result, inputRegion); +// IteratorType outputIt(result,outputRegion); +// // Duplication de la dernière colonne +// for(inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd();++inputIt,++outputIt) +// { +// outputIt.Set(inputIt.Get()); +// } +// } + /** Output filter connexion */ + this->GraftOutput(result); +} +/** + * PrintSelf method + */ +template <class TInputImage,class TOuputImage> +void +Resampler<TInputImage, TOuputImage> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os,indent); + os << indent << "Size: " << m_Size << std::endl; +} +} // End namespace morphologicalPyramid +} // End namespace otb +#endif diff --git a/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.h b/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..566a520dc64ff54098689249a944523aed93ada2 --- /dev/null +++ b/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.h @@ -0,0 +1,117 @@ +/*========================================================================= + + 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 _otbMorphologicalPyramidSynthesisFilter_h +#define _otbMorphologicalPyramidSynthesisFilter_h + +#include "otbImageToImageListFilter.h" + +namespace otb +{ +/** + * \class MorphologicalPyramidSynthesisFilter + * \brief Recomposition of the multiscale analysis performed with + * a MorphologicalPyramidAnalyseFilter. + * + * Once a morphological pyramidal decompisition has been made, it is + * possible to rebuild without any loss of information the original + * image at full resolution. The MorphologicalPyramidsynthesisFilter + * provides such a functionality. At each iteration, it perfoms the + * up-sampling of the current image using the + * otb::morphologicalPyramid::Resampler filter, the addition of + * the details lost in down-sampling, and the addition of the details + * lost in smoothing. + * + * \ingroup MultiScale + * \sa MorphologicalPyramidAnalyseFilter + * \sa MorphologicalPyramidResampler + */ +template <class TInputImage, class TOutputImage> +class MorphologicalPyramidSynthesisFilter + : public ImageToImageListFilter<TInputImage,TOutputImage> +{ +public: +/** Standard typedefs */ + typedef MorphologicalPyramidSynthesisFilter Self; + typedef ImageToImageListFilter<TInputImage,TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + /** Creation through object factory macro */ + itkNewMacro(Self); + /** Type macro */ + itkTypeMacro(MorphologicalPyramidSynthesisFilter,MorphologicalPyramidSynthesisFilter); + /** Input image dimension constant macro */ + itkStaticConstMacro(InputImageDimension, unsigned int,TInputImage::ImageDimension); + /** Output related typedefs */ + typedef typename Superclass::OutputImageType OutputImageType; + typedef typename Superclass::OutputImageListType OutputImageListType; + typedef typename OutputImageListType::Pointer OutputImageListPointerType; + typedef typename Superclass::OutputImagePointerType OutputImagePointerType; + typedef typename Superclass::OutputImageListType::Iterator ImageListIterator; + typedef typename Superclass::OutputImageListType::ReverseIterator ImageListReverseIterator; + /** Input related typedefs */ + typedef typename Superclass::InputImageType InputImageType; + typedef typename Superclass::InputImageRegionType InputImageRegionType; + typedef typename InputImageType::Pointer InputImagePointer; + typedef typename InputImageType::ConstPointer InputImageConstPointer; + typedef typename InputImageType::SizeType SizeType; + typedef typename InputImageType::ValueType ValueType; + typedef typename InputImageType::PixelType PixelType; + typedef typename InputImageType::SpacingType SpacingType; + /** Size vector typedefs */ + typedef std::vector<SizeType> SizeVectorType; + typedef typename SizeVectorType::iterator SizeIterator; + typedef typename SizeVectorType::reverse_iterator SizeReverseIterator; + /** Details images lists setters */ + itkSetMacro(SupFiltre,OutputImageListPointerType); + itkSetMacro(InfFiltre,OutputImageListPointerType); + itkSetMacro(SupDeci,OutputImageListPointerType); + itkSetMacro(InfDeci,OutputImageListPointerType); + /** + * Set the vector of sizes + * \param size The vector of sizes + */ + virtual void SetSize(std::vector<typename TOutputImage::SizeType> size); + +protected: + /** Constructor */ + MorphologicalPyramidSynthesisFilter(); + /** Destructor */ + ~MorphologicalPyramidSynthesisFilter(); + virtual void GenerateOutputInformation(){}; // does nothing + /** Main computation method */ + virtual void GenerateData(); + /** Printself method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + /** Sup details from filtering operations */ + OutputImageListPointerType m_SupFiltre; + /** Inf details from filtering operations */ + OutputImageListPointerType m_InfFiltre; + /** Sup details from subsampling operations */ + OutputImageListPointerType m_SupDeci; + /** Inf details from subsampling operations */ + OutputImageListPointerType m_InfDeci; + /** Sizes vector */ + SizeVectorType m_Size; +}; +}// End namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbMorphologicalPyramidSynthesisFilter.txx" +#endif + +#endif diff --git a/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.txx b/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..673231e1832e1d1ec976c0bb9f68acfec1a64505 --- /dev/null +++ b/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.txx @@ -0,0 +1,146 @@ +/*========================================================================= + +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 _otbMorphologicalPyramidSynthesisFilter_txx +#define _otbMorphologicalPyramidSynthesisFilter_txx + +#include "otbMorphologicalPyramidSynthesisFilter.h" + +#include "otbMorphologicalPyramidResampler.h" +#include "itkSubtractImageFilter.h" +#include "itkAddImageFilter.h" +#include "itkImageDuplicator.h" + +namespace otb +{ +/** + * Constructor + */ +template <class TInputImage, class TOutputImage> +MorphologicalPyramidSynthesisFilter<TInputImage,TOutputImage> +::MorphologicalPyramidSynthesisFilter() {} +/** + * Destructor + */ +template <class TInputImage, class TOutputImage> +MorphologicalPyramidSynthesisFilter<TInputImage,TOutputImage> +::~MorphologicalPyramidSynthesisFilter() {} +/** + * Get the vector of sizes + * \param size The vector of sizes + */ +template <class TInputImage, class TOutputImage> +void +MorphologicalPyramidSynthesisFilter<TInputImage,TOutputImage> +::SetSize(std::vector<typename TOutputImage::SizeType> size) +{ + m_Size=size; +} +/** + * Main computation method + */ +template <class TInputImage, class TOutputImage> +void +MorphologicalPyramidSynthesisFilter<TInputImage,TOutputImage> +::GenerateData(void) +{ + // Input image pointer + OutputImageListType * OutputImageList = this->GetOutput(); + // typedefs of the filters + typedef itk::SubtractImageFilter<InputImageType,InputImageType,OutputImageType> SubtractFilterType; + typedef itk::AddImageFilter<InputImageType,InputImageType,InputImageType> AddFilterType; + typedef otb::morphologicalPyramid::Resampler<InputImageType,InputImageType> ResamplerType; + typedef itk::ImageDuplicator<InputImageType> DuplicatorType; + + // Input Image duplication to the currentImage Pointer + typename DuplicatorType::Pointer duplicator = DuplicatorType::New(); + duplicator->SetInputImage(this->GetInput()); + duplicator->Update(); + + // Input Image duplication to the currentImage Pointer + typename InputImageType::Pointer currentImage =duplicator->GetOutput(); + + // Filters declarations + typename AddFilterType::Pointer add1, add2; + typename SubtractFilterType::Pointer subtract1,subtract2; + typename ResamplerType::Pointer resampler; + + // Iterators definition + ImageListReverseIterator itInfFiltre = m_InfFiltre->ReverseBegin(); + ImageListReverseIterator itSupFiltre = m_SupFiltre->ReverseBegin(); + ImageListReverseIterator itInfDeci = m_InfDeci->ReverseBegin(); + ImageListReverseIterator itSupDeci = m_SupDeci->ReverseBegin(); + SizeReverseIterator itSize = m_Size.rbegin(); + + //--------------------------------------------------------// + // Main loop // + //--------------------------------------------------------// + while( itInfFiltre!=m_InfFiltre->ReverseEnd() + && itSupFiltre!=m_SupFiltre->ReverseEnd() + && itInfDeci!=m_InfDeci->ReverseEnd() + && itSupDeci!=m_SupDeci->ReverseEnd() + && itSize!=m_Size.rend()) + { + + // Upsampling current image + resampler = ResamplerType::New(); + resampler->SetSize(*itSize); + resampler->SetInput(currentImage); + + // Adding *Sup details from current level + add1= AddFilterType::New(); + add1->SetInput1(resampler->GetOutput()); + add1->SetInput2(itSupFiltre.Get()); + add2= AddFilterType::New(); + add2->SetInput1(add1->GetOutput()); + add2->SetInput2(itSupDeci.Get()); + + // Adding *Inf details from current level + subtract1= SubtractFilterType::New(); + subtract1->SetInput1(add2->GetOutput()); + subtract1->SetInput2(itInfFiltre.Get()); + subtract2= SubtractFilterType::New(); + subtract2->SetInput1(subtract1->GetOutput()); + subtract2->SetInput2(itInfDeci.Get()); + subtract2->Update(); + + // Updating current image + currentImage=subtract2->GetOutput(); + OutputImageList->PushBack(currentImage); + + // Iterators incrementation + ++itSupFiltre; + ++itInfFiltre; + ++itSupDeci; + ++itInfDeci; + ++itSize; + } + } +/** + * PrintSelf method + */ +template <class TInputImage, class TOutputImage> +void +MorphologicalPyramidSynthesisFilter<TInputImage,TOutputImage> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} +} // End namespace otb + +#endif + diff --git a/Testing/Code/MultiScale/CMakeLists.txt b/Testing/Code/MultiScale/CMakeLists.txt index 537918e5a4b14424950785b83603daeab99f7945..c84441d0b25a239fd9d35024fd60a9b88e56ccda 100644 --- a/Testing/Code/MultiScale/CMakeLists.txt +++ b/Testing/Code/MultiScale/CMakeLists.txt @@ -14,6 +14,28 @@ SET(TOL 0.0) SET(MULTISCALE_TESTS ${CXX_TEST_PATH}/otbMultiScaleTests) + +# ------- otb::MorphologicalPyramidAnalyseFilter ---------- + +ADD_TEST(msTuMorphoPyrResamplerNew ${MULTISCALE_TESTS} + otbMorphologicalPyramidResamplerNew) + +ADD_TEST(msTvMorphoPyrResampler ${MULTISCALE_TESTS} + --compare-n-images ${TOL} 2 + ${BASELINE}/msPyrResampler_IKO_LesHalles_256_2.tif + ${TEMP}/msPyrResampler_IKO_LesHalles_256_2.tif + ${BASELINE}/msPyrResampler_IKO_LesHalles_full.tif + ${TEMP}/msPyrResampler_IKO_LesHalles_full.tif + otbMorphologicalPyramidResampler + ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + ${TEMP}/msPyrResampler_IKO_LesHalles_256_2.tif + ${TEMP}/msPyrResampler_IKO_LesHalles_full.tif + 256 + 256 +# 2.0 +# 2.0 + ) + # ------- otb::MorphologicalPyramidAnalyseFilter ---------- ADD_TEST(msTuMorphoPyrAnalyseFilterNew ${MULTISCALE_TESTS} @@ -38,10 +60,29 @@ ADD_TEST(msTvMorphoPyrAnalyseFilter ${MULTISCALE_TESTS} 2 2.0) +# ------- otb::MorphologicalPyramidAnalyseFilter ---------- + +ADD_TEST(msTuMorphoPyrSynthesisFilterNew ${MULTISCALE_TESTS} + otbMorphologicalPyramidSynthesisFilterNew) + +ADD_TEST(msTvMorphoPyrSynthesisFilter ${MULTISCALE_TESTS} + --compare-image ${TOL} + ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + ${TEMP}/msPyrSynth_IKO_Halles_4_2.tif + otbMorphologicalPyramidSynthesisFilter + ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + ${TEMP}/msPyrSynth_IKO_Halles_4_2.tif + 4 + 2.0) + # ------- Fichiers sources CXX ----------------------------------- SET(BasicMultiScale_SRCS +otbMorphologicalPyramidResamplerNew.cxx +otbMorphologicalPyramidResampler.cxx otbMorphologicalPyramidAnalyseFilterNew.cxx otbMorphologicalPyramidAnalyseFilter.cxx +otbMorphologicalPyramidSynthesisFilterNew.cxx +otbMorphologicalPyramidSynthesisFilter.cxx ) diff --git a/Testing/Code/MultiScale/otbMorphologicalPyramidResampler.cxx b/Testing/Code/MultiScale/otbMorphologicalPyramidResampler.cxx new file mode 100644 index 0000000000000000000000000000000000000000..52306d904ae8eb112f76c13a24f3e488ae6645eb --- /dev/null +++ b/Testing/Code/MultiScale/otbMorphologicalPyramidResampler.cxx @@ -0,0 +1,98 @@ +/*========================================================================= + +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 "otbMorphologicalPyramidResampler.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbImage.h" + +int otbMorphologicalPyramidResampler(int argc, char * argv[]) +{ + try + { + const char* inputFilename = argv[1]; + const char* outputFilename1 = argv[2]; + const char* outputFilename2 = argv[3]; + const unsigned int size_x = atoi(argv[4]); + const unsigned int size_y = atoi(argv[5]); + // const float spacing_x = atof(argv[5]); +// const float spacing_y = atof(argv[6]); + + 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::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + + typedef otb::morphologicalPyramid::Resampler<InputImageType,OutputImageType> + ResamplerType; + + // Input image reading + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(inputFilename); + + InputImageType::SizeType size; + size[0] = size_x; + size[1] = size_y; + + // InputImageType::SpacingType spacing; +// spacing[0] = spacing_x; +// spacing[1] = spacing_y; + + // Instantiation + ResamplerType::Pointer resampler = ResamplerType::New(); + resampler->SetInput(reader->GetOutput()); + resampler->SetSize(size); + // resampler->SetSpacing(spacing); + + // File writing + WriterType::Pointer writer = WriterType::New(); + writer->SetInput(resampler->GetOutput()); + writer->SetFileName(outputFilename1); + writer->Update(); + + + ResamplerType::Pointer resampler2 = ResamplerType::New(); + resampler2->SetInput(resampler->GetOutput()); + resampler2->SetSize(reader->GetOutput()->GetLargestPossibleRegion().GetSize()); + + WriterType::Pointer writer2 = WriterType::New(); + writer2->SetInput(resampler2->GetOutput()); + writer2->SetFileName(outputFilename2); + writer2->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; + } diff --git a/Testing/Code/MultiScale/otbMorphologicalPyramidResamplerNew.cxx b/Testing/Code/MultiScale/otbMorphologicalPyramidResamplerNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..57214c40ee8e174974e1ae7344d9ce91030a6a0c --- /dev/null +++ b/Testing/Code/MultiScale/otbMorphologicalPyramidResamplerNew.cxx @@ -0,0 +1,53 @@ +/*========================================================================= + +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 "otbMorphologicalPyramidResampler.h" +#include "otbImage.h" + +int otbMorphologicalPyramidResamplerNew(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::morphologicalPyramid::Resampler<InputImageType,OutputImageType> + ResamplerType; + + // Instantiation + ResamplerType::Pointer resampler = ResamplerType::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; + } diff --git a/Testing/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.cxx b/Testing/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..347c7e3e082ceeb69a5d1e3418eded1d294fe9eb --- /dev/null +++ b/Testing/Code/MultiScale/otbMorphologicalPyramidSynthesisFilter.cxx @@ -0,0 +1,88 @@ +/*========================================================================= + +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 "otbMorphologicalPyramidAnalyseFilter.h" +#include "otbMorphologicalPyramidSynthesisFilter.h" +#include "otbOpeningClosingMorphologicalFilter.h" +#include "itkBinaryBallStructuringElement.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbImage.h" + +int otbMorphologicalPyramidSynthesisFilter(int argc, char * argv[]) +{ + try + { + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; + const unsigned int numberOfIterations = atoi(argv[3]); + const float subSampleScale = atof(argv[4]); + + 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::ImageFileReader<InputImageType> ReaderType; + typedef otb::ImageFileWriter<OutputImageType> WriterType; + + typedef itk::BinaryBallStructuringElement<InputPixelType,Dimension> StructuringElementType; + typedef otb::OpeningClosingMorphologicalFilter<InputImageType,InputImageType,StructuringElementType> + OpeningClosingFilterType; + typedef otb::MorphologicalPyramidAnalyseFilter<InputImageType,OutputImageType,OpeningClosingFilterType> + PyramidAnalyseFilterType; + typedef otb::MorphologicalPyramidSynthesisFilter<InputImageType,OutputImageType> + PyramidSynthesisFilterType; + + // Reading input image + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(inputFilename); + + // Analysis + PyramidAnalyseFilterType::Pointer pyramidAnalyse = PyramidAnalyseFilterType::New(); + pyramidAnalyse->SetNumberOfIterations(numberOfIterations); + pyramidAnalyse->SetSubSampleScale(subSampleScale); + pyramidAnalyse->SetInput(reader->GetOutput()); + pyramidAnalyse->Update(); + + // Synthesis + PyramidSynthesisFilterType::Pointer pyramidSynthesis = PyramidSynthesisFilterType::New(); + pyramidSynthesis->SetInput(pyramidAnalyse->GetOutput()->Back()); + pyramidSynthesis->SetSupFiltre(pyramidAnalyse->GetSupFiltre()); + pyramidSynthesis->SetSupDeci(pyramidAnalyse->GetSupDeci()); + pyramidSynthesis->SetInfFiltre(pyramidAnalyse->GetInfFiltre()); + pyramidSynthesis->SetInfDeci(pyramidAnalyse->GetInfDeci()); + } + 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; + } diff --git a/Testing/Code/MultiScale/otbMorphologicalPyramidSynthesisFilterNew.cxx b/Testing/Code/MultiScale/otbMorphologicalPyramidSynthesisFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d6dc7f34fd8123efa0a44e67f848873bccc1af6b --- /dev/null +++ b/Testing/Code/MultiScale/otbMorphologicalPyramidSynthesisFilterNew.cxx @@ -0,0 +1,57 @@ +/*========================================================================= + +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 "otbMorphologicalPyramidSynthesisFilter.h" +#include "otbImage.h" + +int otbMorphologicalPyramidSynthesisFilterNew(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::MorphologicalPyramidSynthesisFilter<InputImageType,OutputImageType> + PyramidSynthesisFilterType; + + // Instantiation + PyramidSynthesisFilterType::Pointer pyramidSynthesis = PyramidSynthesisFilterType::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; + } diff --git a/Testing/Code/MultiScale/otbMultiScaleTests.cxx b/Testing/Code/MultiScale/otbMultiScaleTests.cxx index 5433d46e8011e01158536693a826296f963b8c64..b023e1aec33a46659df120dd237c744ae4cd9c0c 100644 --- a/Testing/Code/MultiScale/otbMultiScaleTests.cxx +++ b/Testing/Code/MultiScale/otbMultiScaleTests.cxx @@ -26,6 +26,10 @@ void RegisterTests() { +REGISTER_TEST(otbMorphologicalPyramidResamplerNew); +REGISTER_TEST(otbMorphologicalPyramidResampler); REGISTER_TEST(otbMorphologicalPyramidAnalyseFilterNew); REGISTER_TEST(otbMorphologicalPyramidAnalyseFilter); +REGISTER_TEST(otbMorphologicalPyramidSynthesisFilterNew); +REGISTER_TEST(otbMorphologicalPyramidSynthesisFilter); }