[vtkusers] VTKMATLABMEXADAPTER: vtkDataArray to vtkImageData
kwayeke
bigvision82 at yahoo.com
Tue Jan 4 11:55:13 EST 2011
I have 384 slices of CT (Computed Tomography) data which I want to input
from matlab to VTK to perform volume rendering and display as a 3D volume. I
therefore decided to use the vtkMatlabMexAdapter but but the output is a
vtkDataArray but I need it to be of type vtkImageData so that I can display
it as 3D volume. Here is what I have done so far:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
// convert matlab volume to vtk
bool ShallowCopy=false;
vtkMatlabMexAdapter *matlabMexAdapter = vtkMatlabMexAdapter::New();
matlabMexAdapter->mxArrayTovtkDataArray(prhs[0],ShallowCopy);
// CONVERT vtkDataArray to vtkImageData with 3D
vtkImageData *ImageData = vtkImageData::New();
ImageData->SetDimensions(254,254,384);
ImageData->SetOrigin(0.0,0.0,0.0);
ImageData->SetSpacing(1.0,1.0,1.0);
ImageData->SetScalarTypeToUnsignedChar();
ImageData->SetNumberOfScalarComponents(3);
ImageData->SetWholeExtent(0,299,0,299,0,384);
ImageData->GetPointData()->SetScalars(matlabMexadapter);
}
I tried the above code but did not succeed.
PEOPLE PLEASE HELP
--
View this message in context: http://vtk.1045678.n5.nabble.com/VTKMATLABMEXADAPTER-vtkDataArray-to-vtkImageData-tp3327361p3327361.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list