diff --git a/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.hxx b/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.hxx index 86f192d058720d53f584b68527a093d320236fae..a3db4b817838571c6a4dca5a626e7bff0d125c19 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.hxx +++ b/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.hxx @@ -53,6 +53,10 @@ void InnerProductPCAImageFilter<TInputImage, TOutputImage>::GenerateOutputInform this->GetOutput()->SetNumberOfComponentsPerPixel(m_NumberOfPrincipalComponentsRequired); else this->GetOutput()->SetNumberOfComponentsPerPixel(m_NumberOfPrincipalComponentsRequired + 1); + + // Band specific metadatas are not kept in the reduced space. + this->GetOutput()->SetBandImageMetadata( + ImageMetadata::ImageMetadataBandsType(this->GetOutput()->GetNumberOfComponentsPerPixel())); } /** diff --git a/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.hxx index 4cfe11e021d96852bf7f94ea23bea8d772d0fd24..89ec1e7818f24a9e4aa9c136ac9f8d000910b1b4 100644 --- a/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.hxx @@ -48,6 +48,9 @@ void PerBandVectorImageFilter<TInputImage, TOutputImage, TFilter>::GenerateOutpu m_Filter->UpdateOutputInformation(); this->GetOutput()->CopyInformation(m_Filter->GetOutput(m_OutputIndex)); this->GetOutput()->SetNumberOfComponentsPerPixel(this->GetInput()->GetNumberOfComponentsPerPixel()); + + // Override default metadata copying behavior and copy all metadata from input to output. + this->GetOutput()->SetImageMetadata(this->GetInput()->GetImageMetadata()); } }