diff --git a/Code/BasicFilters/otbCountImageFunction.h b/Code/BasicFilters/otbCountImageFunction.h new file mode 100644 index 0000000000000000000000000000000000000000..fdbd57299ad95061bbd9f663b7bca7b1df93cdbb --- /dev/null +++ b/Code/BasicFilters/otbCountImageFunction.h @@ -0,0 +1,139 @@ +/*========================================================================= + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..b790707f7d0e292afbbaefd2b2cd495590f6d89f --- /dev/null +++ b/Code/BasicFilters/otbCountImageFunction.txx @@ -0,0 +1,105 @@ +/*========================================================================= + + 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/Common/otbTestMain.h b/Code/Common/otbTestMain.h index 717db9c975c3b44693af8fc9ca2ed5f4b7bfe15d..8e728f326e3c5a64c0eb8fd3ee47db494b1d75dd 100644 --- a/Code/Common/otbTestMain.h +++ b/Code/Common/otbTestMain.h @@ -798,7 +798,7 @@ int RegressionTestAsciiFile(const char * testAsciiFileName, const char * baselin nbdiff++; } - else if (vcl_abs(atof(strRef.c_str())-atof(strTest.c_str())) > epsilon) + else if ( (strRef != strTest) && (vcl_abs(atof(strRef.c_str())-atof(strTest.c_str())) > epsilon) ) { if( reportErrors ) { @@ -855,7 +855,7 @@ int RegressionTestAsciiFile(const char * testAsciiFileName, const char * baselin else if ((etatCour==ETAT_CHAR)&&(etatPrec==ETAT_NUM)) { - if (vcl_abs(atof(strNumRef.c_str())-atof(strNumTest.c_str())) > epsilon) + if ( (strNumRef != strNumTest) && (vcl_abs(atof(strNumRef.c_str())-atof(strNumTest.c_str())) > epsilon) ) { if( reportErrors ) { @@ -897,7 +897,7 @@ int RegressionTestAsciiFile(const char * testAsciiFileName, const char * baselin if (isNumeric(strRef)) { - if (vcl_abs(atof(strRef.c_str())-atof(strTest.c_str())) > epsilon) + if ( ( strRef != strTest) && (vcl_abs(atof(strRef.c_str())-atof(strTest.c_str())) > epsilon)) { if( reportErrors ) { diff --git a/Code/FeatureExtraction/otbSimplePointCountStrategy.h b/Code/FeatureExtraction/otbSimplePointCountStrategy.h new file mode 100644 index 0000000000000000000000000000000000000000..693ed129b6f37ded934e28066a308676a8e44c71 --- /dev/null +++ b/Code/FeatureExtraction/otbSimplePointCountStrategy.h @@ -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 __otbSimplePointCountStrategy_h +#define __otbSimplePointCountStrategy_h + +#include "otbMath.h" + + +namespace otb +{ + +/** \class Count + * \brief Compute the density of a neighboorhood centerred in a pixel + * + * This filter is templated over the pixel type of the input image + * and the pixel type of the output image. + * + * The filter will walk over all the pixels in the input image, and for + * each one of them it will do the following: + + */ + + +template< class TPointSet, class TRadiusType , class TIndexType> +class Count +{ +public: + Count() {}; + ~Count() {}; + + inline float operator()( const TPointSet * pointSet , const TRadiusType & size , const TIndexType & index ) + { + + int accu = 0; + double surface = M_PI*size*size; + + typedef typename TPointSet::PointsContainer::ConstIterator iteratorType; + + iteratorType it = pointSet->GetPoints()->Begin(); + + while( it != pointSet->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 <= size) + accu++; + + ++it; + } + + return static_cast<float>(accu/surface); + } +}; + + +} // end namespace otb + + +#endif diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 1f1c98ca473f404c777f29db51c023a7fc19a09f..a8317545fbc03c2513b866a56f64b614772ece67 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1115,7 +1115,20 @@ ADD_TEST(bfTvExtractROIResample2 ${BASICFILTERS_TESTS11} ${TEMP}/bfTvExtractROIResample2.tif 1 ) +# ------- otbCountImageFunction ---------------------------- +ADD_TEST(bfTuCountImageFunctionNew ${BASICFILTERS_TESTS11} + otbCountImageFunctionNew + ) +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 +) # A enrichir SET(BasicFilters_SRCS1 @@ -1277,6 +1290,8 @@ ENDIF(USE_FFTWD) SET(BasicFilters_SRCS11 otbExtractROIResample.cxx +otbCountImageFunctionNew.cxx +otbCountImageFunctionTest.cxx ) @@ -1313,6 +1328,6 @@ ADD_EXECUTABLE(otbBasicFiltersTests10 otbBasicFiltersTests10.cxx ${BasicFilters_ TARGET_LINK_LIBRARIES(otbBasicFiltersTests10 OTBBasicFilters OTBIO ) ADD_EXECUTABLE(otbBasicFiltersTests11 otbBasicFiltersTests11.cxx ${BasicFilters_SRCS11}) -TARGET_LINK_LIBRARIES(otbBasicFiltersTests11 OTBBasicFilters OTBIO ) +TARGET_LINK_LIBRARIES(otbBasicFiltersTests11 OTBBasicFilters OTBIO OTBFeatureExtraction) ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx index b92b25de997386b26c69c3e7f687d72eafb27133..18fa0e979aaf7e6e63c8c3ee767e16d5b4e90180 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx @@ -27,5 +27,7 @@ void RegisterTests() { - REGISTER_TEST(otbExtractROIResample); +REGISTER_TEST(otbExtractROIResample); +REGISTER_TEST(otbCountImageFunctionNew); +REGISTER_TEST(otbCountImageFunctionTest); } diff --git a/Testing/Code/BasicFilters/otbCountImageFunction.cxx b/Testing/Code/BasicFilters/otbCountImageFunction.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1edc301a424ffa72f34428d26521b4a762f629c2 --- /dev/null +++ b/Testing/Code/BasicFilters/otbCountImageFunction.cxx @@ -0,0 +1,50 @@ +/*========================================================================= + +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 "otbCountImageFunction.h" +#include "otbSiftFastImageFilter.h" +#include "otbSimplePointCountStrategy.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" + +int otbCountImageFunctionNew(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; + + /**Instancitation of an object*/ + FunctionType::Pointer filter = FunctionType::New(); + + return EXIT_SUCCESS; +} + diff --git a/Testing/Code/BasicFilters/otbCountImageFunctionNew.cxx b/Testing/Code/BasicFilters/otbCountImageFunctionNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1edc301a424ffa72f34428d26521b4a762f629c2 --- /dev/null +++ b/Testing/Code/BasicFilters/otbCountImageFunctionNew.cxx @@ -0,0 +1,50 @@ +/*========================================================================= + +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 "otbCountImageFunction.h" +#include "otbSiftFastImageFilter.h" +#include "otbSimplePointCountStrategy.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" + +int otbCountImageFunctionNew(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; + + /**Instancitation of an object*/ + FunctionType::Pointer filter = FunctionType::New(); + + return EXIT_SUCCESS; +} + diff --git a/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx b/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..462646c226f98ee8bf5a7d8fd71503da61fafe85 --- /dev/null +++ b/Testing/Code/BasicFilters/otbCountImageFunctionTest.cxx @@ -0,0 +1,103 @@ +/*========================================================================= + +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/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index 480ec303823efdb6e8fcb031d78ecfbc26703ad3..492b7c11349aca3cdcc506820da946f0de2ae6fc 100644 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -961,6 +961,14 @@ ADD_TEST(KeyPointSetsMatchingFilter ${FEATUREEXTRACTION_TESTS9} ADD_TEST(LandmarkNew ${FEATUREEXTRACTION_TESTS9} otbLandmarkNew) + +#--------- SimpleCountStrategy -------------- + +ADD_TEST(otbSimplePointCountStrategyTest ${FEATUREEXTRACTION_TESTS9} + otbSimplePointCountStrategyTest) + + + # A enrichir SET(BasicFeatureExtraction_SRCS1 otbAlignImageToPath.cxx @@ -1080,6 +1088,7 @@ otbImageToSIFTKeyPointSetFilterOutputImage.cxx otbKeyPointSetsMatchingFilterNew.cxx otbKeyPointSetsMatchingFilter.cxx otbLandmarkNew.cxx +otbSimplePointCountStrategyTest.cxx ) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx index cb9a3a2a0d44a25262c6f7c6720828b682ee5956..34df0698fced0bffd0695f0b70e678b719490e68 100644 --- a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx +++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests9.cxx @@ -48,4 +48,5 @@ REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii); REGISTER_TEST(otbKeyPointSetsMatchingFilterNew); REGISTER_TEST(otbKeyPointSetsMatchingFilter); REGISTER_TEST(otbLandmarkNew); +REGISTER_TEST(otbSimplePointCountStrategyTest); } diff --git a/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx b/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx index a64baa87e08e45a328533cd8a649f3973883e878..3af21c02573eb32856f51e32ed9b7de5dbbb0145 100644 --- a/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx +++ b/Testing/Code/FeatureExtraction/otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii.cxx @@ -118,8 +118,5 @@ int otbImageToFastSIFTKeyPointSetFilterOutputDescriptorAscii(int argc, char * ar } outfile.close(); - - outfile.close(); - return EXIT_SUCCESS; } diff --git a/Testing/Code/FeatureExtraction/otbSimplePointCountStrategyTest.cxx b/Testing/Code/FeatureExtraction/otbSimplePointCountStrategyTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b5612ca8db6adbdd128c42513953594f8f3ac1bc --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbSimplePointCountStrategyTest.cxx @@ -0,0 +1,63 @@ +/*========================================================================= + +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 "otbSimplePointCountStrategy.h" +#include "itkPointSet.h" +#include "otbImage.h" +#include "itkVariableLengthVector.h" + +int otbSimplePointCountStrategyTest(int argc, char * argv[]) +{ + + const unsigned int Dimension =2; + typedef float RealType; + + typedef otb::Image<RealType,Dimension> ImageType; + typedef ImageType::PointType PointType ; + typedef itk::VariableLengthVector<RealType> RealVectorType; + + typedef itk::PointSet<RealVectorType,Dimension> PointSetType; + typedef PointSetType::PointsContainer PointsContainerType; + typedef ImageType::IndexType IndexType; + + typedef otb::Count<PointSetType, unsigned int ,IndexType> counterType; + + /*pointSet de test*/ + PointSetType::Pointer pointset = PointSetType::New(); + PointsContainerType::ElementIdentifier count = 0; + PointSetType::PointType Point; + Point[0] = 12.14 ; Point[1] = 14.14; + + for(int i = 0 ; i < 10 ; i++) + { + pointset->SetPoint(count, Point); + count++; + }/** Fin creation pointset de test */ + + /*Test du filtre*/ + IndexType index; + index[0] = 12 ; index[1] = 14 ; + unsigned int rad = 2; + counterType comptemoica; + + std::cout <<"Le resultat retourne est " <<comptemoica(pointset,rad,index)<< std::endl; + + + return EXIT_SUCCESS; + +} diff --git a/Testing/Utilities/CMakeLists.txt b/Testing/Utilities/CMakeLists.txt index 37e00613e0b0413245238b47ef4b6fa68fd23675..1789cad2bd6b564e9dd934ba25816f179e73ca56 100644 --- a/Testing/Utilities/CMakeLists.txt +++ b/Testing/Utilities/CMakeLists.txt @@ -465,19 +465,6 @@ kmlprint.cc siftfast.cpp ) -# Suppress deprecated warning -IF(CMAKE_COMPILER_IS_GNUCXX) - SET_SOURCE_FILES_PROPERTIES(ijBSplineScatteredDataPointSetToImageFilterTest.cxx PROPERTIES COMPILE_FLAGS -w) -ELSE(CMAKE_COMPILER_IS_GNUCXX) - IF(WIN32) - IF (CMAKE_CXX_COMPILER MATCHES "^cl$") - SET_SOURCE_FILES_PROPERTIES( ijBSplineScatteredDataPointSetToImageFilterTest.cxx PROPERTIES COMPILE_FLAGS "/W0" ) - ENDIF (CMAKE_CXX_COMPILER MATCHES "^cl$") - ENDIF(WIN32) -ENDIF(CMAKE_COMPILER_IS_GNUCXX) - - - IF(OTB_COMPILE_JPEG2000) SET(UtilitiesTests_SRCS ${UtilitiesTests_SRCS} openJpegEncoder.cxx openJpegDecoder.cxx) ENDIF(OTB_COMPILE_JPEG2000) @@ -495,13 +482,30 @@ IF(NOT OTB_USE_EXTERNAL_EXPAT) expatchardata.cxx expatminicheck.cxx expatruntests.cxx ) - IF(CMAKE_COMPILER_IS_GNUCXX) - SET_SOURCE_FILES_PROPERTIES( expatchardata.cxx expatminicheck.cxx expatruntests.cxx PROPERTIES COMPILE_FLAGS -w ) - ENDIF(CMAKE_COMPILER_IS_GNUCXX) - ENDIF(NOT OTB_USE_EXTERNAL_EXPAT) +# ------- Select sources files suppress warning ----------------------------------- +SET(UtilitiesTests_DisableWarning_SRCS + ijBSplineScatteredDataPointSetToImageFilterTest.cxx + siftfast.cpp + openthreadsWorkCrew.cpp + expatchardata.cxx + expatminicheck.cxx + expatruntests.cxx +) +IF(CMAKE_COMPILER_IS_GNUCXX) + SET_SOURCE_FILES_PROPERTIES( ${UtilitiesTests_DisableWarning_SRCS} PROPERTIES COMPILE_FLAGS -w) +ELSE(CMAKE_COMPILER_IS_GNUCXX) + IF(WIN32) + IF (CMAKE_CXX_COMPILER MATCHES "^cl$") + SET_SOURCE_FILES_PROPERTIES( ${UtilitiesTests_DisableWarning_SRCS} PROPERTIES COMPILE_FLAGS "/W0" ) + ENDIF (CMAKE_CXX_COMPILER MATCHES "^cl$") + ENDIF(WIN32) +ENDIF(CMAKE_COMPILER_IS_GNUCXX) + + + INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/Utilities/otbsiftfast/CMakeLists.txt b/Utilities/otbsiftfast/CMakeLists.txt index dd28ee140557caf55b07dbce3cff89a247d47999..994daa13c167c4e6fe047a385855e31f687bdd49 100755 --- a/Utilities/otbsiftfast/CMakeLists.txt +++ b/Utilities/otbsiftfast/CMakeLists.txt @@ -76,15 +76,10 @@ endif() # TRY COMPILE libsiftfast.cpp (depend of gcc version) IF(CMAKE_COMPILER_IS_GNUCXX) SET(IS_SIFTFAST_COMPILE 0) -# SET(OTB_DISABLE_FAST_FUNCTIONS_VALUE 0) -# CHECK_CXX_SOURCE_COMPILES( -# ${CMAKE_CURRENT_SOURCE_DIR}/test_try_compile_main_libsiftfast.cpp -# CMAKE_REQUIRED_FLAGS "-msse2 -mfpmath=sse" -# IS_SIFTFAST_COMPILE ) -#CMAKE_REQUIRED_DEFINITIONS TRY_COMPILE(IS_SIFTFAST_COMPILE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test_try_compile_libsiftfast.cpp + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${SSE_FLAGS} OUTPUT_VARIABLE OUTPUT) IF(IS_SIFTFAST_COMPILE) MESSAGE(STATUS "Try to compile libsiftfast.cpp -- yes.") @@ -93,6 +88,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX) TRY_COMPILE(IS_SIFTFAST_COMPILE2 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test_try_compile_libsiftfast.cpp + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${SSE_FLAGS} COMPILE_DEFINITIONS -DOTB_DISABLE_FAST_FUNCTIONS OUTPUT_VARIABLE OUTPUT) IF(IS_SIFTFAST_COMPILE2)