Skip to content
Snippets Groups Projects
Commit 05536716 authored by Jonathan Guinet's avatar Jonathan Guinet
Browse files

ENH imageMatrixFilter can handle non square matrix.

parent 28bb4f40
No related branches found
No related tags found
No related merge requests found
......@@ -25,11 +25,11 @@ namespace otb
{
/** \class MatrixImageFilter
* \brief Apply a transition matric over the channel of an image.
* \brief Apply a transition matrix over the channel of an image.
*
* The templates are the input and putput image type.
* The transition matrix is giver using the SetTransitionMatrix() method. The waiting type is a vnl_matrix<double> (ie. MatrixType).
* The number of columns of the matrix must be the input image number of channels, the number of rows is the number of channels of the output image.
* The templates are the input and output image type.
* The transition matrix is given using the SetTransitionMatrix() method. The waiting type is a vnl_matrix<double> (ie. MatrixType).
* The number of rows of the matrix must be the input image number of channels, the number of columns is the number of channels of the output image.
*
* For example, if the image has 2 bands, the matrix is \f$ \begin{pmatrix} \alpha & \beta \\ \gama & \delta \end{pmatrix} \f$
* The pixel \f$ [a, b] \f$ will give the output pixel \f$ [\alpha.a + \beta.b, \gamma.a + \delta.b ]. \f$
......
......@@ -74,9 +74,10 @@ void MatrixImageFilter<TInputImage, TOutputImage, TMatrix>::ThreadedGenerateData
inIt.GoToBegin();
outIt.GoToBegin();
const unsigned int outSize = m_Matrix.rows();
const unsigned int inSize = m_Matrix.rows();
const unsigned int outSize = m_Matrix.cols();
VectorType inVect(outSize, InputRealType(0.));
VectorType inVect(inSize, InputRealType(0.));
VectorType outVect(outSize, InputRealType(0.));
while (!outIt.IsAtEnd())
......@@ -85,7 +86,7 @@ void MatrixImageFilter<TInputImage, TOutputImage, TMatrix>::ThreadedGenerateData
OutputPixelType outPix;
outPix.SetSize(outSize);
for(unsigned int i=0; i<outSize; i++)
for(unsigned int i=0; i<inSize; i++)
{
inVect[i] = static_cast<InputRealType>(inPix[i]);
}
......@@ -105,6 +106,8 @@ void MatrixImageFilter<TInputImage, TOutputImage, TMatrix>::ThreadedGenerateData
}
/**
* Standard "PrintSelf" method
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment