From 8c5663b37b789910b8617dbf1ee5db4d839c83a6 Mon Sep 17 00:00:00 2001 From: Otmane Lahlou <otmane.lahlou@c-s.fr> Date: Fri, 30 Jan 2009 11:52:26 +0100 Subject: [PATCH] ADD: test otbKeyPointDensityImageFilterTest & Correcting mistakes in the BasicFilter CMakelist --- Testing/Code/BasicFilters/CMakeLists.txt | 26 +++--- .../BasicFilters/otbBasicFiltersTests11.cxx | 2 +- .../otbKeyPointDensityImageFilterTest.cxx | 79 +++++++++++++++++++ 3 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 Testing/Code/BasicFilters/otbKeyPointDensityImageFilterTest.cxx diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 7bc20d4cdf..894a4406b7 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1109,7 +1109,7 @@ ADD_TEST(bfTvExtractROIResample ${BASICFILTERS_TESTS11} ADD_TEST(bfTvExtractROIResample2 ${BASICFILTERS_TESTS11} --compare-image ${TOL} - ${BASELINE_FILES}/bfTvExtractROIResample2.tif + ${BASELINE}/bfTvExtractROIResample2.tif ${TEMP}/bfTvExtractROIResample2.tif otbExtractROIResample ${INPUTDATA}/ToulouseQuickBird_Extrait_1500_3750.tif @@ -1146,12 +1146,12 @@ ADD_TEST(bfTuPointSetToDensityImageFilterNew ${BASICFILTERS_TESTS11} ADD_TEST(bfTvPointSetToDensityImageFilterTest ${BASICFILTERS_TESTS11} --compare-image ${TOL} - ${BASELINE_FILES}/bfTvPointSetToDensityImageFilterOutputImage.tif + ${BASELINE}/bfTvPointSetToDensityImageFilterOutputImage.tif ${TEMP}/bfTvPointSetToDensityImageFilterOutputImage.tif otbPointSetToDensityImageFilterTest ${INPUTDATA}/QB_Suburb.png ${TEMP}/bfTvPointSetToDensityImageFilterOutputImage.tif - 5 2 + 3 5 10 ) # ------- otbPCAShapeModelEstimatorTest ---------------------------- @@ -1170,15 +1170,15 @@ ADD_TEST(bfTuKeyPointDensityImageFilterNew ${BASICFILTERS_TESTS11} otbKeyPointDensityImageFilterNew ) -#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(bfTvKeyPointDensityImageFilterOutputImage ${BASICFILTERS_TESTS11} +--compare-image ${TOL} + ${BASELINE}/bfTvKeyPointDensityImageFilterOutputImage.tif + ${TEMP}/bfTvKeyPointDensityImageFilterOutputImage.tif + otbKeyPointDensityImageFilterTest + ${INPUTDATA}/QB_Suburb.png + ${TEMP}/bfTvKeyPointDensityImageFilterOutputImage.tif + 3 5 10 +) ADD_TEST(bfTvFunctionWithNeighborhoodToImageFilterNew ${BASICFILTERS_TESTS11} otbFunctionWithNeighborhoodToImageFilterNew @@ -1351,7 +1351,7 @@ otbPointSetDensityFunctionTest.cxx otbPointSetToDensityImageFilterNew.cxx otbPointSetToDensityImageFilterTest.cxx otbKeyPointDensityImageFilterNew.cxx -#otbCountImageFilterTest.cxx +otbKeyPointDensityImageFilterTest.cxx otbImagePCAShapeModelEstimatorTest.cxx otbFunctionWithNeighborhoodToImageFilterNew.cxx ) diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx index 57ff26ff62..9589919931 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests11.cxx @@ -34,7 +34,7 @@ REGISTER_TEST(otbPointSetDensityFunctionTest); REGISTER_TEST(otbPointSetToDensityImageFilterNew); REGISTER_TEST(otbPointSetToDensityImageFilterTest); REGISTER_TEST(otbKeyPointDensityImageFilterNew); -//REGISTER_TEST(otbCountImageFilterTest); +REGISTER_TEST(otbKeyPointDensityImageFilterTest); REGISTER_TEST(otbImagePCAShapeModelEstimatorTest); REGISTER_TEST(otbFunctionWithNeighborhoodToImageFilterNew); } diff --git a/Testing/Code/BasicFilters/otbKeyPointDensityImageFilterTest.cxx b/Testing/Code/BasicFilters/otbKeyPointDensityImageFilterTest.cxx new file mode 100644 index 0000000000..2505769be3 --- /dev/null +++ b/Testing/Code/BasicFilters/otbKeyPointDensityImageFilterTest.cxx @@ -0,0 +1,79 @@ +/*========================================================================= + +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 "otbKeyPointDensityImageFilter.h" +#include "otbImageToSIFTKeyPointSetFilter.h" +#include "itkPointSet.h" +#include "itkVariableLengthVector.h" +#include "otbImage.h" + +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +int otbKeyPointDensityImageFilterTest(int argc, char* argv[] ) +{ + const char * infname = argv[1]; + const char * outfname = argv[2]; + const unsigned int scales = atoi(argv[3]); + const unsigned int octaves = atoi(argv[4]); + const unsigned int radius = atoi(argv[5]); + + 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::ImageToSIFTKeyPointSetFilter<ImageType,PointSetType> DetectorType; + + typedef otb::KeyPointDensityImageFilter< ImageType,DetectorType, ImageType> FilterType; + + + /**Instancitation of an object*/ + FilterType::Pointer filter = FilterType::New(); + DetectorType::Pointer detector = DetectorType::New(); + ReaderType::Pointer reader = ReaderType::New(); + + reader->SetFileName(infname); + reader->GenerateOutputInformation(); + + filter->SetInput(reader->GetOutput()); + detector = filter->GetDetector(); + detector ->SetOctavesNumber(octaves); + detector->SetScalesNumber(scales); + + + filter->SetDetector(detector); + filter->SetNeighborhoodRadius(radius); + + /** Writing the densty Image*/ + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(outfname); + writer->SetInput(filter->GetOutput()); + writer->Update(); + + + + return EXIT_SUCCESS; +} + -- GitLab