diff --git a/Code/FeatureExtraction/otbHaralickTexturesImageFunction.txx b/Code/FeatureExtraction/otbHaralickTexturesImageFunction.txx index 54d5a05f3c3c3fa67d301da0febc2d85787ae792..7c2d2f8de33834e6c2118905cf3c559136a356b0 100644 --- a/Code/FeatureExtraction/otbHaralickTexturesImageFunction.txx +++ b/Code/FeatureExtraction/otbHaralickTexturesImageFunction.txx @@ -47,6 +47,10 @@ HaralickTexturesImageFunction<TInputImage, TCoordRep> { this->Superclass::PrintSelf(os, indent); os << indent << " Neighborhood radius value : " << m_NeighborhoodRadius << std::endl; + os << indent << " Input image minimum value : " << m_InputImageMinimum << std::endl; + os << indent << " Input Image maximum value : " << m_InputImageMaximum << std::endl; + os << indent << " Number of bins per axis : " << m_NumberOfBinsPerAxis << std::endl; + os << indent << " Offset : " << m_Offset << std::endl; } template <class TInputImage, class TCoordRep> diff --git a/Code/ObjectDetection/otbHaralickTexturesIFFactory.h b/Code/ObjectDetection/otbHaralickTexturesIFFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..4d9ac2cdca4117ccb12e369f7e21a2ccfba6507e --- /dev/null +++ b/Code/ObjectDetection/otbHaralickTexturesIFFactory.h @@ -0,0 +1,95 @@ +/*========================================================================= + + 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 __otbHaralickTexturesIFFactory_h +#define __otbHaralickTexturesIFFactory_h + +#include "itkLightObject.h" + +#include "otbMetaImageFunction.h" +#include "itkDataObject.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" +#include "otbImageFunctionAdaptor.h" +#include "otbHaralickTexturesImageFunction.h" + + +namespace otb +{ +/** \class HaralickTexturesFFactory + * \brief add a HaralickTextures image function to a + * MetaImageFunction + * + * This class aims at adding an adapted + * HaralickTexturesImageFunction to an existing + * MetaImageFunction through the method Create. + * + */ + +template <class TImageType, class TCoordRep = double, class TPrecision = double> +class ITK_EXPORT HaralickTexturesIFFactory : + public itk::LightObject +{ +public: + /** Standard class typedefs. */ + typedef HaralickTexturesIFFactory Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + // New macro + itkNewMacro(Self); + + // RTTI typeinfo + itkTypeMacro(haralickTexturesIFFactory,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 HaralickTexturesImageFunction<InputImageType, CoordRepType> + HaralickTexturesIF; + typedef typename HaralickTexturesIF::OffsetType OffsetType; + typedef ImageFunctionAdaptor<HaralickTexturesIF> AdaptedHaralickTexturesIF; + + void Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container); + +protected: + HaralickTexturesIFFactory(){} + ~HaralickTexturesIFFactory(){} + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + HaralickTexturesIFFactory(const Self& ); //purposely not implemented + void operator=(const Self& ); //purposely not implemented + +}; + +} // End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbHaralickTexturesIFFactory.txx" +#endif + +#endif diff --git a/Code/ObjectDetection/otbHaralickTexturesIFFactory.txx b/Code/ObjectDetection/otbHaralickTexturesIFFactory.txx new file mode 100644 index 0000000000000000000000000000000000000000..0ac9b110da2da4af64ab13482d8548a583760dac --- /dev/null +++ b/Code/ObjectDetection/otbHaralickTexturesIFFactory.txx @@ -0,0 +1,59 @@ +/*========================================================================= + + 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 __otbHaralickTexturesIFFactory_txx +#define __otbHaralickTexturesIFFactory_txx + +#include "otbHaralickTexturesIFFactory.h" + + +namespace otb +{ +template <class TImageType, class TCoordRep, class TPrecision> +void +HaralickTexturesIFFactory<TImageType, TCoordRep, TPrecision> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +template <class TImageType, class TCoordRep, class TPrecision> +void +HaralickTexturesIFFactory<TImageType, TCoordRep, TPrecision> +::Create(InputImageType * image, + ParamContainerType param, + MetaImageFunctionPointerType metaIF, + DataObjectContainerType * container) +{ + typename AdaptedHaralickTexturesIF::Pointer function = AdaptedHaralickTexturesIF::New(); + + function->SetInputImage(image); + function->GetInternalImageFunction()->SetNeighborhoodRadius(param[0]); + function->GetInternalImageFunction()->SetInputImageMinimum(param[1]); + function->GetInternalImageFunction()->SetInputImageMaximum(param[2]); + function->GetInternalImageFunction()->SetNumberOfBinsPerAxis(param[3]); + + OffsetType offset; + offset.Fill(param[4]); + function->GetInternalImageFunction()->SetOffset(offset); + + metaIF->AddFunction(function); + container->push_back(image); +} + +}//end namespace +#endif diff --git a/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.h b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.h index fde984ae8d9d1129582a9b09e1f66c50f3b6f853..e37eac3b9c525f309de4ac6fea93ec75a91e4dc0 100644 --- a/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.h +++ b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.h @@ -31,6 +31,7 @@ #include "otbFlusserMomentsIFFactory.h" #include "otbRadiometricMomentsIFFactory.h" #include "otbFourierMellinDescriptorsIFFactory.h" +#include "otbHaralickTexturesIFFactory.h" namespace otb @@ -95,6 +96,9 @@ public: ParamContainerType GetFourierMellinDescriptorsIFParameters(); void SetFourierMellinDescriptorsIFParameters(ParamContainerType Param); + + ParamContainerType GetHaralickTexturesIFParameters(); + void SetHaralickTexturesIFParameters(ParamContainerType Param); MetaImageFunctionPointerType GetMetaImageFunction(); DataObjectContainerType GetDataObjectContainer(); @@ -115,6 +119,8 @@ public: CoordRepType, TPrecision> RadiometricMomentsIFFactoryType; typedef FourierMellinDescriptorsIFFactory<ImageType, CoordRepType, TPrecision> FourierMellinDescriptorsIFFactoryType; + typedef HaralickTexturesIFFactory<ImageType, + CoordRepType, TPrecision> HaralickTexturesIFFactoryType; //Multi-Channel Factories typedef MultiChannelIFFactory<LocalHistogramIFFactoryType, InputImageType> @@ -125,11 +131,14 @@ public: MCRadiometricMomentsIFFactoryType; typedef MultiChannelIFFactory<FourierMellinDescriptorsIFFactoryType, InputImageType> MCFourierMellinDescriptorsIFFactoryType; + typedef MultiChannelIFFactory<HaralickTexturesIFFactoryType, InputImageType> + MCHaralickTexturesIFFactoryType; - MCLocalHistogramIFFactoryType MCLocalHistogramIFFactory;// = MCLocalHistogramIFFactoryType::New(); - MCFlusserMomentsIFFactoryType MCFlusserMomentsIFFactory;// = MCFlusserMomentsIFFactoryType::New(); - MCRadiometricMomentsIFFactoryType MCRadiometricMomentsIFFactory;// = MCRadiometricMomentsIFFactoryType::New(); - MCFourierMellinDescriptorsIFFactoryType MCFourierMellinDescriptorsIFFactory;// = MCFourierMellinDescriptorsIFFactoryType::New(); + MCLocalHistogramIFFactoryType MCLocalHistogramIFFactory; + MCFlusserMomentsIFFactoryType MCFlusserMomentsIFFactory; + MCRadiometricMomentsIFFactoryType MCRadiometricMomentsIFFactory; + MCFourierMellinDescriptorsIFFactoryType MCFourierMellinDescriptorsIFFactory; + MCHaralickTexturesIFFactoryType MCHaralickTexturesIFFactory; MCLocalHistogramIFFactory.Create(image, m_LocalHistogramParam, @@ -147,6 +156,10 @@ public: m_FourierMellinDescriptorsParam, m_MetaImageFunction, &m_DataObjectContainer); + MCHaralickTexturesIFFactory.Create(image, + m_HaralickTexturesParam, + m_MetaImageFunction, + &m_DataObjectContainer); } protected: @@ -165,6 +178,8 @@ private: ParamContainerType m_RadiometricMomentsParam; //[NeighborhoodRadius] ParamContainerType m_LocalHistogramParam; //[NeighborhoodRadius; nbBins; minHistogram; maxHistogram] ParamContainerType m_FourierMellinDescriptorsParam; //[NeighborhoodRadius; PMax; QMax] + ParamContainerType m_HaralickTexturesParam; //[NeighborhoodRadius; ImageMin; ImageMax; NbBinPerAxis; Offset] + }; } // End namespace otb diff --git a/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.txx b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.txx index 2a0f1b9b8a996b58c1277e5dbc6ce670cadf531e..073dced75159989b89bff3c0eae2576b31a46d03 100644 --- a/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.txx +++ b/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.txx @@ -43,6 +43,12 @@ StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> m_FourierMellinDescriptorsParam.push_back(static_cast<ValueType>(this->GetNeighborhoodRadius())); m_FourierMellinDescriptorsParam.push_back(3); m_FourierMellinDescriptorsParam.push_back(3); + + m_HaralickTexturesParam.push_back(static_cast<ValueType>(this->GetNeighborhoodRadius())); + m_HaralickTexturesParam.push_back(0); + m_HaralickTexturesParam.push_back(4096); + m_HaralickTexturesParam.push_back(30); + m_HaralickTexturesParam.push_back(2); } template <class TPrecision, class TCoordRep> @@ -81,6 +87,7 @@ StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> m_RadiometricMomentsParam[0] = static_cast<ValueType>(radius); m_LocalHistogramParam[0] = static_cast<ValueType>(radius); m_FourierMellinDescriptorsParam[0] = static_cast<ValueType>(radius); + m_HaralickTexturesParam[0] = static_cast<ValueType>(radius); } } @@ -166,6 +173,29 @@ StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> } } +template <class TPrecision, class TCoordRep> +typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::ParamContainerType +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::GetHaralickTexturesIFParameters() +{ + return m_HaralickTexturesParam; +} + +template <class TPrecision, class TCoordRep> +void +StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> +::SetHaralickTexturesIFParameters(ParamContainerType Param) +{ + if (Param.size()==5) + { + m_HaralickTexturesParam[0] = Param[0]; + m_HaralickTexturesParam[1] = Param[1]; + m_HaralickTexturesParam[2] = Param[2]; + m_HaralickTexturesParam[3] = Param[3]; + m_HaralickTexturesParam[4] = Param[4]; + } +} + template <class TPrecision, class TCoordRep> typename StandardMetaImageFunctionBuilder<TPrecision, TCoordRep>::MetaImageFunctionPointerType StandardMetaImageFunctionBuilder<TPrecision, TCoordRep> diff --git a/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx b/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx index 6bd7e14e7374712ea73e25dc2bfe06c5dfe1fc7f..d93605f5dfd89d827617a441cc21236b189eed16 100644 --- a/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx +++ b/Testing/Code/ObjectDetection/otbStandardMetaImageFunctionBuilder.cxx @@ -29,6 +29,7 @@ #include "otbRadiometricMomentsImageFunction.h" #include "otbFourierMellinDescriptorsImageFunction.h" #include "otbLocalHistogramImageFunction.h" +#include "otbHaralickTexturesImageFunction.h" int otbStandardMetaImageFunctionBuilderNew(int argc, char* argv[]) @@ -48,7 +49,7 @@ int otbStandardMetaImageFunctionBuilder(int argc, char* argv[]) { const char * inputFilename = argv[1]; - std::vector<double> p1, p2, p3, p4; + std::vector<double> p1, p2, p3, p4, p5; typedef double PrecisionType; typedef double CoordRepType; @@ -75,6 +76,9 @@ int otbStandardMetaImageFunctionBuilder(int argc, char* argv[]) typedef otb::FlusserMomentsImageFunction<ImageType, CoordRepType> LocalHistogramIF; typedef otb::ImageFunctionAdaptor<LocalHistogramIF> AdaptedLocalHistogramIF; + typedef otb::HaralickTexturesImageFunction<ImageType, CoordRepType> HaralickTexturesIF; + typedef otb::ImageFunctionAdaptor<HaralickTexturesIF> AdaptedHaralickTexturesIF; + p1.push_back(7); p1.push_back(128); @@ -86,6 +90,12 @@ int otbStandardMetaImageFunctionBuilder(int argc, char* argv[]) p4.push_back(5); p4.push_back(5); + p5.push_back(10); + p5.push_back(1); + p5.push_back(1500); + p5.push_back(16); + p5.push_back(4); + // instantiation ImageReaderType::Pointer Ireader = ImageReaderType::New(); VectorImageReaderType::Pointer VIreader = VectorImageReaderType::New(); @@ -102,6 +112,7 @@ int otbStandardMetaImageFunctionBuilder(int argc, char* argv[]) builder->SetFlusserMomentsIFParameters(p2); builder->SetRadiometricMomentsIFParameters(p3); builder->SetFourierMellinDescriptorsIFParameters(p4); + builder->SetHaralickTexturesIFParameters(p5); builder->AddImage(VIreader->GetOutput()); @@ -113,22 +124,27 @@ int otbStandardMetaImageFunctionBuilder(int argc, char* argv[]) std::cout << static_cast<AdaptedLocalHistogramIF *>(MIF->GetNthFunction(0))->GetInternalImageFunction() << std::endl; - std::cout << static_cast<AdaptedLocalHistogramIF *>(MIF->GetNthFunction(4))->GetInternalImageFunction() + std::cout << static_cast<AdaptedLocalHistogramIF *>(MIF->GetNthFunction(5))->GetInternalImageFunction() << std::endl; std::cout << static_cast<AdaptedFlusserMomentsIF *>(MIF->GetNthFunction(1))->GetInternalImageFunction() << std::endl; - std::cout << static_cast<AdaptedFlusserMomentsIF *>(MIF->GetNthFunction(8))->GetInternalImageFunction() + std::cout << static_cast<AdaptedFlusserMomentsIF *>(MIF->GetNthFunction(9))->GetInternalImageFunction() << std::endl; std::cout << static_cast<AdaptedRadiometricMomentsIF *>(MIF->GetNthFunction(2))->GetInternalImageFunction() << std::endl; - std::cout << static_cast<AdaptedRadiometricMomentsIF *>(MIF->GetNthFunction(12))->GetInternalImageFunction() + std::cout << static_cast<AdaptedRadiometricMomentsIF *>(MIF->GetNthFunction(13))->GetInternalImageFunction() << std::endl; std::cout << static_cast<AdaptedFourierMellinDescriptorsIF *>(MIF->GetNthFunction(3))->GetInternalImageFunction() << std::endl; - std::cout << static_cast<AdaptedFourierMellinDescriptorsIF *>(MIF->GetNthFunction(16))->GetInternalImageFunction() + std::cout << static_cast<AdaptedFourierMellinDescriptorsIF *>(MIF->GetNthFunction(17))->GetInternalImageFunction() + << std::endl; + + std::cout << static_cast<AdaptedHaralickTexturesIF *>(MIF->GetNthFunction(4))->GetInternalImageFunction() + << std::endl; + std::cout << static_cast<AdaptedHaralickTexturesIF *>(MIF->GetNthFunction(21))->GetInternalImageFunction() << std::endl; return EXIT_SUCCESS;