1 // This example illustrates how the vtkGdcmWriter vtk class can be
6 //----------------------------------------------------------------------------
9 #include <vtkImageMapToColors.h>
10 #include <vtkLookupTable.h>
11 #include <vtkImageData.h>
13 #include "vtkGdcmReader.h"
14 #include "vtkGdcmWriter.h"
16 #ifndef vtkFloatingPointType
17 #define vtkFloatingPointType float
20 //----------------------------------------------------------------------------
21 int main(int argc, char *argv[])
28 vtkGdcmReader *reader = vtkGdcmReader::New();
29 reader->AllowLookupTableOff();
30 reader->SetFileName( argv[1] );
34 if( reader->GetLookupTable() )
37 vtkImageMapToColors *map = vtkImageMapToColors::New ();
38 map->SetInput (reader->GetOutput());
39 map->SetLookupTable (reader->GetLookupTable());
40 map->SetOutputFormatToRGB();
41 output = map->GetOutput();
46 output = reader->GetOutput();
52 //////////////////////////////////////////////////////////
54 //if you wish you can export dicom to a vtk file
55 // this file will have the add of .tmp.dcm extention
56 std::string fileName = argv[2];
59 vtkGdcmWriter *writer = vtkGdcmWriter::New();
62 writer->SetFileDimensionality(3);
63 writer->SetFileName(fileName.c_str());
66 if( strcmp(argv[3],"2D" )==0 )
68 writer->SetFileDimensionality(2);
69 writer->SetFilePrefix(argv[2]);
70 writer->SetFilePattern("%s%d.dcm");
74 writer->SetInput(output);
76 //////////////////////////////////////////////////////////