Commit b5de303e authored by Cédric Traizet's avatar Cédric Traizet
Browse files

Merge branch '1860_multiband_watershed_crash' into 'develop'

No data documentation in Segmentation

See merge request orfeotoolbox/otb!440
No related merge requests found
Showing with 27 additions and 14 deletions
+27 -14
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
//Utils //Utils
#include "itksys/SystemTools.hxx" #include "itksys/SystemTools.hxx"
#include "otbNoDataHelper.h"
namespace otb namespace otb
{ {
...@@ -165,10 +166,11 @@ private: ...@@ -165,10 +166,11 @@ private:
SetDocLimitations("In raster mode, the application can not handle large input images. Stitching step of vector mode might become slow with very large input images." SetDocLimitations("In raster mode, the application can not handle large input images. Stitching step of vector mode might become slow with very large input images."
" \nMeanShift filter results depends on the number of threads used. \nWatershed and multiscale geodesic morphology segmentation will be performed on the amplitude " " \nMeanShift filter results depends on the number of threads used. \nWatershed and multiscale geodesic morphology segmentation will be performed on the amplitude "
" of the input image."); " of the input image. \nThis application does not handle no data values. No data pixels will be treated as regular pixels,"
" This may lead to unexpected segmentation results and crashes.");
SetDocAuthors("OTB-Team"); SetDocAuthors("OTB-Team");
SetDocSeeAlso("MeanShiftSegmentation"); SetDocSeeAlso("LargeScaleMeanShift");
AddDocTag(Tags::Segmentation); AddDocTag(Tags::Segmentation);
...@@ -375,7 +377,7 @@ private: ...@@ -375,7 +377,7 @@ private:
if (segModeType == "vector" && HasValue("mode.vector.inmask")) if (segModeType == "vector" && HasValue("mode.vector.inmask"))
{ {
streamingVectorizedFilter->SetInputMask(m_ClampFilter->GetOutput()); streamingVectorizedFilter->SetInputMask(m_ClampFilter->GetOutput());
otbAppLogINFO(<<"Use a mask as input." << std::endl); otbAppLogINFO("Use a mask as input.");
} }
streamingVectorizedFilter->SetOGRLayer(layer); streamingVectorizedFilter->SetOGRLayer(layer);
...@@ -390,13 +392,13 @@ private: ...@@ -390,13 +392,13 @@ private:
if (use8connected) if (use8connected)
{ {
otbAppLogINFO(<<"Use 8 connected neighborhood."<<std::endl); otbAppLogINFO("Use 8 connected neighborhood.");
} }
streamingVectorizedFilter->SetUse8Connected(use8connected); streamingVectorizedFilter->SetUse8Connected(use8connected);
if (minSize > 1) if (minSize > 1)
{ {
otbAppLogINFO(<<"Object with size under "<< minSize <<" will be suppressed."<<std::endl); otbAppLogINFO(<<"Object with size under "<< minSize <<" will be suppressed.");
streamingVectorizedFilter->SetFilterSmallObject(true); streamingVectorizedFilter->SetFilterSmallObject(true);
streamingVectorizedFilter->SetMinimumObjectSize(minSize); streamingVectorizedFilter->SetMinimumObjectSize(minSize);
} }
...@@ -413,7 +415,7 @@ private: ...@@ -413,7 +415,7 @@ private:
{ {
streamingVectorizedFilter->SetSimplify(true); streamingVectorizedFilter->SetSimplify(true);
streamingVectorizedFilter->SetSimplificationTolerance(GetParameterFloat("mode.vector.simplify")); streamingVectorizedFilter->SetSimplificationTolerance(GetParameterFloat("mode.vector.simplify"));
otbAppLogINFO(<<"Simplify the geometry." << std::endl); otbAppLogINFO("Simplify the geometry.");
} }
else else
{ {
...@@ -422,7 +424,7 @@ private: ...@@ -422,7 +424,7 @@ private:
if (segModeType == "vector") if (segModeType == "vector")
{ {
otbAppLogINFO(<<"Large scale segmentation mode which output vector data" << std::endl); otbAppLogINFO("Large scale segmentation mode which output vector data");
DisableParameter("mode.raster.out"); DisableParameter("mode.raster.out");
EnableParameter("mode.vector.out"); EnableParameter("mode.vector.out");
...@@ -436,7 +438,7 @@ private: ...@@ -436,7 +438,7 @@ private:
} }
else if (segModeType == "raster") else if (segModeType == "raster")
{ {
otbAppLogINFO(<<"Segmentation mode which output label image" << std::endl); otbAppLogINFO("Segmentation mode which output label image.");
DisableParameter("mode.vector.out"); DisableParameter("mode.vector.out");
EnableParameter("mode.raster.out"); EnableParameter("mode.raster.out");
...@@ -467,6 +469,17 @@ private: ...@@ -467,6 +469,17 @@ private:
std::string projRef = GetParameterFloatVectorImage("in")->GetProjectionRef(); std::string projRef = GetParameterFloatVectorImage("in")->GetProjectionRef();
std::vector<bool> noDataFlags;
std::vector<double> noDataValues;
itk::MetaDataDictionary &dict = GetParameterFloatVectorImage("in")->GetMetaDataDictionary();
bool ret = otb::ReadNoDataFlags(dict,noDataFlags,noDataValues);
if (ret)
{
otbAppLogWARNING("The input image has no data values but this application does not handle no-data. No-data pixels"
" will be treated as regular pixels.");
}
OGRSpatialReference oSRS(projRef.c_str()); OGRSpatialReference oSRS(projRef.c_str());
if (segModeType == "vector") if (segModeType == "vector")
...@@ -562,7 +575,7 @@ private: ...@@ -562,7 +575,7 @@ private:
if (segType == "cc") if (segType == "cc")
{ {
otbAppLogINFO(<<"Use connected component segmentation."<<std::endl); otbAppLogINFO("Use connected component segmentation.");
ConnectedComponentStreamingVectorizedSegmentationOGRType::Pointer ConnectedComponentStreamingVectorizedSegmentationOGRType::Pointer
ccVectorizationFilter = ConnectedComponentStreamingVectorizedSegmentationOGRType::New(); ccVectorizationFilter = ConnectedComponentStreamingVectorizedSegmentationOGRType::New();
...@@ -581,7 +594,7 @@ private: ...@@ -581,7 +594,7 @@ private:
} }
else if (segType == "meanshift") else if (segType == "meanshift")
{ {
otbAppLogINFO(<<"Use threaded Mean-shift segmentation."<<std::endl); otbAppLogINFO("Use threaded Mean-shift segmentation.");
MeanShiftVectorizedSegmentationOGRType::Pointer MeanShiftVectorizedSegmentationOGRType::Pointer
meanShiftVectorizationFilter = MeanShiftVectorizedSegmentationOGRType::New(); meanShiftVectorizationFilter = MeanShiftVectorizedSegmentationOGRType::New();
...@@ -611,7 +624,7 @@ private: ...@@ -611,7 +624,7 @@ private:
} }
else if (segType == "watershed") else if (segType == "watershed")
{ {
otbAppLogINFO(<<"Using watershed segmentation."<<std::endl); otbAppLogINFO("Using watershed segmentation.");
AmplitudeFilterType::Pointer amplitudeFilter = AmplitudeFilterType::New(); AmplitudeFilterType::Pointer amplitudeFilter = AmplitudeFilterType::New();
...@@ -635,7 +648,7 @@ private: ...@@ -635,7 +648,7 @@ private:
} }
else if (segType == "mprofiles") else if (segType == "mprofiles")
{ {
otbAppLogINFO(<<"Using multiscale geodesic morphology segmentation."<<std::endl); otbAppLogINFO("Using multiscale geodesic morphology segmentation.");
unsigned int profileSize = GetParameterInt("filter.mprofiles.size"); unsigned int profileSize = GetParameterInt("filter.mprofiles.size");
unsigned int initialValue = GetParameterInt("filter.mprofiles.start"); unsigned int initialValue = GetParameterInt("filter.mprofiles.start");
...@@ -661,7 +674,7 @@ private: ...@@ -661,7 +674,7 @@ private:
} }
else else
{ {
otbAppLogFATAL(<<"non defined filtering method "<<GetParameterInt("filter")<<std::endl); otbAppLogFATAL(<<"non defined filtering method "<<GetParameterInt("filter"));
} }
if (segModeType == "vector") if (segModeType == "vector")
...@@ -692,7 +705,7 @@ private: ...@@ -692,7 +705,7 @@ private:
std::string driverName(ogrDS->ogr().GetDriverName()); std::string driverName(ogrDS->ogr().GetDriverName());
if ( driverName.find("ESRI Shapefile") != std::string::npos) if ( driverName.find("ESRI Shapefile") != std::string::npos)
{ {
otbAppLogINFO(<<"REPACK the Shapefile ..."<<std::endl); otbAppLogINFO("REPACK the Shapefile ...");
//In Shapefile format, the name of the DaaSource is also the name of the Layer. //In Shapefile format, the name of the DaaSource is also the name of the Layer.
std::string shpLayerName = itksys::SystemTools::GetFilenameWithoutExtension(GetParameterString("mode.vector.out")); std::string shpLayerName = itksys::SystemTools::GetFilenameWithoutExtension(GetParameterString("mode.vector.out"));
std::string repack("REPACK "); std::string repack("REPACK ");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment