[vtkusers] Problems with vtkImageImport

Prename Surname bsd.diverse at gmail.com
Fri Oct 20 10:56:07 EDT 2006


Hello all.
I hope i am not asking to many questions, but these import things gives me a
lot of problems.
I  have managed to get the mex-file to work, so now i can from matlab
interface to vtk, via a dll file.

But i have problems converting the input-data(which is a C-array) to a
VTKImage.

The problem is that when i try to access the data stored in my img pointer,
it seems to be empty.

It is as if the data has not been put there.
I know that the variable double *data1=mxGetPr(prhs[0]);
contains the correct data. I have checked that.

So am i missing something in the import filter?
I hope someone can help me out a little.

Thank you very much


The code i have is as follows :

void mexFunction(int nlhs, mxArray *plhs[], int nrhs,
                 const mxArray *prhs[])
{
 int m=mxGetM(prhs[0]);
 int n=mxGetN(prhs[0]);
 const int* dims=mxGetDimensions(prhs[0]);
 int num=mxGetNumberOfDimensions(prhs[0]);
 double *data1=mxGetPr(prhs[0]);

 vtkImageImport *importer = vtkImageImport::New();
 importer->SetWholeExtent(1,dims[0],1,dims[1],1,dims[2]);
 importer->SetDataExtentToWholeExtent();
 importer->SetDataScalarTypeToShort();
 importer->SetImportVoidPointer(data1);

 importer->Update();
 vtkImageData *img = importer->GetOutput();<---This data seems to be
empty...Why?

 //mexPrintf("Data inserted");
 importer->Delete();

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061020/57cf6a3b/attachment.htm>


More information about the vtkusers mailing list