diff --git a/Code/FeatureExtraction/otbFourierMellinDescriptorsImageFunction.txx b/Code/FeatureExtraction/otbFourierMellinDescriptorsImageFunction.txx index 5c02bf718fbe8727ff4f18c97ec3a7d4244ba559..ebdbac7cc77c597954a8c837d1d8bc3a532d2eb9 100644 --- a/Code/FeatureExtraction/otbFourierMellinDescriptorsImageFunction.txx +++ b/Code/FeatureExtraction/otbFourierMellinDescriptorsImageFunction.txx @@ -28,8 +28,8 @@ namespace otb { /** - * Constructor - */ + * Constructor + */ template <class TInputImage, class TCoordRep> FourierMellinDescriptorsImageFunction<TInputImage, TCoordRep> ::FourierMellinDescriptorsImageFunction() diff --git a/Code/ObjectDetection/otbFlusserMomentsIFFactory.h b/Code/ObjectDetection/otbFlusserMomentsIFFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..5d8d4028850cc26373de6037d05a4b2016390125 --- /dev/null +++ b/Code/ObjectDetection/otbFlusserMomentsIFFactory.h @@ -0,0 +1,94 @@ +/*========================================================================= + + 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 __otbFlusserMomentsIFFactory_h +#define __otbFlusserMomentsIFFactory_h + +#include "itkLightObject.h" + +#include "otbMetaImageFunction.h" +#include "itkDataObject.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" +#include "otbImageFunctionAdaptor.h" +#include "otbFlusserMomentsImageFunction.h" + + +namespace otb +{ +/** \class FlusserMomentsFFactory + * \brief add a FlusserMoments image function to a + * MetaImageFunction + * + * This class aims at adding an adapted + * FlusserMomentsImageFunction to an existing + * MetaImageFunction through the method Create. + * + */ + +template <class TImageType, class TCoordRep = double, class TPrecision = double> +class ITK_EXPORT FlusserMomentsIFFactory : + public itk::LightObject +{ +public: + /** Standard class typedefs. */ + typedef FlusserMomentsIFFactory Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + // New macro + itkNewMacro(Self); + + // RTTI typeinfo + itkTypeMacro(FlusserMomentsIFFactory,itk::LightObject); + + // Input and output typedef + typedef TImageType InputImageType; + typedef TCoordRep CoordRepType; + typedef TPrecision PrecisionType; + + // Other typedef + typedef typename MetaImageFunction<TPrecision>::Pointer MetaImageFunctionPointerType; + typedef typename std::vector<itk::DataObject::Pointer> DataObjectContainerType; + typedef typename std::vector<PrecisionType> ParamContainerType; + typedef FlusserMomentsImageFunction<InputImageType, CoordRepType> + FlusserMomentsIF; + typedef ImageFunctionAdaptor<FlusserMomentsIF> AdaptedFlusserMomentsIF; + + void Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container); + +protected: + FlusserMomentsIFFactory(){} + ~FlusserMomentsIFFactory(){} + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + FlusserMomentsIFFactory(const Self& ); //purposely not implemented + void operator=(const Self& ); //purposely not implemented + +}; + +} // End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbFlusserMomentsIFFactory.txx" +#endif + +#endif diff --git a/Code/ObjectDetection/otbFlusserMomentsIFFactory.txx b/Code/ObjectDetection/otbFlusserMomentsIFFactory.txx new file mode 100644 index 0000000000000000000000000000000000000000..062db758776a9f77aedf15138d0054717ea3cb83 --- /dev/null +++ b/Code/ObjectDetection/otbFlusserMomentsIFFactory.txx @@ -0,0 +1,52 @@ +/*========================================================================= + + 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 __otbFlusserMomentsIFFactory_txx +#define __otbFlusserMomentsIFFactory_txx + +#include "otbFlusserMomentsIFFactory.h" + + +namespace otb +{ +template <class TImageType, class TCoordRep, class TPrecision> +void +FlusserMomentsIFFactory<TImageType, TCoordRep, TPrecision> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +template <class TImageType, class TCoordRep, class TPrecision> +void +FlusserMomentsIFFactory<TImageType, TCoordRep, TPrecision> +::Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container) +{ + typename AdaptedFlusserMomentsIF::Pointer function = AdaptedFlusserMomentsIF::New(); + + function->SetInputImage(image); + function->GetInternalImageFunction()->SetNeighborhoodRadius(param[0]); + + metaIF->AddFunction(function); + container->push_back(image); +} + +}//end namespace +#endif diff --git a/Code/ObjectDetection/otbFourierMellinDescriptorsIFFactory.h b/Code/ObjectDetection/otbFourierMellinDescriptorsIFFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..94fe941b1ce0aeca8f85ab53914be98a0659a846 --- /dev/null +++ b/Code/ObjectDetection/otbFourierMellinDescriptorsIFFactory.h @@ -0,0 +1,94 @@ +/*========================================================================= + + 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 __otbFourierMellinDescriptorsIFFactory_h +#define __otbFourierMellinDescriptorsIFFactory_h + +#include "itkLightObject.h" + +#include "otbMetaImageFunction.h" +#include "itkDataObject.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" +#include "otbImageFunctionAdaptor.h" +#include "otbFourierMellinDescriptorsImageFunction.h" + + +namespace otb +{ +/** \class FourierMellinDescriptorsFFactory + * \brief add a FourierMellinDescriptors image function to a + * MetaImageFunction + * + * This class aims at adding an adapted + * FourierMellinDescriptorsImageFunction to an existing + * MetaImageFunction through the method Create. + * + */ + +template <class TImageType, class TCoordRep = double, class TPrecision = double> +class ITK_EXPORT FourierMellinDescriptorsIFFactory : + public itk::LightObject +{ +public: + /** Standard class typedefs. */ + typedef FourierMellinDescriptorsIFFactory Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + // New macro + itkNewMacro(Self); + + // RTTI typeinfo + itkTypeMacro(FourierMellinDescriptorsIFFactory,itk::LightObject); + + // Input and output typedef + typedef TImageType InputImageType; + typedef TCoordRep CoordRepType; + typedef TPrecision PrecisionType; + + // Other typedef + typedef typename MetaImageFunction<TPrecision>::Pointer MetaImageFunctionPointerType; + typedef typename std::vector<itk::DataObject::Pointer> DataObjectContainerType; + typedef typename std::vector<PrecisionType> ParamContainerType; + typedef FourierMellinDescriptorsImageFunction<InputImageType, CoordRepType> + FourierMellinDescriptorsIF; + typedef ImageFunctionAdaptor<FourierMellinDescriptorsIF> AdaptedFourierMellinDescriptorsIF; + + void Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container); + +protected: + FourierMellinDescriptorsIFFactory(){} + ~FourierMellinDescriptorsIFFactory(){} + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + FourierMellinDescriptorsIFFactory(const Self& ); //purposely not implemented + void operator=(const Self& ); //purposely not implemented + +}; + +} // End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbFourierMellinDescriptorsIFFactory.txx" +#endif + +#endif diff --git a/Code/ObjectDetection/otbFourierMellinDescriptorsIFFactory.txx b/Code/ObjectDetection/otbFourierMellinDescriptorsIFFactory.txx new file mode 100644 index 0000000000000000000000000000000000000000..388ffc3ab042d0ad2799ce2926bedc4463a3c704 --- /dev/null +++ b/Code/ObjectDetection/otbFourierMellinDescriptorsIFFactory.txx @@ -0,0 +1,54 @@ +/*========================================================================= + + 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 __otbFourierMellinDescriptorsIFFactory_txx +#define __otbFourierMellinDescriptorsIFFactory_txx + +#include "otbFourierMellinDescriptorsIFFactory.h" + + +namespace otb +{ +template <class TImageType, class TCoordRep, class TPrecision> +void +FourierMellinDescriptorsIFFactory<TImageType, TCoordRep, TPrecision> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +template <class TImageType, class TCoordRep, class TPrecision> +void +FourierMellinDescriptorsIFFactory<TImageType, TCoordRep, TPrecision> +::Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container) +{ + typename AdaptedFourierMellinDescriptorsIF::Pointer function = AdaptedFourierMellinDescriptorsIF::New(); + + function->SetInputImage(image); + function->GetInternalImageFunction()->SetNeighborhoodRadius(param[0]); + function->GetInternalImageFunction()->SetPmax(param[1]); + function->GetInternalImageFunction()->SetQmax(param[2]); + + metaIF->AddFunction(function); + container->push_back(image); +} + +}//end namespace +#endif diff --git a/Code/ObjectDetection/otbLocalHistogramIFFactory.h b/Code/ObjectDetection/otbLocalHistogramIFFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..b44bf505700a35e69d6b90905f4b0856153ffc22 --- /dev/null +++ b/Code/ObjectDetection/otbLocalHistogramIFFactory.h @@ -0,0 +1,94 @@ +/*========================================================================= + + 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 __otbLocalHistogramIFFactory_h +#define __otbLocalHistogramIFFactory_h + +#include "itkLightObject.h" + +#include "otbMetaImageFunction.h" +#include "itkDataObject.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" +#include "otbImageFunctionAdaptor.h" +#include "otbLocalHistogramImageFunction.h" + + +namespace otb +{ +/** \class LocalHistogramIFFactory + * \brief add a LocalHistogram image function to a + * MetaImageFunction + * + * This class aims at adding an adapted + * LocalHistogramImageFunction to an existing MetaImageFunction + * through the method Create. + * + */ + +template <class TImageType, class TCoordRep = double, class TPrecision = double> +class ITK_EXPORT LocalHistogramIFFactory : + public itk::LightObject +{ +public: + /** Standard class typedefs. */ + typedef LocalHistogramIFFactory Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + // New macro + itkNewMacro(Self); + + // RTTI typeinfo + itkTypeMacro(LocalHistogramIFFactory,itk::LightObject); + + // Input and output typedef + typedef TImageType InputImageType; + typedef TCoordRep CoordRepType; + typedef TPrecision PrecisionType; + + // Other typedef + typedef typename MetaImageFunction<TPrecision>::Pointer MetaImageFunctionPointerType; + typedef typename std::vector<itk::DataObject::Pointer> DataObjectContainerType; + typedef typename std::vector<PrecisionType> ParamContainerType; + typedef LocalHistogramImageFunction<InputImageType, CoordRepType> + LocalHistogramIF; + typedef ImageFunctionAdaptor<LocalHistogramIF> AdaptedLocalHistogramIF; + + void Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container); + +protected: + LocalHistogramIFFactory(){} + ~LocalHistogramIFFactory(){} + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + LocalHistogramIFFactory(const Self& ); //purposely not implemented + void operator=(const Self& ); //purposely not implemented + +}; + +} // End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbLocalHistogramIFFactory.txx" +#endif + +#endif diff --git a/Code/ObjectDetection/otbLocalHistogramIFFactory.txx b/Code/ObjectDetection/otbLocalHistogramIFFactory.txx new file mode 100644 index 0000000000000000000000000000000000000000..c48c0634f437223ee71c70da346da1e0616ff204 --- /dev/null +++ b/Code/ObjectDetection/otbLocalHistogramIFFactory.txx @@ -0,0 +1,61 @@ +/*========================================================================= + + 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 __otbLocalHistogramIFFactory_txx +#define __otbLocalHistogramIFFactory_txx + +#include "otbLocalHistogramIFFactory.h" +#include "otbStreamingMinMaxImageFilter.h" + + +namespace otb +{ +template <class TImageType, class TCoordRep, class TPrecision> +void +LocalHistogramIFFactory<TImageType, TCoordRep, TPrecision> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +template <class TImageType, class TCoordRep, class TPrecision> +void +LocalHistogramIFFactory<TImageType, TCoordRep, TPrecision> +::Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container) +{ + typename AdaptedLocalHistogramIF::Pointer function = AdaptedLocalHistogramIF::New(); + + typedef otb::StreamingMinMaxImageFilter<InputImageType> MinMaxFilterType; + typename MinMaxFilterType::Pointer filter = MinMaxFilterType::New(); + filter->SetInput(image); + filter->Update(); + + function->SetInputImage(image); + function->GetInternalImageFunction()->SetNeighborhoodRadius(param[0]); + function->GetInternalImageFunction()->SetNumberOfHistogramBins(param[1]); + function->GetInternalImageFunction()->SetHistogramMin(filter->GetMinimum()); + function->GetInternalImageFunction()->SetHistogramMax(filter->GetMaximum()); + + metaIF->AddFunction(function); + container->push_back(image); +} + +}//end namespace +#endif diff --git a/Code/ObjectDetection/otbMultiChannelIFFactory.h b/Code/ObjectDetection/otbMultiChannelIFFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..b3fcfe44adbcc799778847bed6d14624039770fe --- /dev/null +++ b/Code/ObjectDetection/otbMultiChannelIFFactory.h @@ -0,0 +1,131 @@ +/*========================================================================= + + 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 __otbMultiChannelIFFactory_h +#define __otbMultiChannelIFFactory_h + +#include "otbVectorImageToImageListFilter.h" +#include "otbVectorImage.h" +#include "otbImage.h" +#include "otbImageList.h" +#include "itkDataObject.h" +#include "otbMetaImageFunction.h" + + +namespace otb +{ +/** \class MultiChannelIFFactory + * \brief Yhis class handle the image type before the use of an + * image function factory + * + * According to the image type, the Create method of this class can + * call an ImageFunctionFactory for each band of the input image or + * once if the image type is otb::Image. + * + */ + +template <class TIFFactory, class TInputImage> +class MultiChannelIFFactory +{ +public: + typedef TIFFactory IFFactoryType; + typedef TInputImage InputImageType; + typedef typename IFFactoryType::Pointer IFFactoryPointerType; + typedef typename IFFactoryType::InputImageType ImageType; + typedef typename IFFactoryType::CoordRepType CoordRepType; + typedef typename IFFactoryType::PrecisionType PrecisionType; + typedef typename std::vector<PrecisionType> ParameterContainerType; + typedef typename std::vector<itk::DataObject::Pointer> ImageContainer; + typedef typename MetaImageFunction<PrecisionType>::Pointer MetaIFPointerType; + + typedef ImageList<ImageType> ImageListType; + typedef VectorImageToImageListFilter<InputImageType, + ImageListType> VIToILFilterType; + + void Create(InputImageType * image, + ParameterContainerType param, + MetaIFPointerType metaIF, + ImageContainer * container) + { + m_Factory->Create(image, param, metaIF, container); + } + + MultiChannelIFFactory() + { + m_Factory = IFFactoryType::New(); + } + + virtual ~MultiChannelIFFactory(){}; + +private: + IFFactoryPointerType m_Factory; + +}; + + +template <class TIFFactory, typename TPixel, unsigned int VImageDimension> +class MultiChannelIFFactory<TIFFactory, otb::VectorImage<TPixel,VImageDimension> > +{ +public: + typedef TIFFactory IFFactoryType; + typedef typename IFFactoryType::Pointer IFFactoryPointerType; + typedef typename IFFactoryType::InputImageType ImageType; + typedef typename IFFactoryType::CoordRepType CoordRepType; + typedef typename IFFactoryType::PrecisionType PrecisionType; + typedef VectorImage<TPixel, 2> InputImageType; + + typedef typename std::vector<PrecisionType> ParameterContainerType; + typedef typename std::vector<itk::DataObject::Pointer> ImageContainer; + typedef typename MetaImageFunction<PrecisionType>::Pointer MetaIFPointerType; + + typedef ImageList<ImageType> ImageListType; + typedef VectorImageToImageListFilter<InputImageType, + ImageListType> VIToILFilterType; + + void Create(InputImageType * image, + ParameterContainerType param, + MetaIFPointerType metaIF, + ImageContainer * container) + { + unsigned int nbBand; + typename VIToILFilterType::Pointer filter = VIToILFilterType::New(); + + filter->SetInput(image); + filter->UpdateOutputInformation(); + nbBand = filter->GetOutput()->Size(); + + for (unsigned int i=0; i<nbBand; i++) + { + filter->GetOutput()->GetNthElement(i)->UpdateOutputInformation(); + m_Factory->Create(filter->GetOutput()->GetNthElement(i), param, metaIF, container); + } + } + + MultiChannelIFFactory() + { + m_Factory = IFFactoryType::New(); + } + + virtual ~MultiChannelIFFactory(){}; + +private: + IFFactoryPointerType m_Factory; + +}; +} //end namespace + +#endif diff --git a/Code/ObjectDetection/otbRadiometricMomentsIFFactory.h b/Code/ObjectDetection/otbRadiometricMomentsIFFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..a449e1ee3b4d1783443fac164769582e8cee11a1 --- /dev/null +++ b/Code/ObjectDetection/otbRadiometricMomentsIFFactory.h @@ -0,0 +1,94 @@ +/*========================================================================= + + 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 __otbRadiometricMomentsIFFactory_h +#define __otbRadiometricMomentsIFFactory_h + +#include "itkLightObject.h" + +#include "otbMetaImageFunction.h" +#include "itkDataObject.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" +#include "otbImageFunctionAdaptor.h" +#include "otbRadiometricMomentsImageFunction.h" + + +namespace otb +{ +/** \class RadiometricMomentsIFFactory + * \brief add a RadiometricMoments image function to a + * MetaImageFunction + * + * This class aims at adding an adapted + * RadiometricMomentsImageFunction to an existing MetaImageFunction + * through the method Create. + * + */ + +template <class TImageType, class TCoordRep = double, class TPrecision = double> +class ITK_EXPORT RadiometricMomentsIFFactory : + public itk::LightObject +{ +public: + /** Standard class typedefs. */ + typedef RadiometricMomentsIFFactory Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + // New macro + itkNewMacro(Self); + + // RTTI typeinfo + itkTypeMacro(RadiometricMomentsIFFactory,itk::LightObject); + + // Input and output typedef + typedef TImageType InputImageType; + typedef TCoordRep CoordRepType; + typedef TPrecision PrecisionType; + + // Other typedef + typedef typename MetaImageFunction<TPrecision>::Pointer MetaImageFunctionPointerType; + typedef typename std::vector<itk::DataObject::Pointer> DataObjectContainerType; + typedef typename std::vector<PrecisionType> ParamContainerType; + typedef RadiometricMomentsImageFunction<InputImageType, CoordRepType> + RadiometricMomentsIF; + typedef ImageFunctionAdaptor<RadiometricMomentsIF> AdaptedRadiometricMomentsIF; + + void Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container); + +protected: + RadiometricMomentsIFFactory(){} + ~RadiometricMomentsIFFactory(){} + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + RadiometricMomentsIFFactory(const Self& ); //purposely not implemented + void operator=(const Self& ); //purposely not implemented + +}; + +} // End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbRadiometricMomentsIFFactory.txx" +#endif + +#endif diff --git a/Code/ObjectDetection/otbRadiometricMomentsIFFactory.txx b/Code/ObjectDetection/otbRadiometricMomentsIFFactory.txx new file mode 100644 index 0000000000000000000000000000000000000000..65638b841c5113736d5bf02111003449b6451ae4 --- /dev/null +++ b/Code/ObjectDetection/otbRadiometricMomentsIFFactory.txx @@ -0,0 +1,52 @@ +/*========================================================================= + + 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 __otbRadiometricMomentsIFFactory_txx +#define __otbRadiometricMomentsIFFactory_txx + +#include "otbRadiometricMomentsIFFactory.h" + + +namespace otb +{ +template <class TImageType, class TCoordRep, class TPrecision> +void +RadiometricMomentsIFFactory<TImageType, TCoordRep, TPrecision> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +template <class TImageType, class TCoordRep, class TPrecision> +void +RadiometricMomentsIFFactory<TImageType, TCoordRep, TPrecision> +::Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container) +{ + typename AdaptedRadiometricMomentsIF::Pointer function = AdaptedRadiometricMomentsIF::New(); + + function->SetInputImage(image); + function->GetInternalImageFunction()->SetNeighborhoodRadius(param[0]); + + metaIF->AddFunction(function); + container->push_back(image); +} + +}//end namespace +#endif diff --git a/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.h b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.h new file mode 100644 index 0000000000000000000000000000000000000000..71de3d4d77b56edefdcc61d78fc894be14a3d10c --- /dev/null +++ b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.h @@ -0,0 +1,175 @@ +/*========================================================================= + + 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 __otbStandardMetaImageFunctionBuilder_h +#define __otbStandardMetaImageFunctionBuilder_h + +#include "itkLightObject.h" + +#include "otbMetaImageFunction.h" +#include "itkDataObject.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" + +#include "otbMultiChannelIFFactory.h" + +#include "otbLocalHistogramIFFactory.h" +#include "otbFlusserMomentsIFFactory.h" +#include "otbRadiometricMomentsIFFactory.h" +#include "otbFourierMellinDescriptorsIFFactory.h" + + +namespace otb +{ +/** \class StandardMetaImageFunctionBuilder + * \brief Build a Standard MetaImageFunction + * + * The StandardMetaImageFunctionBuilder class allows to call multiple + * ImageFunctions: + * - otbRadiometricMomentsImageFunction + * - otbFlusserMomentsImageFunction + * - otbFourierMellinDescriptorsImageFunction + * - otbLocalHistogramImageFunction + * On Multiple Images (and VectorImages Processed as ImageList). + * + * Each ImageFunction can be parametrized. The only thing to do to + * complete the MetaImageFunction is to AddImages. + * + * + * + */ + +template <class TPrecision = double, class TCoordRep = double> +class ITK_EXPORT StandardMetaImageFunctionBuilder : + public itk::LightObject +{ +public: + /** Standard class typedefs. */ + typedef StandardMetaImageFunctionBuilder Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + // New macro + itkNewMacro(Self); + + // RTTI typeinfo + itkTypeMacro(StandardMetaImageFunctionBuilder,itk::LightObject); + + // Input and output typedef + typedef TPrecision ValueType; + typedef TCoordRep CoordRepType; + + // Other typedef + typedef MetaImageFunction<TPrecision> MetaImageFunctionType; + typedef typename MetaImageFunctionType::Pointer MetaImageFunctionPointerType; + typedef typename std::vector<itk::DataObject::Pointer> DataObjectContainerType; + typedef typename std::vector<ValueType> ParamContainerType; + + //Accessors + unsigned int GetNeighborhoodRadius(); + void SetNeighborhoodRadius(unsigned int radius); + + ParamContainerType GetFlusserMomentsIFParameters(); + void SetFlusserMomentsIFParameters(ParamContainerType Param); + + ParamContainerType GetLocalHistogramIFParameters(); + void SetLocalHistogramIFParameters(ParamContainerType Param); + + ParamContainerType GetRadiometricMomentsIFParameters(); + void SetRadiometricMomentsIFParameters(ParamContainerType Param); + + ParamContainerType GetFourierMellinDescriptorsIFParameters(); + void SetFourierMellinDescriptorsIFParameters(ParamContainerType Param); + + MetaImageFunctionPointerType GetMetaImageFunction(); + DataObjectContainerType GetDataObjectContainer(); + + // Adding Image + template <class TInputImage> + void AddImage(TInputImage * image) + { + typedef Image<ValueType, 2> ImageType; + typedef TInputImage InputImageType; + + //Mono-Channel Factories + typedef LocalHistogramIFFactory<ImageType, + CoordRepType, TPrecision> LocalHistogramIFFactoryType; + typedef FlusserMomentsIFFactory<ImageType, + CoordRepType, TPrecision> FlusserMomentsIFFactoryType; + typedef RadiometricMomentsIFFactory<ImageType, + CoordRepType, TPrecision> RadiometricMomentsIFFactoryType; + typedef FourierMellinDescriptorsIFFactory<ImageType, + CoordRepType, TPrecision> FourierMellinDescriptorsIFFactoryType; + + //Multi-Channel Factories + typedef MultiChannelIFFactory<LocalHistogramIFFactoryType, InputImageType> + MCLocalHistogramIFFactoryType; + typedef MultiChannelIFFactory<FlusserMomentsIFFactoryType, InputImageType> + MCFlusserMomentsIFFactoryType; + typedef MultiChannelIFFactory<RadiometricMomentsIFFactoryType, InputImageType> + MCRadiometricMomentsIFFactoryType; + typedef MultiChannelIFFactory<FourierMellinDescriptorsIFFactoryType, InputImageType> + MCFourierMellinDescriptorsIFFactoryType; + + MCLocalHistogramIFFactoryType MCLocalHistogramIFFactory;// = MCLocalHistogramIFFactoryType::New(); + MCFlusserMomentsIFFactoryType MCFlusserMomentsIFFactory;// = MCFlusserMomentsIFFactoryType::New(); + MCRadiometricMomentsIFFactoryType MCRadiometricMomentsIFFactory;// = MCRadiometricMomentsIFFactoryType::New(); + MCFourierMellinDescriptorsIFFactoryType MCFourierMellinDescriptorsIFFactory;// = MCFourierMellinDescriptorsIFFactoryType::New(); + + MCLocalHistogramIFFactory.Create(image, + m_LocalHistogramParam, + m_MetaImageFunction, + &m_DataObjectContainer); + MCFlusserMomentsIFFactory.Create(image, + this->GetFlusserMomentsIFParameters(), + m_MetaImageFunction, + &m_DataObjectContainer); + MCRadiometricMomentsIFFactory.Create(image, + m_RadiometricMomentsParam, + m_MetaImageFunction, + &m_DataObjectContainer); + MCFourierMellinDescriptorsIFFactory.Create(image, + m_FourierMellinDescriptorsParam, + m_MetaImageFunction, + &m_DataObjectContainer); + } + +protected: + StandardMetaImageFunctionBuilder(); + ~StandardMetaImageFunctionBuilder(); + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + StandardMetaImageFunctionBuilder(const Self& ); //purposely not implemented + void operator=(const Self& ); //purposely not implemented + + MetaImageFunctionPointerType m_MetaImageFunction; + DataObjectContainerType m_DataObjectContainer; + unsigned int m_NeighborhoodRadius; + ParamContainerType m_FlusserMomentsParam; //[NeighborhoodRadius] + ParamContainerType m_RadiometricMomentsParam; //[NeighborhoodRadius] + ParamContainerType m_LocalHistogramParam; //[NeighborhoodRadius; nbBins] + ParamContainerType m_FourierMellinDescriptorsParam; //[NeighborhoodRadius; PMax; QMax] +}; + +} // End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbStandardMetaImageFunctionBuilder.txx" +#endif + +#endif diff --git a/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.txx b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.txx new file mode 100644 index 0000000000000000000000000000000000000000..301836480624622c2ea4e09b0eb78c2672b3b58a --- /dev/null +++ b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.txx @@ -0,0 +1,182 @@ +/*========================================================================= + + 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 __otbStandardMetaImageFunctionBuilder_txx +#define __otbStandardMetaImageFunctionBuilder_txx + +#include "otbStandardMetaImageFunctionBuilder.h" + + +namespace otb +{ +template <class TPrecision, class TCoordRep> +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::StandardMetaImageFunctionBuilder() +{ + m_NeighborhoodRadius = 4; + + m_MetaImageFunction = MetaImageFunctionType::New(); + + m_FlusserMomentsParam.push_back(static_cast<ValueType>(this->GetNeighborhoodRadius())); + + m_RadiometricMomentsParam.push_back(static_cast<ValueType>(this->GetNeighborhoodRadius())); + + m_LocalHistogramParam.push_back(static_cast<ValueType>(this->GetNeighborhoodRadius())); + m_LocalHistogramParam.push_back(64); + + m_FourierMellinDescriptorsParam.push_back(static_cast<ValueType>(this->GetNeighborhoodRadius())); + m_FourierMellinDescriptorsParam.push_back(3); + m_FourierMellinDescriptorsParam.push_back(3); +} + +template <class TPrecision, class TCoordRep> +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::~StandardMetaImageFunctionBuilder() +{ + +} + +template <class TPrecision, class TCoordRep> +void +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +template <class TPrecision, class TCoordRep> +unsigned int +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetNeighborhoodRadius() +{ + return m_NeighborhoodRadius; +} + +template <class TPrecision, class TCoordRep> +void +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::SetNeighborhoodRadius(unsigned int radius) +{ + if (radius>0) + { + m_NeighborhoodRadius = radius; + + m_FlusserMomentsParam[0] = static_cast<ValueType>(radius); + m_RadiometricMomentsParam[0] = static_cast<ValueType>(radius); + m_LocalHistogramParam[0] = static_cast<ValueType>(radius); + m_FourierMellinDescriptorsParam[0] = static_cast<ValueType>(radius); + } +} + +template <class TPrecision, class TCoordRep> +typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::ParamContainerType +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetFlusserMomentsIFParameters() +{ + return m_FlusserMomentsParam; +} + +template <class TPrecision, class TCoordRep> +void +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::SetFlusserMomentsIFParameters(ParamContainerType Param) +{ + if (Param.size()==1) + { + m_FlusserMomentsParam[0] = Param[0]; + } +} + + +template <class TPrecision, class TCoordRep> +typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::ParamContainerType +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetLocalHistogramIFParameters() +{ + return m_LocalHistogramParam; +} + +template <class TPrecision, class TCoordRep> +void +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::SetLocalHistogramIFParameters(ParamContainerType Param) +{ + if (Param.size()==2) + { + m_LocalHistogramParam[0] = Param[0]; + m_LocalHistogramParam[1] = Param[1]; + } +} + +template <class TPrecision, class TCoordRep> +typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::ParamContainerType +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetRadiometricMomentsIFParameters() +{ + return m_RadiometricMomentsParam; +} + +template <class TPrecision, class TCoordRep> +void +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::SetRadiometricMomentsIFParameters(ParamContainerType Param) +{ + if (Param.size()==1) + { + m_RadiometricMomentsParam[0] = Param[0]; + } +} + +template <class TPrecision, class TCoordRep> +typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::ParamContainerType +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetFourierMellinDescriptorsIFParameters() +{ + return m_FourierMellinDescriptorsParam; +} + +template <class TPrecision, class TCoordRep> +void +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::SetFourierMellinDescriptorsIFParameters(ParamContainerType Param) +{ + if (Param.size()==3) + { + m_FourierMellinDescriptorsParam[0] = Param[0]; + m_FourierMellinDescriptorsParam[1] = Param[1]; + m_FourierMellinDescriptorsParam[2] = Param[2]; + } +} + +template <class TPrecision, class TCoordRep> +typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::MetaImageFunctionPointerType +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetMetaImageFunction() +{ + return m_MetaImageFunction; +} + +template <class TPrecision, class TCoordRep> +typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::DataObjectContainerType +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetDataObjectContainer() +{ + return m_DataObjectContainer; +} + +}//end namespace +#endif diff --git a/Testing/Code/ObjectDetection/CMakeLists.txt b/Testing/Code/ObjectDetection/CMakeLists.txt index a675fa41ff2a57e0d803ca440c097a6a7f002a79..4ab5028ad9d6703959b753d964493c31c31d8e41 100644 --- a/Testing/Code/ObjectDetection/CMakeLists.txt +++ b/Testing/Code/ObjectDetection/CMakeLists.txt @@ -94,12 +94,22 @@ ADD_TEST(odTvObjectDetectionClassifier ${OBJECTDETECTION_TESTS1} 5 # neighborhood radius ) +ADD_TEST(odTuStandardMetaImageFunctionBuilderNew ${OBJECTDETECTION_TESTS1} + otbStandardMetaImageFunctionBuilderNew + ) + +ADD_TEST(odTvStandardMetaImageFunctionBuilder ${OBJECTDETECTION_TESTS1} + otbStandardMetaImageFunctionBuilder + ${INPUTDATA}/ObjectReco/Boats/maur_B010202_01.tif + ) + # A enrichir SET(ObjectDetection_SRCS1 otbObjectDetectionTests1.cxx otbLabeledSampleLocalizationGenerator.cxx otbDescriptorsListSampleGenerator.cxx otbObjectDetectionClassifier.cxx +otbStandardMetaImageFunctionBuilder.cxx ) diff --git a/Testing/Code/ObjectDetection/otbObjectDetectionTests1.cxx b/Testing/Code/ObjectDetection/otbObjectDetectionTests1.cxx index 9547bc80bd579378174eee03473f78174cc408b7..79c022377dce9fee1a5de5cd1d21fe9785b5b6cc 100644 --- a/Testing/Code/ObjectDetection/otbObjectDetectionTests1.cxx +++ b/Testing/Code/ObjectDetection/otbObjectDetectionTests1.cxx @@ -35,4 +35,6 @@ void RegisterTests() REGISTER_TEST(otbObjectDetectionClassifier); REGISTER_TEST(otbObjectDetectionClassifierNew); REGISTER_TEST(otbObjectDetectionClassifier); + REGISTER_TEST(otbStandardMetaImageFunctionBuilderNew); + REGISTER_TEST(otbStandardMetaImageFunctionBuilder); } diff --git a/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx b/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6a8c9ac61e47e60e7b5a71406576a2474427ecc5 --- /dev/null +++ b/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx @@ -0,0 +1,136 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbStandardMetaImageFunctionBuilder.h" +#include "otbImage.h" +#include "otbVectorImage.h" +#include "otbImageFileReader.h" + +#include "otbImageFunctionAdaptor.h" +#include "otbFlusserMomentsImageFunction.h" +#include "otbRadiometricMomentsImageFunction.h" +#include "otbFourierMellinDescriptorsImageFunction.h" +#include "otbLocalHistogramImageFunction.h" + + +int otbStandardMetaImageFunctionBuilderNew(int argc, char* argv[]) +{ + typedef double PrecisionType; + typedef otb::StandardMetaImageFunctionBuilder<PrecisionType> BuilderType; + + // instantiation + BuilderType::Pointer builder = BuilderType::New(); + + std::cout << builder << std::endl; + + return EXIT_SUCCESS; +} + +int otbStandardMetaImageFunctionBuilder(int argc, char* argv[]) +{ + const char * inputFilename = argv[1]; + + unsigned int nbFunction; + std::vector<double> p1, p2, p3, p4; + + typedef double PrecisionType; + typedef double CoordRepType; + typedef otb::StandardMetaImageFunctionBuilder<PrecisionType, + CoordRepType> BuilderType; + + typedef otb::Image<PrecisionType, 2> ImageType; + typedef otb::VectorImage<PrecisionType, 2> VectorImageType; + typedef otb::ImageFileReader<ImageType> ImageReaderType; + typedef otb::ImageFileReader<VectorImageType> VectorImageReaderType; + + typedef BuilderType::MetaImageFunctionType MetaImageFunctionType; + typedef BuilderType::DataObjectContainerType DataObjectContainerType; + + typedef otb::FlusserMomentsImageFunction<ImageType, CoordRepType> FlusserMomentsIF; + typedef otb::ImageFunctionAdaptor<FlusserMomentsIF> AdaptedFlusserMomentsIF; + + typedef otb::RadiometricMomentsImageFunction<ImageType, CoordRepType> RadiometricMomentsIF; + typedef otb::ImageFunctionAdaptor<RadiometricMomentsIF> AdaptedRadiometricMomentsIF; + + typedef otb::FourierMellinDescriptorsImageFunction<ImageType, CoordRepType> FourierMellinDescriptorsIF; + typedef otb::ImageFunctionAdaptor<FourierMellinDescriptorsIF> AdaptedFourierMellinDescriptorsIF; + + typedef otb::FlusserMomentsImageFunction<ImageType, CoordRepType> LocalHistogramIF; + typedef otb::ImageFunctionAdaptor<LocalHistogramIF> AdaptedLocalHistogramIF; + + p1.push_back(7); + p1.push_back(128); + + p2.push_back(6); + + p3.push_back(5); + + p4.push_back(9); + p4.push_back(5); + p4.push_back(5); + + // instantiation + ImageReaderType::Pointer Ireader = ImageReaderType::New(); + VectorImageReaderType::Pointer VIreader = VectorImageReaderType::New(); + + BuilderType::Pointer builder = BuilderType::New(); + + Ireader->SetFileName(inputFilename); + VIreader->SetFileName(inputFilename); + + builder->AddImage(Ireader->GetOutput()); + builder->SetNeighborhoodRadius(8); + + builder->SetLocalHistogramIFParameters(p1); + builder->SetFlusserMomentsIFParameters(p2); + builder->SetRadiometricMomentsIFParameters(p3); + builder->SetFourierMellinDescriptorsIFParameters(p4); + + builder->AddImage(VIreader->GetOutput()); + + MetaImageFunctionType::Pointer MIF = builder->GetMetaImageFunction(); + std::cout << MIF << std::endl; + + DataObjectContainerType DOC = builder->GetDataObjectContainer(); + std::cout << "DataObjectContainer.size(): " << DOC.size() << std::endl; + + std::cout << static_cast<AdaptedLocalHistogramIF *>(MIF->GetNthFunction(0))->GetInternalImageFunction() + << std::endl; + std::cout << static_cast<AdaptedLocalHistogramIF *>(MIF->GetNthFunction(4))->GetInternalImageFunction() + << std::endl; + + std::cout << static_cast<AdaptedFlusserMomentsIF *>(MIF->GetNthFunction(1))->GetInternalImageFunction() + << std::endl; + std::cout << static_cast<AdaptedFlusserMomentsIF *>(MIF->GetNthFunction(8))->GetInternalImageFunction() + << std::endl; + + std::cout << static_cast<AdaptedRadiometricMomentsIF *>(MIF->GetNthFunction(2))->GetInternalImageFunction() + << std::endl; + std::cout << static_cast<AdaptedRadiometricMomentsIF *>(MIF->GetNthFunction(12))->GetInternalImageFunction() + << std::endl; + + std::cout << static_cast<AdaptedFourierMellinDescriptorsIF *>(MIF->GetNthFunction(3))->GetInternalImageFunction() + << std::endl; + std::cout << static_cast<AdaptedFourierMellinDescriptorsIF *>(MIF->GetNthFunction(16))->GetInternalImageFunction() + << std::endl; + + return EXIT_SUCCESS; +}