[Insight-users] Re: matrix and vector
Luis Ibanez
luis . ibanez at kitware . com
Tue, 14 Oct 2003 10:19:10 -0400
Hi Bing,
"Vector" is unfortunately a term used
in too many contexts.
ITK "Vectors" are intended to represent
"Geometric Vectors", that is, the relative
position between two points in space.
itk::Vectors are *not* designed to serve as "Matlab"
vectors which are conceived in the context of linear
algebra.
Strictly speaking, a row or a column of an
itk::Matrix *IS NOT* an itk::Vector, nor
a itk::CovariantVector. You can interpret
it as such, but we couldn't put this in the
API of the itk::Matrix class.
---
You can always get a vector from a matrix with
five lines of code:
itk::Vector<float,3> vector;
for( unsigned int i=0; i<3; i++ )
{
vector[i] = matrix[row][i];
}
or the column as
itk::Vector<float,3> vector;
for( unsigned int i=0; i<3; i++ )
{
vector[i] = matrix[i][col];
}
----
Regards,
Luis
------------------
Bing Jian wrote:
> Thanks Luis.
>
> On Mon, 13 Oct 2003, Luis Ibanez wrote:
>
>
>>Hi Bing,
>>
>>(0) The operator [] in the itk::Matrix return a row of the matrix.
>> http://www . itk . org/Insight/Doxygen/html/classitk_1_1Matrix . html#a9
>> the vnl_matrix has similar access methods (with the operator[]).
>> Please look at
>> http://www . robots . ox . ac . uk/~awf/vxl/book/book_5 . html
>
>
> According to itkMatrix.h
> inline T * operator[]( unsigned int i )
> { return m_Matrix[i]; }
>
> the operator does return a row of the matrix, but not a object of
> or pointer to a vector. So I cannot apply methods of vector class
> directly.
>
>
>
>>(1) You can interpolate an image of Vector using the
>> VectorLinearInterpolateImageFunction class:
>>http://www . itk . org/Insight/Doxygen/html/classitk_1_1VectorLinearInterpolateImageFunction . html
>>
>>
>>(2) Yes,
>> You just need to write the appropriate PixelAccessor.
>>
>>
>>
>>
>>Regards,
>>
>>
>> Luis
>>
>>
>>---------------
>>Bing Jian wrote:
>>
>>>Hello,
>>>
>>> Can anybody help me following questions?
>>>
>>>(0) Is there an easy way to read/write one column or row vector
>>>of a matrix?
>>>(1) Does interpolater accept vector or matrix image as input?
>>>(2) Can we extract vector image from matrix image
>>>in the same way as VectorPixelAccessor?
>>>
>>> Thanks in advance!
>>>
>>>
>>>On Thu, 9 Oct 2003, Bing Jian wrote:
>>>
>>>
>>>
>>>>Hello,
>>>>
>>>> Is there an easy way to assign a vector to ith row or col of
>>>>matrix?
>>>> e.g.
>>>> itk::Matrix<T, m, n> A;
>>>> itk::Vector<T, n> x;
>>>> A[i] = x;
>>>>
>>>> I looked through the reference page of itk::Matrix, only found
>>>>
>>>>T * operator[] (unsigned int i)
>>>>const T * operator[] (unsigned int i) const
>>>>
>>>> So do we need to use GetVnlMatrix()?
>>>>
>>>>
>>>
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk . org
>>>http://www . itk . org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>
>>
>
>