From e1b9298ec20b13ca52a27fc3d950eb02369583a0 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 13 Feb 2018 14:50:06 +0100 Subject: [PATCH] BUG: fix bug comming from itk way of counting component --- .../include/otbConvertTypeFunctor.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index aa318c24ab..bc74ae4a99 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -53,8 +53,15 @@ public: unsigned int GetOutputSize( unsigned int sizeIn ) { m_CompIn = sizeIn ; - if ( m_cInPix || m_cInInternalPix ) + if ( m_cInInternalPix ) m_Scal = 2 * m_CompIn; + else if ( m_cInPix ) + { + // needed as ITK thinks that one complex component is actually + // two components... + m_CompIn /= 2 ; + m_Scal = 2 * m_CompIn; + } else m_Scal = m_CompIn; if ( m_cOutInternalPix ) @@ -102,8 +109,11 @@ public: std::vector < double > vPixel; for ( unsigned int i = 0 ; i < m_CompIn ; i ++) FillIn < InputPixelType > ( i , in , vPixel ); + assert( m_Scal == vPixel.size() ); if ( ( m_cOutPix || m_cOutInternalPix ) && vPixel.size()%2 ) + { vPixel.push_back(0); // last component has no imaginary part + } Clamp( vPixel ); OutputPixelType out; int hack = 1; @@ -155,7 +165,6 @@ protected: void Clamp( std::vector < double > & vPixel ) const { - assert( m_Scal == vPixel.size() ); for ( double & comp : vPixel ) { if ( comp >= m_HighestBD ) -- GitLab