<span class="postbody">Another option to read in an array is the following:<br><br></span><span class="postbody">
int i, j, k;
<br>
vtkImageData *image;
<br>
image = vtkImageData::New();
<br>
<br>
image->SetOrigin(0,0,0);
<br>
image->SetScalarTypeToInt(); //I found the data type earlier in the program, this will change depending on your data type
<br>
image->SetNumberOfScalarComponents(0);
<br>
image->SetSpacing(xspacing, yspacing, zspacing); //the spacing between rows and columns of data and between slices
<br>
image->SetExtent(0, Rows-1, 0, Columns-1, 0, slices-1); <br>
image->AllocateScalars();
<br>
<br>
int *ptr = static_cast<int*>(image->GetScalarPointer());
<br>
<br>
for(i = 0; i< slices; i++){
<br>
for (j = 0; j < Columns; ++j)
<br>
{
<br>
for (k = 0; k < Rows; ++k)
<br>
{
<br>
*ptr++ = HUData[i][j][k]; //HUData is 3D array of pixel data from DCMTK
<br>
}
<br>
}
<br>
}
<br>
</span><span class="postbody"></span><span class="postbody"><br>You can then use "image" in VTK functions like ContourFilter().
<br><br>Catherine Peloquin<br></span><br><div><span class="gmail_quote">On 10/10/07, <b class="gmail_sendername">Francois Bertel</b> <<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Guessing you have a C array of raw data, vtkImageImport is probably a good candidate:
<br><br><a href="http://www.vtk.org/doc/nightly/html/classvtkImageImport.html">http://www.vtk.org/doc/nightly/html/classvtkImageImport.html</a><br><br>Couge Chen wrote:<br>> Hi all,<br>><br>> I want to show a 3d array of size (50X50X50). And I don't want generate
<br>> any data file and read it. So which "Reader" can directly read this array?<br>><br>> Thanks a lot!<br>><br>> Couge<br><br><br>--<br>François Bertel, PhD | Kitware Inc. Suite 204<br>1 (518) 371 3971 x113 | 28 Corporate Drive
<br> | Clifton Park NY 12065, USA<br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br>