diff --git a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h index 4ebdfce5c43e1299bb7195712b8ad2df55b1e3c9..3b44ec0bedd6295fc0491fec6942d03ba10b9d87 100644 --- a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h +++ b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h @@ -93,6 +93,8 @@ protected: */ virtual void GenerateInputRequestedRegion(); + virtual void GenerateOutputInformation(); + /** * Re-implement the method ThreadedGenerateData to mask area outside the deformation grid */ diff --git a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx index a3e9972a3b5117584e0b984f6c3d0cdf0ec9f693..19ba9ff358c2f35ac314090048b0605b6a08e66f 100644 --- a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx +++ b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.txx @@ -23,6 +23,9 @@ #include "otbStreamingWarpImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" +#include "itkDefaultConvertPixelTraits.h" +#include "itkMetaDataObject.h" +#include "otbMetaDataKey.h" namespace otb { @@ -202,6 +205,40 @@ StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> } +template<class TInputImage, class TOutputImage, class TDisplacementField> +void +StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> +::GenerateOutputInformation() +{ + Superclass::GenerateOutputInformation(); + + // Set the NoData flag to the edge padding value + itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary(); + std::vector<bool> noDataValueAvailable; + bool ret = itk::ExposeMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + if (!ret) + { + noDataValueAvailable.resize(this->GetOutput()->GetNumberOfComponentsPerPixel(),false); + } + std::vector<double> noDataValue; + ret = itk::ExposeMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); + if (!ret) + { + noDataValue.resize(this->GetOutput()->GetNumberOfComponentsPerPixel(),0.0); + } + PixelType edgePadding = this->GetEdgePaddingValue(); + for (unsigned int i=0; i<noDataValueAvailable.size() ; ++i) + { + if (!noDataValueAvailable[i]) + { + noDataValueAvailable[i] = true; + noDataValue[i] = itk::DefaultConvertPixelTraits<PixelType>::GetNthComponent(i,edgePadding); + } + } + itk::EncapsulateMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + itk::EncapsulateMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); +} + template<class TInputImage, class TOutputImage, class TDisplacementField> void StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> diff --git a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h index 39d04f689ad6bb90b695073cb6a4a32c9b8e6685..ce25b90ecedb1db3c54530bac7ffd8b0d9f3bfe7 100644 --- a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h +++ b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h @@ -164,6 +164,7 @@ protected: const KernelIteratorType kernelBegin, const KernelIteratorType kernelEnd); + virtual void GenerateOutputInformation(); private: NeighborhoodMajorityVotingImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx index 2889cf1d861de2ec69193924e94da97db67d565c..93c05d6b2034c637528cfaecec84e7e69a9fc89b 100644 --- a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx +++ b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.txx @@ -23,6 +23,9 @@ // gets integrated into the main directories. #include "otbNeighborhoodMajorityVotingImageFilter.h" +#include "itkDefaultConvertPixelTraits.h" +#include "itkMetaDataObject.h" +#include "otbMetaDataKey.h" namespace otb { @@ -118,6 +121,30 @@ const KernelIteratorType kernelEnd) return majorityLabel; } +template<class TInputImage, class TOutputImage, class TKernel> +void +NeighborhoodMajorityVotingImageFilter<TInputImage, TOutputImage, TKernel> +::GenerateOutputInformation() +{ + Superclass::GenerateOutputInformation(); + + TOutputImage* outputPtr = this->GetOutput(); + + // Set the NoData value using the background + const unsigned int & nbBands = outputPtr->GetNumberOfComponentsPerPixel(); + std::vector<bool> noDataValueAvailable; + noDataValueAvailable.resize(nbBands,true); + std::vector<double> noDataValue; + noDataValue.resize(nbBands,0.0); + for (unsigned int i=0 ; i<nbBands ; ++i) + { + noDataValue[i] = itk::DefaultConvertPixelTraits<PixelType>::GetNthComponent(i,m_LabelForNoDataPixels); + } + itk::MetaDataDictionary& dict = outputPtr->GetMetaDataDictionary(); + itk::EncapsulateMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + itk::EncapsulateMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); +} + } // end namespace otb #endif diff --git a/Modules/Fusion/MajorityVoting/otb-module.cmake b/Modules/Fusion/MajorityVoting/otb-module.cmake index bc585bf62a7088aa2ca551d384bcc6f9d011b36b..8643c503476f640fd87ad82754cfb97720c56a8b 100644 --- a/Modules/Fusion/MajorityVoting/otb-module.cmake +++ b/Modules/Fusion/MajorityVoting/otb-module.cmake @@ -5,6 +5,7 @@ this label value (see also DempsterShafer module).") otb_module(OTBMajorityVoting DEPENDS OTBITK + OTBOSSIMAdapters TEST_DEPENDS OTBTestKernel diff --git a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h index 2c3810858082feca40b6b6296f7df821aa1fa964..84b093f8c167c6985890be5a9e9c888b4dd2c8d6 100644 --- a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h +++ b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h @@ -139,6 +139,8 @@ protected: /** Destructor */ virtual ~DSFusionOfClassifiersImageFilter() {} + /** Generate output information */ + virtual void GenerateOutputInformation(); /** Threaded generate data */ virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); /** Before threaded generate data */ diff --git a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.txx b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.txx index 65c577151dec44cbe7000adf8facf2b398c1891c..5305fa3d368444bf63e6e70cfbc630c11d51436d 100644 --- a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.txx +++ b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.txx @@ -22,6 +22,9 @@ #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" +#include "itkMetaDataObject.h" +#include "otbMetaDataKey.h" + namespace otb { /** @@ -84,6 +87,23 @@ DSFusionOfClassifiersImageFilter<TInputImage, TOutputImage, TMaskImage> } /* ************************************************************************************************************** */ +template <class TInputImage, class TOutputImage, class TMaskImage> +void +DSFusionOfClassifiersImageFilter<TInputImage, TOutputImage, TMaskImage> +::GenerateOutputInformation() +{ + Superclass::GenerateOutputInformation(); + + // Set the NoData value + std::vector<bool> noDataValueAvailable; + noDataValueAvailable.push_back(true); + std::vector<double> noDataValue; + noDataValue.push_back(m_LabelForNoDataPixels); + itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary(); + itk::EncapsulateMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + itk::EncapsulateMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); +} +/* ************************************************************************************************************** */ template <class TInputImage, class TOutputImage, class TMaskImage> void diff --git a/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.txx b/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.txx index 2a0932c883e1c023d439b12bc7cb2b641943ae19..afd59f1caf21033f43f0f4cc8f4449f69a63b389 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.txx +++ b/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.txx @@ -205,6 +205,18 @@ DisparityTranslateFilter<TDisparityImage,TGridImage,TSensorImage,TMaskImage> horizOut->CopyInformation(leftIn); vertiOut->CopyInformation(leftIn); + + // Set the NoData value + std::vector<bool> noDataValueAvailable; + noDataValueAvailable.push_back(true); + std::vector<double> noDataValue; + noDataValue.push_back(m_NoDataValue); + itk::MetaDataDictionary& dict = horizOut->GetMetaDataDictionary(); + itk::EncapsulateMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + itk::EncapsulateMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); + dict = vertiOut->GetMetaDataDictionary(); + itk::EncapsulateMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + itk::EncapsulateMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); } template <class TDisparityImage, class TGridImage, class TSensorImage, class TMaskImage> diff --git a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx index 2c7a851f0446e45ca7ad3dbe0b47e8357d4a6af7..515161f4bb580acd054c6996fc7da7b9e1c24fdf 100644 --- a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx +++ b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.txx @@ -337,7 +337,14 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::GenerateOutpu m_IsGeographic = oSRS.IsGeographic(); // TODO check if this test is valid for all projection systems } - + // Set the NoData value + std::vector<bool> noDataValueAvailable; + noDataValueAvailable.push_back(true); + std::vector<double> noDataValue; + noDataValue.push_back(m_NoDataValue); + itk::MetaDataDictionary& dict = outputPtr->GetMetaDataDictionary(); + itk::EncapsulateMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + itk::EncapsulateMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); } template<class T3DImage, class TMaskImage, class TOutputDEMImage> diff --git a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx index 997c4cb1382dc0c4b9b4f19545a7530f2407d79d..69b8e325f45c80d0dc20259fe885037e2f396c1c 100644 --- a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx +++ b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx @@ -20,6 +20,8 @@ #include "otbOGRIOHelper.h" #include "otbGdalDataTypeBridge.h" #include "otbImageMetadataInterfaceFactory.h" +#include "itkMetaDataObject.h" +#include "otbMetaDataKey.h" #include "gdal_alg.h" #include "stdint.h" //needed for uintptr_t @@ -164,6 +166,15 @@ OGRDataSourceToLabelImageFilter<TOutputImage> m_SrcDataSetLayers.push_back( &(ogrDS->GetLayer(layer).ogr()) ); } } + + // Set the NoData value using the background + const unsigned int & nbBands = outputPtr->GetNumberOfComponentsPerPixel(); + std::vector<bool> noDataValueAvailable; + noDataValueAvailable.resize(nbBands,true); + std::vector<double> noDataValue; + noDataValue.resize(nbBands,static_cast<double>(m_BackgroundValue)); + itk::EncapsulateMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); + itk::EncapsulateMetaData<std::vector<double> >(dict,MetaDataKey::NoDataValue,noDataValue); } template< class TOutputImage>