<div>Hello all. </div>
<div>I hope i am not asking to many questions, but these import things gives me a lot of problems.</div>
<div>I have managed to get the mex-file to work, so now i can from matlab interface to vtk, via a dll file.</div>
<div> </div>
<div>But i have problems converting the input-data(which is a C-array) to a VTKImage.</div>
<div> </div>
<div>The problem is that when i try to access the data stored in my img pointer, it seems to be empty.</div>
<div> </div>
<div>It is as if the data has not been put there.</div>
<div>I know that the variable double *data1=mxGetPr(prhs[0]); </div>
<div>contains the correct data. I have checked that.</div>
<div> </div>
<div>So am i missing something in the import filter?</div>
<div>I hope someone can help me out a little.</div>
<div> </div>
<div>Thank you very much</div>
<div> </div>
<div> </div>
<div>The code i have is as follows :</div>
<div> </div>
<div>void mexFunction(int nlhs, mxArray *plhs[], int nrhs,<br> const mxArray *prhs[])<br>{<br> int m=mxGetM(prhs[0]);<br> int n=mxGetN(prhs[0]);<br> const int* dims=mxGetDimensions(prhs[0]);<br> int num=mxGetNumberOfDimensions(prhs[0]);
<br> double *data1=mxGetPr(prhs[0]);<br> <br> vtkImageImport *importer = vtkImageImport::New();<br> importer->SetWholeExtent(1,dims[0],1,dims[1],1,dims[2]);<br> importer->SetDataExtentToWholeExtent();<br> importer->SetDataScalarTypeToShort();
<br> importer->SetImportVoidPointer(data1);<br> <br> importer->Update();<br> vtkImageData *img = importer->GetOutput();<---This data seems to be empty...Why?<br> <br> //mexPrintf("Data inserted");<br>
importer->Delete();<br> <br>}<font size="1"></font></div>