#include <iostream>#include <vtkImageMapToColors.h>#include <vtkLookupTable.h>#include <vtkImageData.h>#include "vtkGdcmReader.h"#include "vtkGdcmWriter.h"Go to the source code of this file.
Defines | |
| #define | vtkFloatingPointType float |
Functions | |
| int | main (int argc, char *argv[]) |
|
|
Definition at line 17 of file vtkWriteDicom.cxx. |
|
||||||||||||
|
Definition at line 21 of file vtkWriteDicom.cxx. References vtkGdcmWriter::New(), vtkGdcmReader::New(), and vtkGdcmReader::SetFileName().
00022 {
00023 if( argc < 3 )
00024 {
00025 return 0;
00026 }
00027
00028 vtkGdcmReader *reader = vtkGdcmReader::New();
00029 reader->AllowLookupTableOff();
00030 reader->SetFileName( argv[1] );
00031 reader->Update();
00032
00033 vtkImageData *output;
00034 if( reader->GetLookupTable() )
00035 {
00036 //convert to color:
00037 vtkImageMapToColors *map = vtkImageMapToColors::New ();
00038 map->SetInput (reader->GetOutput());
00039 map->SetLookupTable (reader->GetLookupTable());
00040 map->SetOutputFormatToRGB();
00041 output = map->GetOutput();
00042 map->Delete();
00043 }
00044 else
00045 {
00046 output = reader->GetOutput();
00047 }
00048
00049 //print debug info:
00050 output->Print(cout);
00051
00053 // WRITE...
00054 //if you wish you can export dicom to a vtk file
00055 // this file will have the add of .tmp.dcm extention
00056 std::string fileName = argv[2];
00057 fileName += ".dcm";
00058
00059 vtkGdcmWriter *writer = vtkGdcmWriter::New();
00060
00061 // For 3D
00062 writer->SetFileDimensionality(3);
00063 writer->SetFileName(fileName.c_str());
00064 if(argc >= 4)
00065 {
00066 if( strcmp(argv[3],"2D" )==0 )
00067 {
00068 writer->SetFileDimensionality(2);
00069 writer->SetFilePrefix(argv[2]);
00070 writer->SetFilePattern("%s%d.dcm");
00071 }
00072 }
00073
00074 writer->SetInput(output);
00075 writer->Write();
00077
00078 // Clean up
00079 writer->Delete();
00080 reader->Delete();
00081
00082 return 0;
00083 }
|
1.3.6