[vtkusers] 3d array visualization

Catherine Peloquin cepeloquin at gmail.com
Wed Oct 10 15:30:14 EDT 2007


Another option to read in an array is the following:

int i, j, k;
vtkImageData *image;
image = vtkImageData::New();

image->SetOrigin(0,0,0);
image->SetScalarTypeToInt(); //I found the data type earlier in the program,
this will change depending on your data type
image->SetNumberOfScalarComponents(0);
image->SetSpacing(xspacing, yspacing, zspacing); //the spacing between rows
and columns of data and between slices
image->SetExtent(0, Rows-1, 0, Columns-1, 0, slices-1);
image->AllocateScalars();

int *ptr = static_cast<int*>(image->GetScalarPointer());

for(i = 0; i< slices; i++){
for (j = 0; j < Columns; ++j)
{
for (k = 0; k < Rows; ++k)
{
*ptr++ = HUData[i][j][k]; //HUData is 3D array of pixel data from DCMTK
}
}
}

You can then use "image" in VTK functions like ContourFilter().

Catherine Peloquin

On 10/10/07, Francois Bertel <francois.bertel at kitware.com> wrote:
>
> Guessing you have a C array of raw data, vtkImageImport is probably a good
> candidate:
>
> http://www.vtk.org/doc/nightly/html/classvtkImageImport.html
>
> Couge Chen wrote:
> > Hi all,
> >
> > I want to show a 3d array of size (50X50X50). And I don't want generate
> > any data file and read it. So which "Reader" can directly read this
> array?
> >
> > Thanks a lot!
> >
> > Couge
>
>
> --
> François Bertel, PhD  | Kitware Inc. Suite 204
> 1 (518) 371 3971 x113 | 28 Corporate Drive
>                       | Clifton Park NY 12065, USA
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071010/52fcc8d0/attachment.htm>


More information about the vtkusers mailing list