diff --git a/Code/BasicFilters/otbCountImageFunction.h b/Code/BasicFilters/otbCountImageFunction.h deleted file mode 100644 index b7a7341c41389a78cca79f295172797e6bb5fc15..0000000000000000000000000000000000000000 --- a/Code/BasicFilters/otbCountImageFunction.h +++ /dev/null @@ -1,138 +0,0 @@ -/*========================================================================= - - 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 __otbCountImageFunction_h -#define __otbCountImageFunction_h - -#include "itkImageFunction.h" -#include "itkNumericTraits.h" -#include "itkProcessObject.h" - -namespace otb -{ - -/** - * \class CountImageFunction - * \brief Calculate the density in the neighborhood of a pixel - * - * \ingroup ImageFunctions - */ -template <class TInputImage, class TDetector, class TCount > - class ITK_EXPORT CountImageFunction : - public itk::ImageFunction< TInputImage, typename itk::NumericTraits<typename TInputImage::PixelType>::RealType> -{ -public: - /** Standard class typedefs. */ - typedef CountImageFunction Self; - typedef itk::ImageFunction<TInputImage, typename itk::NumericTraits<typename TInputImage::PixelType>::RealType > - Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Run-time type information (and related methods). */ - itkTypeMacro(CountImageFunction, itk::ImageFunction); - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** InputImageType typedef support. */ - typedef TInputImage InputImageType; - - /** Index typedef support. */ - typedef typename Superclass::IndexType IndexType; - - /** ContinuousIndex typedef support. */ - typedef typename Superclass::ContinuousIndexType ContinuousIndexType; - - /** Point typedef support. */ - typedef typename Superclass::PointType PointType; - - /** Datatype used for the density */ - typedef typename itk::NumericTraits<typename InputImageType::PixelType>::RealType RealType; - - /** Detector typedef support*/ - typedef TDetector DetectorType; - typedef typename DetectorType::Pointer DetectorPointerType; - - /** Count Method type*/ - typedef TCount CountType; - - - /** Dimension of the underlying image. */ - itkStaticConstMacro(ImageDimension, unsigned int, - InputImageType::ImageDimension); - - /** Set the input image (reimplemented since we need to set the detector input) */ - virtual void SetInputImage( const InputImageType * ptr ); - - /** Evalulate the function at specified index */ - virtual RealType EvaluateAtIndex( const IndexType& index ) const; - - /** Evaluate the function at non-integer positions */ - virtual RealType Evaluate( const PointType& point ) const - { - IndexType index; - this->ConvertPointToNearestIndex( point, index ); - return this->EvaluateAtIndex( index ); - } - virtual RealType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex ) const - { - IndexType index; - this->ConvertContinuousIndexToNearestIndex( cindex, index ); - return this->EvaluateAtIndex( index ) ; - } - - /**SetDetector */ - virtual void SetDetector( DetectorType* detector) ; - - /**GetDetector */ - virtual DetectorType * GetDetector() ; - - /** Get/Set the radius of the neighborhood over which the - statistics are evaluated */ - itkSetMacro( NeighborhoodRadius, unsigned int ); - itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int ); - -protected: - CountImageFunction(); - ~CountImageFunction(){}; - - - void PrintSelf(std::ostream& os, itk::Indent indent) const; - - - -private: - CountImageFunction( const Self& ); //purposely not implemented - void operator=( const Self& ); //purposely not implemented - - /** Detector implementation */ - DetectorPointerType m_Detector; - - unsigned int m_NeighborhoodRadius; -}; - -} // end namespace otb - - -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbCountImageFunction.txx" -#endif - -#endif - diff --git a/Code/BasicFilters/otbCountImageFunction.txx b/Code/BasicFilters/otbCountImageFunction.txx deleted file mode 100644 index b790707f7d0e292afbbaefd2b2cd495590f6d89f..0000000000000000000000000000000000000000 --- a/Code/BasicFilters/otbCountImageFunction.txx +++ /dev/null @@ -1,105 +0,0 @@ -/*========================================================================= - - 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 __otbCountImageFunction_txx -#define __otbCountImageFunction_txx - -#include "otbCountImageFunction.h" - -#include "itkProcessObject.h" -#include "itkNumericTraits.h" -#include "itkConstNeighborhoodIterator.h" - -namespace otb -{ - -/** - * Constructor - */ -template <class TInputImage, class TDetector ,class TCount > -CountImageFunction<TInputImage,TDetector , TCount> -::CountImageFunction() -{ - m_NeighborhoodRadius = 1; - m_Detector = DetectorType::New(); -} - - -template <class TInputImage, class TDetector ,class TCount > -void -CountImageFunction< TInputImage, TDetector , TCount > -::SetInputImage(const InputImageType * ptr) -{ - Superclass::SetInputImage(ptr); - m_Detector->SetInput(ptr); -} - -/** - * - */ -template <class TInputImage, class TDetector ,class TCount > -void -CountImageFunction< TInputImage, TDetector , TCount > -::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - this->Superclass::PrintSelf(os,indent); - os << indent << "NeighborhoodRadius: " << m_NeighborhoodRadius << std::endl; -} - - -/** - * - */ -template <class TInputImage, class TDetector ,class TCount > -typename CountImageFunction< TInputImage, TDetector , TCount > -::RealType -CountImageFunction<TInputImage,TDetector , TCount> -::EvaluateAtIndex(const IndexType& index) const -{ - m_Detector->Update(); - CountType countDensity; - return countDensity(m_Detector->GetOutput(),m_NeighborhoodRadius,index ); -} -/** - * SetDetector method - */ -template <class TInputImage, class TDetector ,class TCount > -void -CountImageFunction<TInputImage,TDetector , TCount> -::SetDetector( DetectorType* detector) -{ - m_Detector = detector; - if(this->GetInputImage()) - { - m_Detector->SetInput(this->GetInputImage()); - } -} - -/** - * GetDetector method - */ -template <class TInputImage, class TDetector ,class TCount > -typename CountImageFunction< TInputImage, TDetector , TCount > -::DetectorType * -CountImageFunction<TInputImage,TDetector , TCount> -::GetDetector() -{ - return m_Detector; -} -} // end namespace otb - -#endif diff --git a/Code/BasicFilters/otbPointSetFunction.h b/Code/BasicFilters/otbPointSetFunction.h new file mode 100644 index 0000000000000000000000000000000000000000..6b21dfdae4244693b0edbf6af7b0733a29526d9d --- /dev/null +++ b/Code/BasicFilters/otbPointSetFunction.h @@ -0,0 +1,81 @@ +/*========================================================================= + + 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 __otbPointSetFunction_h +#define __otbPointSetFunction_h + +#include "itkSpatialFunction.h" +#include "itkPoint.h" +#include "itkProcessObject.h" + +namespace otb +{ + +/** + * \class PointSetFunction + * \brief Calculate the density in the neighborhood of a pixel + * + * \ingroup SpatialFunctions + */ +template <class TPointSet, class TOutput> + class ITK_EXPORT PointSetFunction : + public itk::SpatialFunction<TOutput > +{ +public: + /** Standard class typedefs. */ + typedef PointSetFunction Self; + typedef itk::SpatialFunction< TOutput > Superclass; + + /** Run-time type information (and related methods). */ + itkTypeMacro(PointSetFunction, itk::SpatialFunction); + + /** PointSet Type typedef Support*/ + typedef TPointSet PointSetType; + typedef typename PointSetType::Pointer PointSetPointerType; + + /** TOutput typedef suppoty*/ + typedef TOutput OutputType; + + /** Set the input image (reimplemented since we need to set the detector input) */ + virtual void SetPointSet(PointSetType* PointSet); + virtual PointSetType * GetPointSet(); + + +protected: + PointSetFunction(); + ~PointSetFunction(){}; + + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + +private: + PointSetFunction( const Self& ); //purposely not implemented + void operator=( const Self& ); //purposely not implemented + + PointSetPointerType m_PointSet; + +}; + +} // end namespace otb + + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbPointSetFunction.txx" +#endif + +#endif + diff --git a/Code/BasicFilters/otbPointSetFunction.txx b/Code/BasicFilters/otbPointSetFunction.txx new file mode 100644 index 0000000000000000000000000000000000000000..f1a885f85f71e369cdd579fd172035923747f3c6 --- /dev/null +++ b/Code/BasicFilters/otbPointSetFunction.txx @@ -0,0 +1,76 @@ +/*========================================================================= + + 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 __otbPointSetFunction_txx +#define __otbPointSetFunction_txx + +#include "otbPointSetFunction.h" + +#include "itkProcessObject.h" +#include "itkNumericTraits.h" +#include "itkConstNeighborhoodIterator.h" + +namespace otb +{ + +/** + * Constructor + */ +template <class TPointSet, class TOutput > +PointSetFunction< TPointSet, TOutput> +::PointSetFunction() +{ + m_PointSet = PointSetType::New(); +} + +/** + * + */ +template <class TPointSet, class TOutput > +void +PointSetFunction< TPointSet, TOutput> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + this->Superclass::PrintSelf(os,indent); + } + + +/** + * SetDetector method + */ +template <class TPointSet, class TOutput > +void +PointSetFunction< TPointSet, TOutput> +::SetPointSet(PointSetType* PointSet) +{ + m_PointSet = PointSet; +} + +/** + * GetDetector method + */ +template <class TPointSet, class TOutput > +typename PointSetFunction< TPointSet,TOutput> +::PointSetType * +PointSetFunction< TPointSet, TOutput> +::GetPointSet() +{ + return m_PointSet; +} +} // end namespace otb + +#endif diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 4b57269e47d4bd3ecffc736081d55dc4d24be357..1c217cc7f81b539cadf088d9f855421e70a6960e 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1115,34 +1115,35 @@ ADD_TEST(bfTvExtractROIResample2 ${BASICFILTERS_TESTS11} ${TEMP}/bfTvExtractROIResample2.tif 1 ) -# ------- otbCountImageFunction ---------------------------- -ADD_TEST(bfTuCountImageFunctionNew ${BASICFILTERS_TESTS11} - otbCountImageFunctionNew +# ------- otbPointSetFunction ---------------------------- +ADD_TEST(bfTuPointSetFunctionNew ${BASICFILTERS_TESTS11} + otPointSetFunctionNew ) -ADD_TEST(bfTvCountImageFunction ${BASICFILTERS_TESTS11} ---compare-ascii ${TOL} - ${BASELINE_FILES}/bfTvCountImageFunctionOutputAscii.txt - ${TEMP}/bfTvCountImageFunctionOutputAscii.txt - otbCountImageFunctionTest - ${INPUTDATA}/QB_Suburb.png - ${TEMP}/bfTvCountImageFunctionOutputAscii.txt - 5 2 -) +# +#ADD_TEST(bfTvCountImageFunction ${BASICFILTERS_TESTS11} +#--compare-ascii ${TOL} +# ${BASELINE_FILES}/bfTvCountImageFunctionOutputAscii.txt +# ${TEMP}/bfTvCountImageFunctionOutputAscii.txt +# otbCountImageFunctionTest +# ${INPUTDATA}/QB_Suburb.png +# ${TEMP}/bfTvCountImageFunctionOutputAscii.txt +# 5 2 +#) # ------- otbCountImageFilter ---------------------------- -ADD_TEST(bfTuCountImageFilterNew ${BASICFILTERS_TESTS11} - otbCountImageFilterNew - ) - -ADD_TEST(bfTvCountImageFilterOutputImage ${BASICFILTERS_TESTS11} ---compare-image ${TOL} - ${BASELINE_FILES}/bfTvCountImageFilterOutputImage.tif - ${TEMP}/bfTvCountImageFilterOutputImage.tif - otbCountImageFilterTest - ${INPUTDATA}/QB_Suburb.png - ${TEMP}/bfTvCountImageFilterOutputImage.tif - 5 2 -) +#ADD_TEST(bfTuCountImageFilterNew ${BASICFILTERS_TESTS11} +# otbCountImageFilterNew +# ) + +#ADD_TEST(bfTvCountImageFilterOutputImage ${BASICFILTERS_TESTS11} +#--compare-image ${TOL} +# ${BASELINE_FILES}/bfTvCountImageFilterOutputImage.tif +# ${TEMP}/bfTvCountImageFilterOutputImage.tif +# otbCountImageFilterTest +# ${INPUTDATA}/QB_Suburb.png +# ${TEMP}/bfTvCountImageFilterOutputImage.tif +# 5 2 +#) # A enrichir SET(BasicFilters_SRCS1 @@ -1304,10 +1305,10 @@ ENDIF(USE_FFTWD) SET(BasicFilters_SRCS11 otbExtractROIResample.cxx -otbCountImageFunctionNew.cxx -otbCountImageFunctionTest.cxx -otbCountImageFilterNew.cxx -otbCountImageFilterTest.cxx +otbPointSetFunctionNew.cxx +#otbCountImageFunctionTest.cxx +#otbCountImageFilterNew.cxx +#otbCountImageFilterTest.cxx ) diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx index 66c127df73d5cecf781526c49c136c62c43dbd4b..2a21aea6f205c2a0724811c6b0e216bcbd3955e8 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx @@ -28,8 +28,8 @@ void RegisterTests() { REGISTER_TEST(otbExtractROIResample); -REGISTER_TEST(otbCountImageFunctionNew); -REGISTER_TEST(otbCountImageFunctionTest); -REGISTER_TEST(otbCountImageFilterNew); -REGISTER_TEST(otbCountImageFilterTest); +REGISTER_TEST(otbPointSetFunctionNew); +//REGISTER_TEST(otbCountImageFunctionTest); +//REGISTER_TEST(otbCountImageFilterNew); +//REGISTER_TEST(otbCountImageFilterTest); } diff --git a/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx b/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx deleted file mode 100644 index 462646c226f98ee8bf5a7d8fd71503da61fafe85..0000000000000000000000000000000000000000 --- a/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/*========================================================================= - -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 "otbImage.h" -#include "otbImageFileReader.h" - -#include <stdio.h> -#include "otbCountImageFunction.h" -#include "otbSiftFastImageFilter.h" -#include "otbSimplePointCountStrategy.h" -#include "itkPointSet.h" -#include "itkVariableLengthVector.h" - -#include <iostream> - -int otbCountImageFunctionTest(int argc, char* argv[] ) -{ - const char * infname = argv[1]; - const char * outfname = argv[2]; - const unsigned char scales = atoi(argv[3]); - const unsigned char radius = atoi(argv[4]); - const unsigned int Dimension = 2; - typedef float PixelType; - - typedef otb::Image< PixelType, Dimension > ImageType; - typedef ImageType::IndexType IndexType; - - typedef otb::ImageFileReader<ImageType> ReaderType; - - typedef itk::VariableLengthVector<PixelType> RealVectorType; - typedef itk::PointSet<RealVectorType,Dimension> PointSetType; - typedef otb::SiftFastImageFilter<ImageType,PointSetType> DetectorType; - - typedef otb::Count<PointSetType,unsigned int ,IndexType> CounterType; - - typedef otb::CountImageFunction< ImageType,DetectorType, - CounterType> FunctionType; - - - /** Instanciation of the reader */ - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(infname); - reader->Update(); - - ImageType::SizeType size; - size = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); - - /**Instancitation of an object*/ - FunctionType::Pointer filter = FunctionType::New(); - - /** Instanciation of the detector : */ - DetectorType::Pointer detector = filter->GetDetector(); - detector->SetNumberOfScales(scales); - - - filter->SetInputImage(reader->GetOutput()); - filter->SetNeighborhoodRadius(radius); - filter->SetDetector(detector); /*Set the number of scales for the detector**/ - - /** First try*/ - ImageType::IndexType index ; - index[0] = size[0]/2 ; - index[1] = size[1]/4; - - std::ofstream outfile(outfname); - outfile << "At Index: " << index << std::endl; - outfile << "\t density :" << filter->EvaluateAtIndex(index) << std::endl; - - /** Second Try*/ - index[0] = size[0]/4 ; - index[1] = size[1]/4; - - outfile << "At Index: " << index << std::endl; - outfile << "\t density :" << filter->EvaluateAtIndex(index) << std::endl; - - /** Third Try*/ - index[0] = size[0]/2 ; - index[1] = size[1]/2; - - outfile << "At Index: " << index << std::endl; - outfile << "\t density :" << filter->EvaluateAtIndex(index) << std::endl; - - outfile.close(); - - - return EXIT_SUCCESS; -} - diff --git a/Testing/Code/BasicFilters/otbCountImageFunctionNew.cxx b/Testing/Code/BasicFilters/otbPointSetFunctionNew.cxx similarity index 59% rename from Testing/Code/BasicFilters/otbCountImageFunctionNew.cxx rename to Testing/Code/BasicFilters/otbPointSetFunctionNew.cxx index 1edc301a424ffa72f34428d26521b4a762f629c2..d23ee51756d38c84bb32ea596cafdb3968449a64 100644 --- a/Testing/Code/BasicFilters/otbCountImageFunctionNew.cxx +++ b/Testing/Code/BasicFilters/otbPointSetFunctionNew.cxx @@ -18,32 +18,23 @@ PURPOSE. See the above copyright notices for more information. #include <stdio.h> -#include "otbCountImageFunction.h" -#include "otbSiftFastImageFilter.h" -#include "otbSimplePointCountStrategy.h" +#include "otbPointSetFunction.h" #include "itkPointSet.h" #include "itkVariableLengthVector.h" -#include "otbImage.h" -int otbCountImageFunctionNew(int, char* [] ) + +int otbPointSetFunctionNew(int, char* [] ) { const unsigned int Dimension = 2; typedef float PixelType; - typedef otb::Image< PixelType, Dimension > ImageType; - typedef ImageType::IndexType IndexType; typedef itk::VariableLengthVector<PixelType> RealVectorType; typedef itk::PointSet<RealVectorType,Dimension> PointSetType; - typedef otb::SiftFastImageFilter<ImageType,PointSetType> DetectorType; - - typedef otb::Count<PointSetType,unsigned int ,IndexType> CounterType; - - typedef otb::CountImageFunction< ImageType,DetectorType, - CounterType> FunctionType; + typedef otb::PointSetFunction <PointSetType,PixelType> FunctionType; /**Instancitation of an object*/ - FunctionType::Pointer filter = FunctionType::New(); + FunctionType filter(); return EXIT_SUCCESS; }