From c1b121a1af71e1f290aac2f363c73185dcbc96f1 Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Sat, 10 Apr 2010 11:19:03 +0800 Subject: [PATCH] TEST: add instanciation and non regression tests for PointSetDensityEpanechnikovFunction --- Testing/Code/BasicFilters/CMakeLists.txt | 16 ++++ .../BasicFilters/otbBasicFiltersTests11.cxx | 2 + ...PointSetDensityEpanechnikovFunctionNew.cxx | 39 ++++++++++ ...ointSetDensityEpanechnikovFunctionTest.cxx | 75 +++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionNew.cxx create mode 100644 Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionTest.cxx diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index b8e14d13b0..0504f2b4cd 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1289,6 +1289,20 @@ ADD_TEST(bfTvPointSetDensityGaussianFunctionTest ${BASICFILTERS_TESTS11} ${TEMP}/bfTvPointSetDensityGaussianFunctionOutputAscii.txt ) +# ------- otbPointSetDensityEpanechnikovFunction ---------------------------- +ADD_TEST(bfTuPointSetDensityEpanechnikovFunctionNew ${BASICFILTERS_TESTS11} + otbPointSetDensityEpanechnikovFunctionNew + ) + + +ADD_TEST(bfTvPointSetDensityEpanechnikovFunctionTest ${BASICFILTERS_TESTS11} +--compare-ascii ${NOTOL} + ${BASELINE_FILES}/bfTvPointSetDensityEpanechnikovFunctionOutputAscii.txt + ${TEMP}/bfTvPointSetDensityEpanechnikovFunctionOutputAscii.txt + otbPointSetDensityEpanechnikovFunctionTest + ${TEMP}/bfTvPointSetDensityEpanechnikovFunctionOutputAscii.txt + ) + #------------ otbPointSetToDensityImageFilter --------------------- ADD_TEST(bfTuPointSetToDensityImageFilterNew ${BASICFILTERS_TESTS11} @@ -1802,6 +1816,8 @@ otbPointSetDensityFunctionNew.cxx otbPointSetDensityFunctionTest.cxx otbPointSetDensityGaussianFunctionNew.cxx otbPointSetDensityGaussianFunctionTest.cxx +otbPointSetDensityEpanechnikovFunctionNew.cxx +otbPointSetDensityEpanechnikovFunctionTest.cxx otbPointSetToDensityImageFilterNew.cxx otbPointSetToDensityImageFilterTest.cxx otbKeyPointDensityImageFilterNew.cxx diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx index 5cd9151036..65f7de6536 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx @@ -32,6 +32,8 @@ void RegisterTests() REGISTER_TEST(otbPointSetDensityFunctionTest); REGISTER_TEST(otbPointSetDensityGaussianFunctionNew); REGISTER_TEST(otbPointSetDensityGaussianFunctionTest); + REGISTER_TEST(otbPointSetDensityEpanechnikovFunctionNew); + REGISTER_TEST(otbPointSetDensityEpanechnikovFunctionTest); REGISTER_TEST(otbPointSetToDensityImageFilterNew); REGISTER_TEST(otbPointSetToDensityImageFilterTest); REGISTER_TEST(otbKeyPointDensityImageFilterNew); diff --git a/Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionNew.cxx b/Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionNew.cxx new file mode 100644 index 0000000000..4da21b38ad --- /dev/null +++ b/Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionNew.cxx @@ -0,0 +1,39 @@ +/*========================================================================= + + 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 "otbPointSetDensityEpanechnikovFunction.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" + +int otbPointSetDensityEpanechnikovFunctionNew(int, char*[]) +{ + + const unsigned int Dimension = 2; + typedef float PixelType; + + typedef itk::VariableLengthVector<PixelType> RealVectorType; + typedef itk::PointSet<RealVectorType, Dimension> PointSetType; + typedef otb::PointSetDensityEpanechnikovFunction <PointSetType, PixelType> FunctionType; + + /**Instantiation of a Smart Pointer*/ + FunctionType::Pointer filter = FunctionType::New(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionTest.cxx b/Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionTest.cxx new file mode 100644 index 0000000000..aa69b165af --- /dev/null +++ b/Testing/Code/BasicFilters/otbPointSetDensityEpanechnikovFunctionTest.cxx @@ -0,0 +1,75 @@ +/*========================================================================= + + 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 "otbPointSetDensityEpanechnikovFunction.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" +#include "otbSiftFastImageFilter.h" + +#include <iostream> + +int otbPointSetDensityEpanechnikovFunctionTest(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::PointSetDensityEpanechnikovFunction <PointSetType, PixelType> FunctionType; + + /**Instantiation of a Smart Pointer*/ + 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 search 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; +} -- GitLab