<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV>Hi Jens,</DIV>
<DIV> </DIV>
<DIV>As far as I know, there is not a conveniet way to do so, correct me if I am
wrong.</DIV>
<DIV>However, 'coz ITK support many formats 3D images, I use ITK to read the
images at first, then convert them to vtkImageData. The code is enclosed.</DIV>
<DIV> </DIV>
<DIV>Please note, what u need to do is adding headers for the *.img (the raw
data). the headers supported by ITK are *.mha and *.hdr.</DIV>
<DIV>The former u can find details from ITK's documents. but it is fairly
simple, something like that:</DIV>
<DIV>NDims = 3 <BR>DimSize = 256 256 63 <BR>ElementType = MET_UCHAR
<BR>ElementSpacing = 1.0 1.0 1.0<BR>ElementByteOrderMSB =
False<BR>ElementDataFile = 1.img</DIV>
<DIV> </DIV>
<DIV>u can make the *.hdr using MRIcro, u may download it from <A
href="http://www.mricro.com">www.mricro.com</A>.</DIV>
<DIV> </DIV>
<DIV>The former is simpler, but I recommand the later header, it is
more convenient to use.</DIV>
<DIV> </DIV>
<DIV>Good luck!</DIV>
<DIV> </DIV>
<DIV>Kurt Zhao</DIV>
<DIV> </DIV>
<DIV>bool MyImage::ImgReader(vtkImageData * vtkImage, const char *
ImgFileName)<BR>{<BR> typedef unsigned short SegPixelType;<BR> typedef
itk::Image< SegPixelType, Dimension > ImageType;</DIV>
<DIV> </DIV>
<DIV> typedef itk::ImageFileReader< ImageType >
ImageReaderType;<BR> <BR> ImageReaderType::Pointer
ImageReader =
ImageReaderType::New();<BR> ImageReader->SetFileName( ImgFileName
);<BR> std::cout<< "Reading the image "<<
ImageReader->GetFileName()<<"......"<<std::endl;
<BR> <BR> try <BR> {<BR>
ImageReader->Update();<BR> }<BR> catch(
itk::ExceptionObject & excep )<BR> {<BR>
std::cerr << "Exception Caught !" <<
std::endl;<BR> std::cerr << excep <<
std::endl;<BR>
}<BR> ImageReader->GetOutput()->ReleaseDataFlagOn();<BR> ImageType
*itkImg=ImageReader->GetOutput();<BR> </DIV>
<DIV> </DIV>
<DIV> typedef itk::VTKImageExport<ImageType>
ImageExportType;<BR> ImageExportType::Pointer itkExporter =
ImageExportType::New();<BR> itkExporter->SetInput(itkImg);</DIV>
<DIV> </DIV>
<DIV> <BR> vtkImageImport* vtkImporter = vtkImageImport::New();
<BR> ConnectPipelines(itkExporter,
vtkImporter);<BR> vtkImporter->Update();<BR> vtkImageData
*tImage=vtkImporter->GetOutput();<BR> vtkImage->DeepCopy(tImage);<BR> vtkImage->SetSpacing(1,1,1);<BR>// vtkImage->Print(std::cout);<BR> vtkImporter->Delete();<BR> return
false;<BR>}</DIV>
<DIV> </DIV>
<DIV>template <typename ITK_Exporter, typename VTK_Importer> <BR>void
ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)<BR>{<BR> //
importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());<BR> //
importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());<BR> importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());<BR>
importer->SetSpacingCallback(exporter->GetSpacingCallback());<BR>
importer->SetOriginCallback(exporter->GetOriginCallback());<BR>
importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());<BR>
importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());<BR>
importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());<BR>
importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());<BR>
importer->SetDataExtentCallback(exporter->GetDataExtentCallback());<BR>
importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());<BR>
importer->SetCallbackUserData(exporter->GetCallbackUserData());<BR>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>
<HR>
</DIV>
<DIV>Send vtkusers mailing list submissions to</DIV>
<DIV>vtkusers@vtk.org</DIV>
<DIV> </DIV>
<DIV>To subscribe or unsubscribe via the World Wide Web, visit</DIV>
<DIV>http://www.vtk.org/mailman/listinfo/vtkusers</DIV>
<DIV>or, via email, send a message with subject or body 'help' to</DIV>
<DIV>vtkusers-request@vtk.org</DIV>
<DIV> </DIV>
<DIV>You can reach the person managing the list at</DIV>
<DIV>vtkusers-owner@vtk.org</DIV>
<DIV> </DIV>
<DIV>When replying, please edit your Subject line so it is more specific</DIV>
<DIV>than "Re: Contents of vtkusers digest..."</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Today's Topics:</DIV>
<DIV> </DIV>
<DIV> 1. reading row 3D voxel data (Jens Frederich)</DIV>
<DIV> 2. reading row 3D voxel data (Jens Frederich)</DIV>
<DIV> 3. reading row 3D voxel data (Jens Frederich)</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>----------------------------------------------------------------------</DIV>
<DIV> </DIV>
<DIV>Message: 1</DIV>
<DIV>Date: Wed, 7 Jan 2004 20:27:09 +0100</DIV>
<DIV>From: Jens Frederich < jfrederich@mac.com> </DIV>
<DIV>Subject: [vtkusers] reading row 3D voxel data</DIV>
<DIV>To: vtk < vtkusers@vtk.org> </DIV>
<DIV>Message-ID: < 7C576394-4147-11D8-A56E-000A95A0B65C@mac.com>
</DIV>
<DIV>Content-Type: text/plain; charset=US-ASCII; format=flowed</DIV>
<DIV> </DIV>
<DIV>Hi all,</DIV>
<DIV> </DIV>
<DIV>what is the best class (way) for reading 3D binary row voxel data. The </DIV>
<DIV>data is saved in one file, not many 2D images. I would do volume </DIV>
<DIV>rendering, isosurface, contour etc with this data.</DIV>
<DIV>With the volume rendering library vgl </DIV>
<DIV>(http://www.volumegraphics.com/products/vgl/index.html) is this very </DIV>
<DIV>simple. Here a code sample:</DIV>
<DIV> </DIV>
<DIV>VGLSampleGridData* volumeData = new VGLSampleGridData (VGL_TYPE_UINT16);</DIV>
<DIV> // load voxel data:</DIV>
<DIV> VGLSampleGridIO* importPlugIn = VGLSampleGridIO::create ("raw");</DIV>
<DIV> importPlugIn-> setHeaderSkip (40);</DIV>
<DIV> imortPlugIn->
setSampleGridSize (VGLSampleGridSize (42,42,42));</DIV>
<DIV> importPlugIn->
setSampleGridSize (VGLSampleGridSize (250,250,1));</DIV>
<DIV> importPlugIn->
setSampleDataType (VGL_TYPE_UINT16);</DIV>
<DIV> importPlugIn->
open ("../data/simdata4.vol");</DIV>
<DIV> importPlugIn-> read (volumeData);</DIV>
<DIV> importPlugIn-> close ();</DIV>
<DIV> delete importPlugIn;</DIV>
<DIV> </DIV>
<DIV>It's very easy. But I search the same on vtk please.</DIV>
<DIV>Thanks for help.</DIV>
<DIV> </DIV>
<DIV>Best regards,</DIV>
<DIV>Jens</DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>