[vtkusers] dicom data convertion and problem.

iii-lin iii-lin at 163.com
Sun Dec 24 07:51:57 EST 2006


hello Peter Spring and everyone,
   Thanks you advice!I still have some problems,can you help me?thanks.
   How to read dicom files and use vtkPolyDataWriter to write to a .vtk file?can you give me a sample code?
 
   I use vtkDICOMImageReader to read the data formats such as dataSpacing,and use vtkImageReader to use this formats to read the data,
//////////////////////////////
   vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
   reader->SetDirectoryName("D:\\lmhjava\\vtksource\\dicom");
   reader->Update();
   //follow codes read the formats of dicom files.
 
////May be use vtkImageReader to read the dcm file is wrong.but I can not find other ways.
vtkImageReader *imageReader = vtkImageReader::New();
imageReader->SetFilePrefix( outputImagePrefix );
imageReader->SetFilePattern( "%s.%03d.dcm" );///May be wrong
imageReader->SetDataExtent( imageExtent );//Format read from vtkDICOMImageReader
imageReader->SetDataByteOrderToBigEndian();
imageReader->Update();

vtkImageWriter *imageWriter = vtkImageWriter::New();
imageWriter->SetInput( imageReader->GetOutput() );
dicomImageReader->Delete();
imageWriter->SetFilePrefix( outputImagePrefix );
imageWriter->SetFilePattern( "%s.%03d" );//I just want to write dcm files into files like VTKData/headsq/quarter
imageWriter->Write();
imageWriter->Delete();
////////////////////////////////////////////////////////////
And use the the follow code to read the sample headsq/quarter data,and write to a vtk file.I just want to convert the dicom file to datas like headsq/quarter,and write to a vtk file.
//////////////////////////////
//the follow codes I have tested.
package require vtk
package require vtkinteraction
vtkVolume16Reader v16
  v16 SetDataDimensions 256 256
  v16 SetDataByteOrderToLittleEndian 
  v16 SetFilePrefix  "VTKData/fullHead/headsq"
  v16 SetImageRange 1 93
  v16 SetDataSpacing  1.0 1.0 2
vtkImageGaussianSmooth GaussianSmooth
  GaussianSmooth SetInput [v16 GetOutput]
  GaussianSmooth SetDimensionality 3
  GaussianSmooth SetStandardDeviations 0.0 4.0
vtkContourFilter skinExtractor
  skinExtractor SetInput [GaussianSmooth GetOutput]
  skinExtractor SetValue 0 500
  skinExtractor Update
vtkSmoothPolyDataFilter smoother
  smoother SetInput [skinExtractor GetOutput]
  smoother SetNumberOfIterations 70
vtkPolyDataNormals skinNormals
  skinNormals SetInput [smoother GetOutput]
  skinNormals SetFeatureAngle 60.0
vtkPolyDataWriter pdw
  pdw SetInput [skinNormals GetOutput]
  pdw SetFileName "C:/zhangh/VTK/out.vtk"
  pdw Write
////////////////////////////////////////////////////////
 
 
In your advice,use dicom2 to convert dcm files to raw data,and use vtkUolume16Reader to read and use vtkPolyDataWriter to write to a vtk file?
 
thanks you advice,thanks everybody's advice.
         
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061224/58248fd4/attachment.htm>


More information about the vtkusers mailing list