diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 0723a315b35228f9e021c0c1bbbc871c7b0d0610..985664145757c86d8017df06c1084845bddf7efe 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1102,6 +1102,9 @@ ADD_TEST(bfTvContinuousMinimumMaximumImageCalculatorTest ${BASICFILTERS_TESTS9} ADD_TEST(bfTuMeanShiftImageFilterNew ${BASICFILTERS_TESTS9} otbMeanShiftImageFilterNew ) +ADD_TEST(bfTuMeanShiftImageFilterNew2 ${BASICFILTERS_TESTS9} + otbMeanShiftImageFilterNew2 ) + ADD_TEST(bfTvMeanShiftImageFilter ${BASICFILTERS_TESTS9} --compare-n-images ${EPSILON_7} 4 @@ -1122,6 +1125,25 @@ ADD_TEST(bfTvMeanShiftImageFilter ${BASICFILTERS_TESTS9} 16 16 10 1.0 ) +ADD_TEST(bfTvMeanShiftImageFilterValid ${BASICFILTERS_TESTS9} + otbMeanShiftImageFilter + ${INPUTDATA}/QB_Suburb.png + ${TEMP}/bfMeanShiftImageFilterOutputValid.tif + ${TEMP}/bfMeanShiftImageFilterClusteredOutputValid.tif + ${TEMP}/bfMeanShiftImageFilterLabeledClusteredOutputValid.tif + ${TEMP}/bfMeanShiftImageFilterClusterBoundariesOutputValid.tif + 9 50 10 1.0 + ) + +ADD_TEST(bfTvMeanShiftImageFilter2 ${BASICFILTERS_TESTS9} + otbMeanShiftImageFilter2 + ${INPUTDATA}/QB_Suburb.png + ${TEMP}/bfMeanShiftImageSpatialOutput.tif + ${TEMP}/bfMeanShiftImageFilterSpectralOutput.tif + ${TEMP}/bfMeanShiftImageFilterMetricOutput.tif + 9 9 50 + ) + ADD_TEST(bfTuMeanShiftVectorImageFilterNew ${BASICFILTERS_TESTS9} otbMeanShiftVectorImageFilterNew ) @@ -2703,6 +2725,8 @@ otbContinuousMinimumMaximumImageCalculatorNew.cxx otbContinuousMinimumMaximumImageCalculatorTest.cxx otbMeanShiftImageFilterNew.cxx otbMeanShiftImageFilter.cxx +otbMeanShiftImageFilterNew2.cxx +otbMeanShiftImageFilter2.cxx otbMeanShiftVectorImageFilterNew.cxx otbMeanShiftVectorImageFilter.cxx otbFunctionToImageFilterNew.cxx diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests9.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests9.cxx index 69c2de1561c42cad89217ec56bd9ba03dfd9f0ad..f068c483aaf76f350908adc50d121cb7c62bb277 100644 --- a/Testing/Code/BasicFilters/otbBasicFiltersTests9.cxx +++ b/Testing/Code/BasicFilters/otbBasicFiltersTests9.cxx @@ -28,6 +28,8 @@ void RegisterTests() REGISTER_TEST(otbContinuousMinimumMaximumImageCalculatorTest); REGISTER_TEST(otbMeanShiftImageFilterNew); REGISTER_TEST(otbMeanShiftImageFilter); + REGISTER_TEST(otbMeanShiftImageFilterNew2); + REGISTER_TEST(otbMeanShiftImageFilter2); REGISTER_TEST(otbMeanShiftVectorImageFilterNew); REGISTER_TEST(otbMeanShiftVectorImageFilter); REGISTER_TEST(otbFunctionToImageFilterNew); diff --git a/Testing/Code/BasicFilters/otbMeanShiftImageFilter2.cxx b/Testing/Code/BasicFilters/otbMeanShiftImageFilter2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f217359fafe34bbc6df92deff7f913f9a1f8e9fe --- /dev/null +++ b/Testing/Code/BasicFilters/otbMeanShiftImageFilter2.cxx @@ -0,0 +1,90 @@ +/*========================================================================= + + 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 "itkMacro.h" +#include "otbImage.h" +#include "otbVectorImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbMeanShiftImageFilter2.h" + +int otbMeanShiftImageFilter2(int argc, char * argv[]) +{ + if (argc != 8) + { + std::cerr << "Usage: " << argv[0] << + " infname spatialfname spectralfname metricfname spatialRadius spectralRadius spectralbandwidth" + << std::endl; + return EXIT_FAILURE; + } + + const char * infname = argv[1]; + const char * spatialfname = argv[2]; + const char * spectralfname = argv[3]; + const char * metricfname = argv[4]; + const unsigned int spatialRadius = atoi(argv[5]); + const unsigned int spectralRadius = atoi(argv[6]); + const double spectralbandwidth = atof(argv[7]); + + /* maxit - threshold */ + + const unsigned int Dimension = 2; + typedef float PixelType; + typedef double KernelType; + typedef otb::VectorImage<PixelType, Dimension> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; + typedef otb::MeanShiftImageFilter2<ImageType, ImageType,ImageType,KernelType> FilterType; + + // Instantiating object + FilterType::Pointer filter = FilterType::New(); + ReaderType::Pointer reader = ReaderType::New(); + + reader->SetFileName(infname); + + //define square radius + ImageType::SizeType radius; + radius[0]=spatialRadius; + radius[1]=spatialRadius; + + filter->SetSpatialRadius(radius); + + radius[0]=spectralRadius; + radius[1]=spectralRadius; + filter->SetRangeRadius(radius); + filter->SetSpectralBandwidth(spectralbandwidth); + + filter->SetInput(reader->GetOutput()); + //filter->SetNumberOfThreads(1); + WriterType::Pointer writer1 = WriterType::New(); + WriterType::Pointer writer2 = WriterType::New(); + WriterType::Pointer writer3 = WriterType::New(); + + + writer1->SetFileName(spatialfname); + writer2->SetFileName(spectralfname); + writer3->SetFileName(metricfname); + + writer1->SetInput(filter->GetSpatialOutput()); + writer2->SetInput(filter->GetRangeOutput()); + writer3->SetInput(filter->GetMetricOutput()); + writer1->Update(); + writer2->Update(); + writer3->Update(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/BasicFilters/otbMeanShiftImageFilterNew2.cxx b/Testing/Code/BasicFilters/otbMeanShiftImageFilterNew2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5865499309e35e899711c96c140f46c8cf5fb4f1 --- /dev/null +++ b/Testing/Code/BasicFilters/otbMeanShiftImageFilterNew2.cxx @@ -0,0 +1,38 @@ +/*========================================================================= + + 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 "itkMacro.h" +#include "otbVectorImage.h" +#include "otbMeanShiftImageFilter2.h" + +int otbMeanShiftImageFilterNew2(int argc, char * argv[]) +{ + const unsigned int Dimension = 2; + typedef short PixelType; + typedef double OutputPixelType; + typedef double KernelType; + typedef otb::VectorImage<OutputPixelType, Dimension> OutputImageType; + typedef otb::VectorImage<PixelType, Dimension> ImageType; + typedef otb::MeanShiftImageFilter2<ImageType, OutputImageType, OutputImageType,KernelType> FilterType; + + // Instantiating object + FilterType::Pointer filter = FilterType::New(); + + std::cout << filter << std::endl; + + return EXIT_SUCCESS; +}