18 #ifndef __otbMatrixImageFilter_txx
19 #define __otbMatrixImageFilter_txx
32 template <
class TInputImage,
class TOutputImage,
class TMatrix>
37 template <
class TInputImage,
class TOutputImage,
class TMatrix>
41 Superclass::GenerateOutputInformation();
43 if ( m_MatrixByVector )
45 if( this->GetInput()->GetNumberOfComponentsPerPixel() != m_Matrix.cols() )
47 itkExceptionMacro(
"Invalid Matrix size. Number of columns must be the same as the image number of channels.");
50 if( m_Matrix.rows() == 0 )
52 itkExceptionMacro(
"Invalid Matrix size. Number of rows can't be null.");
54 this->GetOutput()->SetNumberOfComponentsPerPixel( m_Matrix.rows() );
57 if ( !m_MatrixByVector )
59 if( this->GetInput()->GetNumberOfComponentsPerPixel() != m_Matrix.rows() )
61 itkExceptionMacro(
"Invalid Matrix size. Number of rows must be the same as the image number of channels.");
64 if( m_Matrix.cols() == 0 )
66 itkExceptionMacro(
"Invalid Matrix size. Number of columns can't be null.");
68 this->GetOutput()->SetNumberOfComponentsPerPixel( m_Matrix.cols() );
72 template<
class TInputImage,
class TOutputImage,
class TMatrix>
79 typename OutputImageType::Pointer outputPtr = this->GetOutput();
80 typename InputImageType::ConstPointer inputPtr = this->GetInput();
92 const unsigned int inSize = m_MatrixByVector ? m_Matrix.cols() : m_Matrix.rows();
93 const unsigned int outSize = m_MatrixByVector ? m_Matrix.rows() : m_Matrix.cols();
102 outPix.SetSize(outSize);
104 for(
unsigned int i=0; i<inSize; ++i)
109 outVect = m_MatrixByVector ? m_Matrix*inVect : inVect*m_Matrix;
111 for(
unsigned int i=0; i<outSize; ++i)
119 progress.CompletedPixel();
127 template <
class TInputImage,
class TOutputImage,
class TMatrix>
131 Superclass::PrintSelf(os, indent);
132 os << indent <<
"Matrix: " << m_Matrix << std::endl;
133 os << indent <<
"MatrixByVector: " << m_MatrixByVector << std::endl;