<div>Hi Robert. Thank you. I also have now done more or less like that. I have a slight problem however, and this is when i try to transfer data from the vnl_matrix to a vtkImage. I do the following:</div>
<div> </div>
<p>vtkImageData* importData(SDMdatatype *data1,int *dims){<br> vtkImageImport *importer = vtkImageImport::New();<br> importer->SetDataScalarTypeToFloat();<br> importer->SetDataOrigin(0,0,0);<br> importer->SetImportVoidPointer(data1);
<br> <br> importer->SetWholeExtent(0,dims[0]-1,0,dims[1]-1,0,dims[2]-1);//If not 3D image set 3D extent = 0.<br> importer->SetDataExtentToWholeExtent();</p>
<p> importer->Update();</p>
<p> vtkImageData *img=importer->GetOutput();<br> img->Update();<br> return img;<br>}</p>
<div>I do the following when calling this function:</div>
<div> </div>
<div>vtkImageData *Temporopolar_region_left_data= importData(*(meanShape.extract(N,1, 0*N,0).data_array()),D);<br><br>where meanShape is my vnl_matrix</div>
<div> </div>
<div> </div>
<div>I know that the matrix meanShape contains correct data, but when i have called the importData data function, and on the returned vtkImageData object call the function </div>
<div> </div>
<div>SDMdatatype* a = (SDMdatatype*)Temporopolar_region_left_data->GetScalarPointer();</div>
<div> </div>
<div>a null pointer is returned. Am I missing something ?</div>
<div>Thank you for your help.</div>
<div>Regards</div>
<div> </div>
<div><span class="gmail_quote">2007/1/12, Atwood, Robert C <<a href="mailto:r.atwood@imperial.ac.uk">r.atwood@imperial.ac.uk</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Here's how I've done it (details of inputting the matrix data omitted<br>since it's all in 'c' rather than 'c++')
<br><br>#include <vnl/vnl_matrix_fixed.h><br>#include <vnl/vnl_matrix.h><br>#include <vnl/vnl_vector.h><br>#include <vnl/algo/vnl_symmetric_eigensystem.h><br>#include <vnl/algo/vnl_svd.h><br>
#include <stdio.h><br>....<br><br>typedef vnl_matrix<double> Mx;<br>void read_data (FILE * datfile,double ** data,unsigned int * r, unsigned<br>int *c);<br><br>....<br> Mx *p;<br> double * data;<br> unsigned int r,c;
<br> FILE * datfile;<br><br>....<br>/*call routine that gets values of r and c, and allocates and fills data<br>with rxc values */<br> read_data(datfile,&data, &r, &c);<br><br> p=new Mx(r,c);<br> p->set(data);
<br><br><br><br>> -----Original Message-----<br>> From: insight-users-bounces+r.atwood=<a href="mailto:imperial.ac.uk@itk.org">imperial.ac.uk@itk.org</a><br>> [mailto:<a href="mailto:insight-users-bounces+r.atwood=imperial.ac.uk@itk.org">
insight-users-bounces+r.atwood=imperial.ac.uk@itk.org</a>]<br>> On Behalf Of Arne Hansen<br>> Sent: 12 January 2007 08:58<br>> To: insight-users<br>> Subject: [Insight-users] Using an existing datapointer for vnl_matrix
<br>><br>> Hello. I have loaded a matrix from a binary file using<br>> standard c++ fstream. I allocated the memory using new, and<br>> have a pointer pointing at it. Now i want to use this data in<br>> a vnl-matrix. How can i do that?
<br>><br>> If there is an example i would appreciate it.<br>><br>> Thank you<br>><br></blockquote></div><br>