Skip to content
Snippets Groups Projects
Commit 6bff76f3 authored by Rémi Cresson's avatar Rémi Cresson
Browse files

FIX: nodata now only in labelimage mode

parent 0bd6b93d
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ public:
typedef itk::SmartPointer<const Self> ConstPointer;
/* Typedefs */
typedef UInt32ImageType LabelImageType;
typedef Int32ImageType LabelImageType;
typedef LabelImageType::ValueType LabelValueType;
typedef otb::VectorData<double, 2> VectorDataType;
typedef otb::VectorDataIntoImageProjectionFilter<VectorDataType,
......@@ -107,12 +107,11 @@ public:
// Input for label image mode
AddParameter(ParameterType_InputImage, "mode.labelimage.in", "Input label image");
AddParameter(ParameterType_Int, "mode.labelimage.nodata", "No-data value for the input label image");
SetDefaultParameterInt ("mode.labelimage.nodata", 0);
MandatoryOff ("mode.labelimage.nodata");
AddParameter(ParameterType_InputImage, "mode.labelimage.outxml", "Output XML file");
// No data value
AddParameter(ParameterType_Float, "nodata", "No-data value");
MandatoryOff("nodata");
AddRAMParameter();
// Doc example parameter settings
......@@ -152,20 +151,6 @@ public:
// Get input image
FloatVectorImageType::Pointer img = GetParameterImage("in");
// Instantiate objects that are used by both processing modes
// No-data
FloatVectorImageType::InternalPixelType m_InputNoData = 0;
const bool has_nodata = HasValue("nodata");
if (has_nodata)
{
m_InputNoData = GetParameterFloat("nodata");
otbAppLogINFO("Using no-data value: " << m_InputNoData);
}
// Internal no-data value
const LabelValueType intNoData = itk::NumericTraits<LabelValueType>::max();
// Statistics filter
m_StatsFilter = StatsFilterType::New();
m_StatsFilter->SetInput(img);
......@@ -196,6 +181,9 @@ public:
m_VectorDataSrc = shp;
}
// Internal no-data value
const LabelValueType intNoData = itk::NumericTraits<LabelValueType>::max();
// Rasterize vector data
m_RasterizeFilter = RasterizeFilterType::New();
m_RasterizeFilter->AddVectorData(m_VectorDataSrc);
......@@ -204,7 +192,7 @@ public:
m_RasterizeFilter->SetOutputSize(img->GetLargestPossibleRegion().GetSize());
m_RasterizeFilter->SetOutputProjectionRef(img->GetProjectionRef());
m_RasterizeFilter->SetBurnAttribute("________");
m_RasterizeFilter->SetDefaultBurnValue(0);
m_RasterizeFilter->SetDefaultBurnValue(intNoData);
m_RasterizeFilter->SetGlobalWarningDisplay(false);
m_RasterizeFilter->SetBackgroundValue(intNoData);
......@@ -272,7 +260,7 @@ public:
otbAppLogINFO("Processing mode: label image");
// Computing stats
m_StatsFilter->SetInputLabelImage(GetParameterUInt32Image("mode.labelimage.in"));
m_StatsFilter->SetInputLabelImage(GetParameterInt32Image("mode.labelimage.in"));
m_StatsFilter->Update();
// Remove the no-data entry
......@@ -281,11 +269,19 @@ public:
StatsFilterType::PixelValueMapType stdMap = m_StatsFilter->GetStandardDeviationValueMap();
StatsFilterType::PixelValueMapType minMap = m_StatsFilter->GetMinValueMap();
StatsFilterType::PixelValueMapType maxMap = m_StatsFilter->GetMaxValueMap();
countMap.erase(intNoData);
meanMap.erase(intNoData);
stdMap.erase(intNoData);
minMap.erase(intNoData);
maxMap.erase(intNoData);
if (HasUserValue("mode.labelimage.nodata"))
{
// Internal no-data value
const LabelValueType intNoData = GetParameterInt("mode.labelimage.nodata");
otbAppLogINFO("Using no-data value: " << intNoData);
countMap.erase(intNoData);
meanMap.erase(intNoData);
stdMap.erase(intNoData);
minMap.erase(intNoData);
maxMap.erase(intNoData);
}
// Write stats
const std::string outXMLFile = this->GetParameterString("mode.labelimage.outxml");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment