From 14937e6e24c89befc65a67ca4a5aee1cd6011c0e Mon Sep 17 00:00:00 2001 From: Jonathan Guinet <jonathan.guinet@c-s.fr> Date: Tue, 29 May 2012 18:16:25 +0200 Subject: [PATCH] ENH: Example update. --- Examples/Segmentation/CMakeLists.txt | 17 +++++++++- .../StreamingMeanShiftSegmentation.cxx | 33 +++++++++++++------ .../otbSegmentationExamplesTests.cxx | 5 +++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Examples/Segmentation/CMakeLists.txt b/Examples/Segmentation/CMakeLists.txt index 148f11967d..736e1a2b56 100644 --- a/Examples/Segmentation/CMakeLists.txt +++ b/Examples/Segmentation/CMakeLists.txt @@ -415,8 +415,23 @@ ADD_TEST(seTeLabelizeNeighborhoodConnectedImageFilterTest ${EXE_TESTS} 80 80 ) + +# ------- StreamingMeanShiftSegmentationTest ---------- + +ADD_TEST(seTeStreamingMeanShiftSegmentationTest ${EXE_TESTS} + # --compare-ogr ${NOTOL} + # ${BASELINE_FILES}/seTeStreamingMeanShiftSegmentationTest.shp + # ${TEMP}/seTeStreamingMeanShiftSegmentationTest.shp + StreamingMeanShiftSegmentationTest + ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + ${TEMP}/seTeStreamingMeanShiftSegmentationTest.shp +) + + + + INCLUDE_DIRECTORIES(${OTB_SOURCE_DIR}/Testing/Code) ADD_EXECUTABLE(otbSegmentationExamplesTests otbSegmentationExamplesTests.cxx) -TARGET_LINK_LIBRARIES(otbSegmentationExamplesTests ITKAlgorithms ITKStatistics OTBBasicFilters OTBCommon OTBDisparityMap OTBIO OTBSpatialReasoning OTBChangeDetection OTBFeatureExtraction OTBLearning OTBMultiScale OTBTesting) +TARGET_LINK_LIBRARIES(otbSegmentationExamplesTests ITKAlgorithms ITKStatistics OTBBasicFilters OTBCommon OTBDisparityMap OTBOGRAdapters OTBIO OTBSpatialReasoning OTBChangeDetection OTBFeatureExtraction OTBLearning OTBMultiScale OTBTesting) ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx b/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx index 460f0e7c88..87ad4617b5 100644 --- a/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx +++ b/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx @@ -34,11 +34,11 @@ #include <iostream> // Software Guide : BeginCodeSnippet -#include "otbMeanShiftImageFilter.h" #include "otbStreamingVectorizedSegmentationOGR.h" +#include "otbMeanShiftSegmentationFilter.h" // Software Guide : EndCodeSnippet -#include "otbImage.h" +#include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbVectorDataFileWriter.h" #include "otbVectorData.h" @@ -47,12 +47,12 @@ int main(int argc, char *argv[]) { - if (argc < 3) + if (argc < 2) { std::cerr << "Missing Parameters " << std::endl; std::cerr << "Usage: " << argv[0]; std::cerr << - " inputImage outputVectorData nbLinePerStream " + " inputImage outputVectorData " << std::endl; return 1; } @@ -64,8 +64,11 @@ int main(int argc, char *argv[]) // Software Guide : BeginCodeSnippet typedef float InputPixelType; + typedef unsigned int LabelPixelType; + const unsigned int Dimension = 2; - typedef otb::Image<InputPixelType, Dimension> ImageType; + typedef otb::VectorImage<InputPixelType, Dimension> ImageType; + typedef otb::Image<LabelPixelType, Dimension> LabelImageType; typedef otb::VectorData<double, 2> VectorDataType; // Software Guide : EndCodeSnippet @@ -86,8 +89,13 @@ int main(int argc, char *argv[]) // Typedefs // Software Guide : BeginCodeSnippet - typedef otb::MeanShiftImageFilter<ImageType, ImageType> MeanShiftImageFilterType; - typedef otb::StreamingVectorizedSegmentationOGR<ImageType, MeanShiftImageFilterType> StreamingVectorizedSegmentationType; + + //typedef otb::MeanShiftSmoothingImageFilter<ImageType, ImageType> MeanShiftImageFilterType; + typedef otb::MeanShiftSegmentationFilter <ImageType,LabelImageType,ImageType> MeanShiftSegmentationFilterType; + + + + typedef otb::StreamingVectorizedSegmentationOGR<ImageType, MeanShiftSegmentationFilterType> StreamingVectorizedSegmentationType; // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -132,9 +140,14 @@ int main(int argc, char *argv[]) filter->SetStartLabel(1); filter->SetUse8Connected(false); - filter->GetSegmentationFilter()->SetSpatialRadius(10); - filter->GetSegmentationFilter()->SetRangeRadius(15); - filter->GetSegmentationFilter()->SetMinimumRegionSize(400); + //filter->GetSegmentationFilter()->SetSpatialRadius(10); + //filter->GetSegmentationFilter()->SetRangeRadius(15); + //filter->GetSegmentationFilter()->SetMinimumRegionSize(400); + + filter->GetSegmentationFilter()->SetSpatialBandwidth(10); + filter->GetSegmentationFilter()->SetRangeBandwidth(15); + filter->SetFilterSmallObject(true); + filter->SetMinimumObjectSize(400); filter->Initialize(); diff --git a/Examples/Segmentation/otbSegmentationExamplesTests.cxx b/Examples/Segmentation/otbSegmentationExamplesTests.cxx index 06be697e41..94418532f5 100644 --- a/Examples/Segmentation/otbSegmentationExamplesTests.cxx +++ b/Examples/Segmentation/otbSegmentationExamplesTests.cxx @@ -33,8 +33,13 @@ void RegisterTests() REGISTER_TEST(ConnectedThresholdImageFilterTest); REGISTER_TEST(OtsuMultipleThresholdImageFilterTest); REGISTER_TEST(LabelizeNeighborhoodConnectedImageFilterTest); + REGISTER_TEST(StreamingMeanShiftSegmentationTest); } +#undef main +#define main StreamingMeanShiftSegmentationTest +#include "StreamingMeanShiftSegmentation.cxx" + #undef main #define main IsolatedConnectedImageFilterTest #include "IsolatedConnectedImageFilter.cxx" -- GitLab