From 462418d7a5500df0310b6c4c89c9c22b4463de21 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Oct 2015 10:52:22 +0200 Subject: [PATCH] ENH: ManageNoData sets output nodata when the default value 0 is used --- .../AppImageUtils/app/otbManageNoData.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx index cbe994926d..fa327c4a6d 100644 --- a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx +++ b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx @@ -23,6 +23,7 @@ #include "itkMaskImageFilter.h" #include "otbVectorImageToImageListFilter.h" #include "otbImageListToVectorImageFilter.h" +#include "otbChangeInformationImageFilter.h" namespace otb { @@ -51,6 +52,7 @@ public: typedef otb::VectorImageToImageListFilter<FloatVectorImageType,ImageListType> VectorToListFilterType; typedef otb::ImageListToVectorImageFilter<ImageListType,FloatVectorImageType> ListToVectorFilterType; typedef itk::MaskImageFilter<FloatImageType,UInt8ImageType,FloatImageType> MaskFilterType; + typedef otb::ChangeInformationImageFilter<FloatVectorImageType> ChangeInfoFilterType; private: void DoInit() @@ -185,13 +187,18 @@ private: } m_L2V = ListToVectorFilterType::New(); m_L2V->SetInput(outputList); - - itk::MetaDataDictionary &outDict = m_L2V->GetOutput()->GetMetaDataDictionary(); if (!ret) { - otb::WriteNoDataFlags(flags,values,outDict); + m_MetaDataChanger = ChangeInfoFilterType::New(); + m_MetaDataChanger->SetInput(m_L2V->GetOutput()); + m_MetaDataChanger->SetOutputMetaData<std::vector<bool> >(otb::MetaDataKey::NoDataValueAvailable,&flags); + m_MetaDataChanger->SetOutputMetaData<std::vector<double> >(otb::MetaDataKey::NoDataValue,&values); + SetParameterOutputImage("out",m_MetaDataChanger->GetOutput()); + } + else + { + SetParameterOutputImage("out",m_L2V->GetOutput()); } - SetParameterOutputImage("out",m_L2V->GetOutput()); } } @@ -200,6 +207,7 @@ private: std::vector<MaskFilterType::Pointer> m_MaskFilters; VectorToListFilterType::Pointer m_V2L; ListToVectorFilterType::Pointer m_L2V; + ChangeInfoFilterType::Pointer m_MetaDataChanger; }; } -- GitLab