diff --git a/Code/BasicFilters/otbPointSetDensityFunction.h b/Code/BasicFilters/otbPointSetDensityFunction.h new file mode 100644 index 0000000000000000000000000000000000000000..0e2d78c28b9c4718741a4875b145133583345193 --- /dev/null +++ b/Code/BasicFilters/otbPointSetDensityFunction.h @@ -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. + +=========================================================================*/ +#ifndef __otbPointSetDensityFunction_h +#define __otbPointSetDensityFunction_h + +#include "otbPointSetFunction.h" +#include "itkPoint.h" +#include "itkProcessObject.h" + +namespace otb +{ + +/** + * \class PointSetDensityFunction + * \brief Calculate the density in the neighborhood of a pixel + * + * \ingroup PointSetFunctions + */ +template <class TPointSet, class TOutput> + class ITK_EXPORT PointSetDensityFunction : public PointSetFunction< TPointSet , TOutput > +{ +public: + /** Standard class typedefs. */ + typedef PointSetDensityFunction Self; + typedef PointSetFunction< TPointSet ,TOutput > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + /** Run-time type information (and related methods). */ + itkTypeMacro(PointSetDensityFunction, PointSetFunction); + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** PointSet Type typedef Support*/ + typedef TPointSet PointSetType; + typedef typename Superclass::InputType InputType; + typedef typename PointSetType::Pointer PointSetPointerType; + + /** TOutput typedef suppoty*/ + typedef TOutput OutputType; + + /** Set/Get the number of scales*/ + itkSetMacro(Radius,unsigned int); + itkGetMacro(Radius,unsigned int); + + /** Evaluate Method */ + virtual OutputType Evaluate(const InputType& input ) const; + +protected: + PointSetDensityFunction(); + ~PointSetDensityFunction(){}; + + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + +private: + PointSetDensityFunction( const Self& ); //purposely not implemented + void operator=( const Self& ); //purposely not implemented + + unsigned int m_Radius; +}; + +} // end namespace otb + + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbPointSetDensityFunction.txx" +#endif + +#endif + diff --git a/Code/BasicFilters/otbPointSetDensityFunction.txx b/Code/BasicFilters/otbPointSetDensityFunction.txx new file mode 100644 index 0000000000000000000000000000000000000000..45b01f5a5dc77a0a8078af96154b686715c67f09 --- /dev/null +++ b/Code/BasicFilters/otbPointSetDensityFunction.txx @@ -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 __otbPointSetDensityFunction_txx +#define __otbPointSetDensityFunction_txx + +#include "otbPointSetDensityFunction.h" +#include "otbImage.h" +#include "otbMath.h" + + +namespace otb +{ + +/** + * Constructor + */ +template <class TPointSet, class TOutput > +PointSetDensityFunction< TPointSet, TOutput> +::PointSetDensityFunction() +{ + m_Radius = 1; +} + + +/** + * + */ +template <class TPointSet, class TOutput > +typename PointSetDensityFunction< TPointSet, TOutput> +::OutputType +PointSetDensityFunction< TPointSet, TOutput> +::Evaluate(const InputType& input ) const +{ + + typename otb::Image<OutputType,2>::IndexType index; + index[0] = input[0]; + index[1] = input[1]; + + int accu = 0; + double surface = M_PI*vcl_pow(2.,static_cast<double>(m_Radius)); + + if(this->GetPointSet()->GetNumberOfPoints() != 0) + { + typedef typename TPointSet::PointsContainer::ConstIterator iteratorType; + iteratorType it = this->GetPointSet()->GetPoints()->Begin(); + + while( it != this->GetPointSet()->GetPoints()->End()) + { + float distX2 =( index[0]-it.Value()[0])*( index[0]-it.Value()[0]); + float distY2 =( index[1]-it.Value()[1])*( index[1]-it.Value()[1]); + float dist = vcl_sqrt(distX2 + distY2); + + if(dist <= m_Radius) + accu++; + + ++it; + } + } + else + return 0.; + + return static_cast<float>(accu/surface); +} + + +/** + * + */ +template <class TPointSet, class TOutput > +void +PointSetDensityFunction< TPointSet, TOutput> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + this->Superclass::PrintSelf(os,indent); +} + + +} // end namespace otb + +#endif diff --git a/Code/BasicFilters/otbPointSetFunction.h b/Code/BasicFilters/otbPointSetFunction.h index 6b21dfdae4244693b0edbf6af7b0733a29526d9d..399d8a45a3e73f1d807c1776f864dfb612eb62bc 100644 --- a/Code/BasicFilters/otbPointSetFunction.h +++ b/Code/BasicFilters/otbPointSetFunction.h @@ -33,12 +33,12 @@ namespace otb */ template <class TPointSet, class TOutput> class ITK_EXPORT PointSetFunction : - public itk::SpatialFunction<TOutput > + public itk::SpatialFunction< TOutput , 2/* TODO : change 2 by PointType::PointDimension*/, typename TPointSet::PointType > { public: /** Standard class typedefs. */ - typedef PointSetFunction Self; - typedef itk::SpatialFunction< TOutput > Superclass; +typedef PointSetFunction Self; + typedef itk::SpatialFunction< TOutput, 2 , typename TPointSet::PointType > Superclass; /** Run-time type information (and related methods). */ itkTypeMacro(PointSetFunction, itk::SpatialFunction); @@ -51,9 +51,12 @@ public: typedef TOutput OutputType; /** Set the input image (reimplemented since we need to set the detector input) */ - virtual void SetPointSet(PointSetType* PointSet); - virtual PointSetType * GetPointSet(); + itkGetConstObjectMacro(PointSet,PointSetType); + void SetPointSet( PointSetType* PointSet) + { + m_PointSet = PointSet; + } protected: PointSetFunction(); diff --git a/Code/BasicFilters/otbPointSetFunction.txx b/Code/BasicFilters/otbPointSetFunction.txx index f1a885f85f71e369cdd579fd172035923747f3c6..a11425eb0496175e3ab112c310e432d0105169fe 100644 --- a/Code/BasicFilters/otbPointSetFunction.txx +++ b/Code/BasicFilters/otbPointSetFunction.txx @@ -49,28 +49,29 @@ PointSetFunction< TPointSet, TOutput> } -/** - * SetDetector method - */ -template <class TPointSet, class TOutput > -void -PointSetFunction< TPointSet, TOutput> -::SetPointSet(PointSetType* PointSet) -{ - m_PointSet = PointSet; -} +// /** +// * SetDetector method +// */ +// template <class TPointSet, class TOutput > +// void +// PointSetFunction< TPointSet, TOutput> +// ::SetPointSet(PointSetType* PointSet) const +// { +// m_PointSet = PointSet; +// } -/** - * GetDetector method - */ -template <class TPointSet, class TOutput > -typename PointSetFunction< TPointSet,TOutput> -::PointSetType * -PointSetFunction< TPointSet, TOutput> -::GetPointSet() -{ - return m_PointSet; -} +// /** +// * GetDetector method +// */ +// template <class TPointSet, class TOutput > +// const +// typename PointSetFunction< TPointSet,TOutput> +// ::PointSetType * +// PointSetFunction< TPointSet, TOutput> +// ::GetPointSet() const +// { +// return m_PointSet; +// } } // end namespace otb #endif diff --git a/Code/BasicFilters/otbPointSetToDensityImageFilter.h b/Code/BasicFilters/otbPointSetToDensityImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..f6c224f1f46a3ea4a0b25d1b61fdc6034ee8cdd4 --- /dev/null +++ b/Code/BasicFilters/otbPointSetToDensityImageFilter.h @@ -0,0 +1,109 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + +Copyright (c) CS Systemes d'information. All rights reserved. +See CSCopyright.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 __otbPointSetToDensityImageFilter_h +#define __otbPointSetToDensityImageFilter_h + +#include "itkProcessObject.h" +#include "itkPointSet.h" +#include "itkPointSetToImageFilter.h" + + +/** \class PointSetToDensityImageFilter + * \brief This class extracts key points from an image through a pyramidal gaussian based decomposition + * + * This class implements the SURF Key point detector proposed by Tuytelaars and Vangool from the university + * of Leuven, 2005 + * + * \li Gaussian Second order derivative Hessian images are computed in each + * level and each octave for the input image. + * \li For each octave, an extremum search is launched on each 3 adjacent scales. + * \li The Key points detected are the ones extremum in the current , previous and + * next scale of reserach. 3 scales are needed for the computation (NumberOfScales >=3). + * \li Orientation and descriptors are computed for each key point detected. + * + * Selected Key Points are stored in an itk::PointSet structure. + * Points contains the coordinate of the detected point. + * DataPoints contain the values of the 64 element descriptor for each key point + * detected through the pyramidal analysis. + * + * Orientation is expressed in degree in the range of [0,360] + * + * \sa otb::ImageToDeterminantHessianImage + */ + +namespace otb +{ + template <class TInputPointSet , class TOutputImage> + class ITK_EXPORT PointSetToDensityImageFilter + : public itk::PointSetToImageFilter<TInputPointSet, TOutputImage > + { + + public: + + /** Standard class typedefs. */ + typedef PointSetToDensityImageFilter Self; + typedef itk::PointSetToImageFilter<TInputPointSet, TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(PointSetToDensityImageFilter,itk::PointSetToImageFilter); + + + /** Template parameters typedefs*/ + + + + protected: + + /** + * Constructor. + */ + PointSetToDensityImageFilter(); + /** + * Destructor. + */ + virtual ~PointSetToDensityImageFilter(); + /** + * Standard PrintSelf method. + */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + /** + * Main computation method. + */ + virtual void GenerateData(); + + private: + + PointSetToDensityImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + }; +} +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbPointSetToDensityImageFilter.txx" +#endif + +#endif + + diff --git a/Code/BasicFilters/otbPointSetToDensityImageFilter.txx b/Code/BasicFilters/otbPointSetToDensityImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..a9c2353b2a5d95aed7b3eec9ec65832014b39b7d --- /dev/null +++ b/Code/BasicFilters/otbPointSetToDensityImageFilter.txx @@ -0,0 +1,66 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + +Copyright (c) CS systèmes d'information. All rights reserved. +See CSCopyright.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 "otbPointSetToDensityImageFilter.h" + + +namespace otb +{ + /**--------------------------------------------------------- + * Constructor + ----------------------------------------------------------*/ + template <class TInputPointSet , class TOutputImage > + PointSetToDensityImageFilter< TInputPointSet , TOutputImage > + ::PointSetToDensityImageFilter() + { + } + + + /*--------------------------------------------------------- + * Destructor.c + ----------------------------------------------------------*/ + template <class TInputPointSet , class TOutputImage > + PointSetToDensityImageFilter< TInputPointSet , TOutputImage > + ::~PointSetToDensityImageFilter() + {} + + /*------------------------------------------------------- + * Generate Data + --------------------------------------------------------*/ + template <class TInputPointSet , class TOutputImage > + void + PointSetToDensityImageFilter< TInputPointSet , TOutputImage> + ::GenerateData(void) + { + + + }/** End of GenerateData()*/ + + /*---------------------------------------------------------------- + PrintSelf + -----------------------------------------------------------------*/ + template <class TInputPointSet , class TOutputImage > + void + PointSetToDensityImageFilter< TInputPointSet , TOutputImage > + ::PrintSelf(std::ostream& os, itk::Indent indent) const + { + Superclass::PrintSelf(os, indent); + } +} diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 8b6e9da75254db6f6f78649aed1d01fe7e252b67..fdf2a941f95a7a38fa8b9b76039d9eecea08eecc 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -64,6 +64,7 @@ ADD_TEST(bfTvFiltreFrost ${BASICFILTERS_TESTS1} ADD_TEST(bfTuImageToPointSetFilterTest ${BASICFILTERS_TESTS1} otbImageToPointSetFilterTest) + # ------- otb::OpeningClosingMorphologicalFilter ------------------------------ ADD_TEST(bfTuOpeningClosingFilterNew ${BASICFILTERS_TESTS1} @@ -1121,6 +1122,28 @@ ADD_TEST(bfTuPointSetFunctionNew ${BASICFILTERS_TESTS11} ) + +# ------- otbPointSetDensityFunction ---------------------------- +ADD_TEST(bfTuPointSetDensityFunctionNew ${BASICFILTERS_TESTS11} + otbPointSetDensityFunctionNew + ) + + +ADD_TEST(bfTvPointSetDensityFunctionTest ${BASICFILTERS_TESTS11} +--compare-ascii ${TOL} + ${BASELINE_FILES}/bfTvPointSetDensityFunctionOutputAscii.txt + ${TEMP}/bfTvPointSetDensityFunctionOutputAscii.txt + otbPointSetDensityFunctionTest + ${TEMP}/bfTvPointSetDensityFunctionOutputAscii.txt + ) + +#------------ otbPointSetToDensityImageFilter --------------------- + +ADD_TEST(bfTuPointSetToDensityImageFilterNew ${BASICFILTERS_TESTS11} + otbPointSetToDensityImageFilterNew) + + + # ------- otbPCAShapeModelEstimatorTest ---------------------------- ADD_TEST(bfTvImagePCAShapeModelEstimatorTest ${BASICFILTERS_TESTS11} otbImagePCAShapeModelEstimatorTest @@ -1130,8 +1153,7 @@ ADD_TEST(bfTvImagePCAShapeModelEstimatorTest ${BASICFILTERS_TESTS11} ${TEMP}/imagePCAShapeModelEstimatorTest_mean.tif ${TEMP}/imagePCAShapeModelEstimatorTest_eigen_vectors1.tif ${TEMP}/imagePCAShapeModelEstimatorTest_eigen_vectors2.tif - ) - +) # #ADD_TEST(bfTvCountImageFunction ${BASICFILTERS_TESTS11} #--compare-ascii ${TOL} @@ -1318,6 +1340,9 @@ ENDIF(USE_FFTWD) SET(BasicFilters_SRCS11 otbExtractROIResample.cxx otbPointSetFunctionNew.cxx +otbPointSetDensityFunctionNew.cxx +otbPointSetDensityFunctionTest.cxx +otbPointSetToDensityImageFilterNew.cxx #otbCountImageFunctionTest.cxx #otbCountImageFilterNew.cxx #otbCountImageFilterTest.cxx diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx index 7d4000c02282517521278b044974699efcb2ebc1..ece89b214b2b310348896fa888d92a5fd3c9d805 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx @@ -29,6 +29,9 @@ void RegisterTests() { REGISTER_TEST(otbExtractROIResample); REGISTER_TEST(otbPointSetFunctionNew); +REGISTER_TEST(otbPointSetDensityFunctionNew); +REGISTER_TEST(otbPointSetDensityFunctionTest); +REGISTER_TEST(otbPointSetToDensityImageFilterNew); //REGISTER_TEST(otbCountImageFunctionTest); //REGISTER_TEST(otbCountImageFilterNew); //REGISTER_TEST(otbCountImageFilterTest); diff --git a/Testing/Code/BasicFilters/otbCountImageFilterTest.cxx b/Testing/Code/BasicFilters/otbCountImageFilterTest.cxx deleted file mode 100644 index 68711a0a8dc84b8eb59b4f78fc341ad0b21487d9..0000000000000000000000000000000000000000 --- a/Testing/Code/BasicFilters/otbCountImageFilterTest.cxx +++ /dev/null @@ -1,87 +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 "otbImageFileWriter.h" - -#include <stdio.h> -#include "otbCountImageFilter.h" -#include "otbSiftFastImageFilter.h" -#include "otbSimplePointCountStrategy.h" -#include "itkPointSet.h" -#include "itkVariableLengthVector.h" - -#include <iostream> - -int otbCountImageFilterTest(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 otb::ImageFileWriter<ImageType> WriterType; - - 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::CountImageFilter< ImageType,DetectorType, - CounterType, ImageType> FilterType; - - - /** 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*/ - FilterType::Pointer filter = FilterType::New(); - - /** Instanciation of the detector : */ - DetectorType::Pointer detector = filter->GetDetector(); - detector->SetNumberOfScales(scales); - - - filter->SetInput(reader->GetOutput()); - filter->SetNeighborhoodRadius(radius); - filter->SetDetector(detector); /*Set the number of scales for the detector**/ - - - /** Output*/ - WriterType::Pointer writer = WriterType::New(); - writer->SetFileName(outfname); - writer->SetInput(filter->GetOutput()); - writer->Update(); - - return EXIT_SUCCESS; -} - diff --git a/Testing/Code/BasicFilters/otbPointSetDensityFunctionNew.cxx b/Testing/Code/BasicFilters/otbPointSetDensityFunctionNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..80c7e5623ce51c0f2cdb032a826589ccf779c3d4 --- /dev/null +++ b/Testing/Code/BasicFilters/otbPointSetDensityFunctionNew.cxx @@ -0,0 +1,42 @@ +/*========================================================================= + +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 <stdio.h> + +#include "otbPointSetDensityFunction.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" + + +int otbPointSetDensityFunctionNew(int, char* [] ) +{ + + const unsigned int Dimension = 2; + typedef float PixelType; + + typedef itk::VariableLengthVector<PixelType> RealVectorType; + typedef itk::PointSet<RealVectorType,Dimension> PointSetType; + typedef otb::PointSetDensityFunction <PointSetType,PixelType> FunctionType; + + /**Instancitation of an object*/ + FunctionType filter(); + //FunctionType::Pointer filter = FunctionType::New(); + + return EXIT_SUCCESS; +} + diff --git a/Testing/Code/BasicFilters/otbPointSetDensityFunctionTest.cxx b/Testing/Code/BasicFilters/otbPointSetDensityFunctionTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..dd6f7d9c91b5b599b521c177d2226f3d0fefa7ef --- /dev/null +++ b/Testing/Code/BasicFilters/otbPointSetDensityFunctionTest.cxx @@ -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. + +=========================================================================*/ + +#include "otbImageFileReader.h" +#include "otbPointSetDensityFunction.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" +#include "otbSiftFastImageFilter.h" + +#include <iostream> + +int otbPointSetDensityFunctionTest(int argc, char* argv[] ) +{ + + const char * outfname = argv[1]; + + const unsigned int Dimension = 2; + typedef float PixelType; + + typedef itk::VariableLengthVector<PixelType> RealVectorType; + typedef itk::PointSet<RealVectorType,Dimension> PointSetType; + typedef otb::PointSetDensityFunction <PointSetType,PixelType> FunctionType; + + + /**Instancitation of an object*/ + PointSetType::Pointer pointSet = PointSetType::New(); + FunctionType::Pointer filter = FunctionType::New(); + std::ofstream outfile(outfname); + + /** Construction of the pointSet */ + PointSetType::PointIdentifier count = 0; + + PointSetType::PointType pDst ,pSrc; + pDst[0] = 12.78 ; + pDst[1] = 18.76 ; + pointSet->SetPoint(count++,pDst); + + pDst[0] = 15.78 ; + pDst[1] = 23.76 ; + pointSet->SetPoint(count++,pDst); + + pDst[0] = 9.78 ; + pDst[1] = 5.76 ; + pointSet->SetPoint(count++,pDst); + + + filter->SetPointSet(pointSet); + filter->SetRadius(2); + + /**Point we serach around*/ + pDst[0] = 14.9; pDst[1] = 24; + outfile << "Density computed for the point : " << pDst << " is "<< filter->Evaluate(pDst) << std::endl; + + pDst[0] = 9; pDst[1] = 5; + outfile << "Density computed for the point : " << pDst << " is "<< filter->Evaluate(pDst) << std::endl; + + outfile.close(); + + return EXIT_SUCCESS; +} + diff --git a/Testing/Code/BasicFilters/otbPointSetFunctionNew.cxx b/Testing/Code/BasicFilters/otbPointSetFunctionNew.cxx index d23ee51756d38c84bb32ea596cafdb3968449a64..c65ec0a586c8707cd824f96eafae37019d41d907 100644 --- a/Testing/Code/BasicFilters/otbPointSetFunctionNew.cxx +++ b/Testing/Code/BasicFilters/otbPointSetFunctionNew.cxx @@ -31,7 +31,7 @@ int otbPointSetFunctionNew(int, char* [] ) typedef itk::VariableLengthVector<PixelType> RealVectorType; typedef itk::PointSet<RealVectorType,Dimension> PointSetType; - typedef otb::PointSetFunction <PointSetType,PixelType> FunctionType; + typedef otb::PointSetFunction <PointSetType,PixelType> FunctionType; /**Instancitation of an object*/ FunctionType filter(); diff --git a/Testing/Code/BasicFilters/otbPointSetToDensityImageFilterNew.cxx b/Testing/Code/BasicFilters/otbPointSetToDensityImageFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e96a5945c4329d8b4bd51829bbc7ce06184aaf5b --- /dev/null +++ b/Testing/Code/BasicFilters/otbPointSetToDensityImageFilterNew.cxx @@ -0,0 +1,43 @@ +/*========================================================================= + +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 <stdio.h> +#include "otbImage.h" +#include "otbPointSetToDensityImageFilter.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" + + +int otbPointSetToDensityImageFilterNew(int, char* [] ) +{ + + const unsigned int Dimension = 2; + typedef float PixelType; + + typedef otb::Image<PixelType , Dimension> ImageType; + typedef itk::VariableLengthVector<PixelType> RealVectorType; + typedef itk::PointSet<RealVectorType,Dimension> PointSetType; + typedef otb::PointSetToDensityImageFilter <PointSetType,ImageType> FunctionType; + + /**Instancitation of an object*/ + + FunctionType::Pointer filter = FunctionType::New(); + + return EXIT_SUCCESS; +} +