[vtkusers] Re: dicom data convertion and problem.
Peter Spring
meancity at gmail.com
Sun Dec 24 09:01:18 EST 2006
ok i do not think vtkImageReader is a proper way to read dicom files.
so for dicom files, u just forget the vtkImageReader.
here i give u a pipeline for doing it.
vtkDICOMImageReader->vtkImageCast->vtkImageGaussianSmooth->vtkContourFilter->vtkPolyDataNormals->vtkPolyDataMapper
after that u create something like
vtkPolyDataWriter PDW
PDW SetInput [yourcontourfilter GetOutput]
bla bla ...
if you data is huge...(most CT data is huge) u may sub-sampling it to
make it manageable.
i do not have any decent java code for this here. above might help.
thanks.
Yours
P.
On 12/24/06, iii-lin <iii-lin at 163.com> wrote:
> 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.
>
>
>
> ________________________________
> 想免费获得高速稳定的3G邮箱吗? www.126.com
More information about the vtkusers
mailing list