[vtkusers] fill vtkImageData in 3D
kwayeke
bigvision82 at yahoo.com
Fri Jan 7 05:56:43 EST 2011
How can one fill out a 3D vtkImageData. I tried the following code in in my
program below but it did not work
double* pixel = static_cast<double*>(ImageData->GetScalarPointer(k,j,i));
pixel[i] = pix;
The program itself is below.
Many Thanks
----------------------------------------------------------------------------------------
vtkMatlabMexAdapter *matlabMexAdapter = vtkMatlabMexAdapter::New();
vtkArray
*edata=matlabMexAdapter->mxArrayTovtkArray(const_cast<mxArray*>(prhs[0]));
vtkSmartPointer<vtkImageData> ImageData =
vtkSmartPointer<vtkImageData>::New();
ImageData->SetDimensions(254,254,384);
ImageData->SetOrigin(0.0,0.0,0.0);
ImageData->SetSpacing(1.0,1.0,1.0);
ImageData->SetScalarTypeToDouble();
ImageData->AllocateScalars();
for(int i=0; i<z_dim-1; i++)
{
for(int j=0;j<y_dim-1;j++)
{
for(int k=0;k<x_dim-1;j++)
{vtkVariant p=edata->GetVariantValue(k, j, i);
double pix= p.ToDouble();
double* pixel =
static_cast<double*>(ImageData->GetScalarPointer(k,j,i));
pixel[i] = pix;
}
}
}
----------------------------------------------------------------------------------------------------
--
View this message in context: http://vtk.1045678.n5.nabble.com/fill-vtkImageData-in-3D-tp3331674p3331674.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list