[vtkusers] Re: Problems with vtkImageImport

Prename Surname bsd.diverse at gmail.com
Fri Oct 20 12:09:54 EDT 2006


If i try to call
long memSize=img->GetActualMemorySize();
on my assigned image, it also returns 0. So somehow the data is not read
into my object...Which i dont understand.
Does anyone know about this problem?
Thank you


2006/10/20, Prename Surname <bsd.diverse at gmail.com>:
>
> 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/8dcdd579/attachment.htm>


More information about the vtkusers mailing list