00001
00002
00003
00004
00005
00006
00007 #include <iostream>
00008
00009 #include <vtkImageMapToColors.h>
00010 #include <vtkLookupTable.h>
00011 #include <vtkImageData.h>
00012
00013 #include "vtkGdcmReader.h"
00014 #include "vtkGdcmWriter.h"
00015
00016 #ifndef vtkFloatingPointType
00017 #define vtkFloatingPointType float
00018 #endif
00019
00020
00021 int main(int argc, char *argv[])
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
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
00050 output->Print(cout);
00051
00053
00054
00055
00056 std::string fileName = argv[2];
00057 fileName += ".dcm";
00058
00059 vtkGdcmWriter *writer = vtkGdcmWriter::New();
00060
00061
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
00079 writer->Delete();
00080 reader->Delete();
00081
00082 return 0;
00083 }