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

REFAC: use ImageMetadata instead of itk dictionary to manage NoData in the...

REFAC: use ImageMetadata instead of itk dictionary to manage NoData in the applymask mode of ManageNoData
parent 6537b312
......@@ -26,7 +26,6 @@
#include "itkMaskImageFilter.h"
#include "otbVectorImageToImageListFilter.h"
#include "otbImageListToVectorImageFilter.h"
#include "otbChangeInformationImageFilter.h"
namespace otb
{
......@@ -55,7 +54,6 @@ 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() override
......@@ -168,8 +166,8 @@ private:
bool ret = otb::ReadNoDataFlags(imd, flags, values);
if (!ret)
{
flags.resize(nbBands, true);
values.resize(nbBands, GetParameterFloat("mode.apply.ndval"));
flags = std::vector<bool>(nbBands, true);
values = std::vector<double>(nbBands, GetParameterFloat("mode.apply.ndval"));
}
m_V2L = VectorToListFilterType::New();
......@@ -198,16 +196,11 @@ private:
m_L2V->SetInput(outputList);
if (!ret)
{
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());
// write the new NoData values in the output metadata (mode.apply.ndval)
m_L2V->UpdateOutputInformation();
otb::WriteNoDataFlags(flags, values, m_L2V->GetOutput()->GetImageMetadata());
}
SetParameterOutputImage("out", m_L2V->GetOutput());
}
}
......@@ -216,7 +209,6 @@ private:
std::vector<MaskFilterType::Pointer> m_MaskFilters;
VectorToListFilterType::Pointer m_V2L;
ListToVectorFilterType::Pointer m_L2V;
ChangeInfoFilterType::Pointer m_MetaDataChanger;
};
}
}
......
Markdown is supported
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