Samuel Gerber
2017-08-08 11:56:14 UTC
I'd guess there is something funky going with vnl_matrix_fixed. From the
docs ( https://github.com/vxl/vxl/blob/master/core/vnl/vnl_matrix_fixed.h )
it says that the data resides on the stack. From your code snippet it is
not exactly clear to me who owns the data in fixed_matrix, probably image.
Might it be that image gets removed before you use the array view?
On Mon, Aug 7, 2017 at 10:27 PM, Nick Cullen via Insight-users <
docs ( https://github.com/vxl/vxl/blob/master/core/vnl/vnl_matrix_fixed.h )
it says that the data resides on the stack. From your code snippet it is
not exactly clear to me who owns the data in fixed_matrix, probably image.
Might it be that image gets removed before you use the array view?
On Mon, Aug 7, 2017 at 10:27 PM, Nick Cullen via Insight-users <
Hi Friends !!
I'm trying to use itkPyVnl directly in ITK, but I must be getting
```
typedef typename ImageType::DirectionType ImageDirectionType;
ImageDirectionType * direction = const_cast<ImageDirectionType *>(
&image->GetDirection() );
typedef typename ImageDirectionType::InternalMatrixType
DirectionInternalMatrixType;
DirectionInternalMatrixType * fixed_matrix = const_cast<DirectionInternalMatrixType
*>( &direction->GetVnlMatrix() );
const vnl_matrix<double> vnlmat1 = fixed_matrix->as_matrix();
vnl_matrix<double> * vnlmat2 = const_cast<vnl_matrix<double> *>(
&vnlmat1 );
typedef itk::PyVnl<double> PyVnlType;
PyObject * mymatrix = PyVnlType::_GetArrayViewFromVnlMatrix( vnlmat2
);
```
I've tried a million different things and have problems either 1) due to
the constness of ->as_matrix() and others or 2) due to "taking the address
of a temporary object" with ->as_matrix() ... -__-
```
vnl_matrix<double> * vnlmat = new vnl_matrix<double>;
vnlmat->set_size(2,3);
vnlmat->fill(0);
vnlmat->put(1,2,1.3);
vnlmat->put(1,0,2);
std::cout << vnlmat << std::endl;
typedef itk::PyVnl<double> PyVnlType;
PyObject * mymatrix = PyVnlType::_GetArrayViewFromVnlMatrix( vnlmat );
```
Any help above is MUCH appreciated !!!!
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
I'm trying to use itkPyVnl directly in ITK, but I must be getting
```
typedef typename ImageType::DirectionType ImageDirectionType;
ImageDirectionType * direction = const_cast<ImageDirectionType *>(
&image->GetDirection() );
typedef typename ImageDirectionType::InternalMatrixType
DirectionInternalMatrixType;
DirectionInternalMatrixType * fixed_matrix = const_cast<DirectionInternalMatrixType
*>( &direction->GetVnlMatrix() );
const vnl_matrix<double> vnlmat1 = fixed_matrix->as_matrix();
vnl_matrix<double> * vnlmat2 = const_cast<vnl_matrix<double> *>(
&vnlmat1 );
typedef itk::PyVnl<double> PyVnlType;
PyObject * mymatrix = PyVnlType::_GetArrayViewFromVnlMatrix( vnlmat2
);
```
I've tried a million different things and have problems either 1) due to
the constness of ->as_matrix() and others or 2) due to "taking the address
of a temporary object" with ->as_matrix() ... -__-
```
vnl_matrix<double> * vnlmat = new vnl_matrix<double>;
vnlmat->set_size(2,3);
vnlmat->fill(0);
vnlmat->put(1,2,1.3);
vnlmat->put(1,0,2);
std::cout << vnlmat << std::endl;
typedef itk::PyVnl<double> PyVnlType;
PyObject * mymatrix = PyVnlType::_GetArrayViewFromVnlMatrix( vnlmat );
```
Any help above is MUCH appreciated !!!!
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
--
Samuel Gerber
R&D Engineer
Kitware, Inc.
Samuel Gerber
R&D Engineer
Kitware, Inc.