21 #ifndef otbChangeNoDataValueFilter_h
22 #define otbChangeNoDataValueFilter_h
24 #include "itkUnaryFunctorImageFilter.h"
25 #include "itkMetaDataObject.h"
39 template <
typename TInputPixel,
typename TOutputPixel>
49 inline TOutputPixel
operator()(
const TInputPixel& in)
const
96 template <
typename TInputImage,
typename TOutputImage>
98 :
public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage,
99 Functor::ChangeNoDataFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
105 typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctorType>
Superclass;
122 this->GetFunctor().m_NewValues = newValues;
132 this->GetFunctor().m_NaNIsNoData = nanIsNoData;
142 Superclass::GenerateOutputInformation();
144 std::vector<bool> noDataValueAvailable;
145 std::vector<double> noDataValues;
147 bool ret =
ReadNoDataFlags(this->GetInput()->GetImageMetadata(), noDataValueAvailable, noDataValues);
151 noDataValueAvailable.resize(this->GetInput()->GetNumberOfComponentsPerPixel(),
false);
152 noDataValues.resize(this->GetInput()->GetNumberOfComponentsPerPixel(), 0);
155 this->GetFunctor().m_Flags = noDataValueAvailable;
156 this->GetFunctor().m_Values = noDataValues;
158 std::vector<bool> flags = noDataValueAvailable;
160 if ((this->GetFunctor().m_NaNIsNoData) || (!ret))
162 flags = std::vector<bool>(flags.size(),
true);
165 WriteNoDataFlags(flags, this->GetFunctor().m_NewValues, this->GetOutput()->GetImageMetadata());
Change no-data flags and values and replace them in image.
void operator=(const Self &)=delete
itk::SmartPointer< Self > Pointer
itk::SmartPointer< const Self > ConstPointer
void GenerateOutputInformation() override
void SetNewNoDataValues(std::vector< double > &newValues)
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, FunctorType > Superclass
ChangeNoDataValueFilter(const Self &)=delete
Functor::ChangeNoDataFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > FunctorType
~ChangeNoDataValueFilter() override=default
void SetNaNIsNoData(bool nanIsNoData)
ChangeNoDataValueFilter()=default
ChangeNoDataValueFilter Self
Functor used by ChangeNoDataValueFilter.
std::vector< double > m_Values
std::vector< bool > m_Flags
TOutputPixel operator()(const TInputPixel &in) const
virtual ~ChangeNoDataFunctor()=default
std::vector< double > m_NewValues
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
bool OTBMetadata_EXPORT ReadNoDataFlags(const ImageMetadata &imd, std::vector< bool > &flags, std::vector< double > &values)
void OTBMetadata_EXPORT WriteNoDataFlags(const std::vector< bool > &flags, const std::vector< double > &values, ImageMetadata &imd)
T ChangeNoData(const T &pixel, const std::vector< bool > &flags, const std::vector< double > &values, const std::vector< double > &newValues, bool nanIsNoData=false)