GDCM  2.4.5
vtkGDCMImageWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: GDCM (Grassroots DICOM). A DICOM library
4 
5  Copyright (c) 2006-2011 Mathieu Malaterre
6  All rights reserved.
7  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkGDCMImageWriter - write DICOM files
15 // .SECTION Description
16 // vtkGDCMImageWriter is a sink object that write DICOM files
17 // this writer is single threaded (see vtkGDCMThreadedImageReader2 for multi-thread)
18 //
19 // .SECTION Warning: vtkLookupTable from the vtkImageData object taken into account
20 // only if ImageFormat is set to VTK_LOOKUP_TABLE
21 //
22 // .SECTION NOTE We are not using the usual API SetFilePrefix / SetFilePattern,
23 // but instead a list of filenames: see SetFileNames and class gdcm::FilenameGenerator
24 //
25 // .SECTION Warning
26 // You need to specify the correct ImageFormat (taken from the reader)
27 // You need to explicitly specify the DirectionCosines (taken from the reader)
28 // Since VTK 5.4 vtkMedicalImageProperties has its own DirectionCosine (no 's')
29 // user need to make sure the vtkMatrix4x4 is compatible with the 6-vector DirectionCosine.
30 //
31 // .SECTION NOTE Shift/Scale are global to all DICOM frames (=files) written
32 // as 2D slice, therefore the shift/scale operation might not be optimized for
33 // all slices. This is not recommended for image with a large dynamic range.
34 //
35 // .SECTION See Also
36 // vtkImageWriter vtkMedicalImageProperties vtkGDCMImageReader
37 
38 #ifndef VTKGDCMIMAGEWRITER_H
39 #define VTKGDCMIMAGEWRITER_H
40 
41 #include "vtkImageWriter.h"
42 
43 class vtkLookupTable;
44 class vtkMedicalImageProperties;
45 class vtkMatrix4x4;
46 class vtkStringArray;
47 class VTK_EXPORT vtkGDCMImageWriter : public vtkImageWriter
48 {
49 public:
50  static vtkGDCMImageWriter *New();
51  vtkTypeRevisionMacro(vtkGDCMImageWriter,vtkImageWriter);
52  virtual void PrintSelf(ostream& os, vtkIndent indent);
53 
54  // Description:
55  // Pass in the vtkmedicalimageproperties object for medical information
56  // to be mapped to DICOM attributes.
57  vtkGetObjectMacro(MedicalImageProperties, vtkMedicalImageProperties);
58  virtual void SetMedicalImageProperties(vtkMedicalImageProperties*);
59 
60  // Description:
61  // Pass in the list of filename to be used to write out the DICOM file(s)
62  virtual void SetFileNames(vtkStringArray*);
63  vtkGetObjectMacro(FileNames, vtkStringArray);
64 
65  // Description:
66  // Set/Get whether or not the image was compressed using a lossy compression algorithm
67  vtkGetMacro(LossyFlag,int);
68  vtkSetMacro(LossyFlag,int);
69  vtkBooleanMacro(LossyFlag,int);
70 
71  // I need that...
72  virtual void Write();
73 
74  // Description:
75  // Get the entension for this file format.
76  virtual const char* GetFileExtensions() {
77  return ".dcm .DCM"; }
78 
79  // Description:
80  // Get the name of this file format.
81  virtual const char* GetDescriptiveName() {
82  return "DICOM"; }
83 
84  // Description:
85  // You need to manually specify the direction the image is in to write a valid DICOM file
86  // since vtkImageData do not contains one (eg. MR Image Storage, CT Image Storage...)
87  virtual void SetDirectionCosines(vtkMatrix4x4 *matrix);
88  vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4);
89  virtual void SetDirectionCosinesFromImageOrientationPatient(const double dircos[6]);
90 
91  // Description:
92  // Modality LUT
93  vtkSetMacro(Shift, double);
94  vtkGetMacro(Shift, double);
95  vtkSetMacro(Scale, double);
96  vtkGetMacro(Scale, double);
97 
98  // Description:
99  // See vtkGDCMImageReader for list of ImageFormat
100  vtkGetMacro(ImageFormat,int);
101  vtkSetMacro(ImageFormat,int);
102 
103  // Description:
104  // Set/Get whether the data comes from the file starting in the lower left
105  // corner or upper left corner.
106  vtkBooleanMacro(FileLowerLeft, int);
107  vtkGetMacro(FileLowerLeft, int);
108  vtkSetMacro(FileLowerLeft, int);
109 
110  // Description:
111  // For color image (more than a single comp) you can specify the planar configuration you prefer
112  vtkSetMacro(PlanarConfiguration,int);
113  vtkGetMacro(PlanarConfiguration,int);
114 
115  // Description:
116  // Set/Get specific StudyUID / SeriesUID
117  vtkSetStringMacro(StudyUID);
118  vtkGetStringMacro(StudyUID);
119  vtkSetStringMacro(SeriesUID);
120  vtkGetStringMacro(SeriesUID);
121 
122 //BTX
124  NO_COMPRESSION = 0, // raw (default)
127  JPEGLS_COMPRESSION, // JPEG-LS
128  RLE_COMPRESSION // RLE
129  };
130 //ETX
131  // Set/Get the compression type
132  vtkSetMacro(CompressionType, int);
133  vtkGetMacro(CompressionType, int);
134 
135  //void SetCompressionTypeFromString(const char *);
136  //const char *GetCompressionTypeAsString();
137 
138 protected:
141 
142 #if (VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 5 )
143  int FillInputPortInformation(int port, vtkInformation *info);
144  int RequestInformation(
145  vtkInformation *request,
146  vtkInformationVector **inputVector,
147  vtkInformationVector *outputVector);
148  int RequestUpdateExtent(
149  vtkInformation *request,
150  vtkInformationVector **inputVector,
151  vtkInformationVector *outputVector);
152  int RequestData(
153  vtkInformation *request,
154  vtkInformationVector **inputVector,
155  vtkInformationVector *outputVector);
156 #else
157  void WriteSlice(vtkImageData *data);
158 #endif /*(VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 5 )*/
159  int WriteGDCMData(vtkImageData *data, int timeStep);
160 
161 protected:
162  virtual /*const*/ char *GetFileName();
163 
164 private:
165  vtkGDCMImageWriter(const vtkGDCMImageWriter&); // Not implemented.
166  void operator=(const vtkGDCMImageWriter&); // Not implemented.
167 
168  // VTK structs:
169  //vtkLookupTable *LookupTable;
170  vtkMedicalImageProperties *MedicalImageProperties;
171  char *StudyUID;
172  char *SeriesUID;
173 
174  int DataUpdateExtent[6];
175  int ImageFormat;
176 
177  vtkStringArray *FileNames;
178  vtkMatrix4x4 *DirectionCosines;
179 
180  double Shift;
181  double Scale;
182  int FileLowerLeft;
183  int PlanarConfiguration;
184  int LossyFlag;
185  int CompressionType;
186 };
187 
188 #endif
Definition: vtkGDCMImageWriter.h:127
CompressionTypes
Definition: vtkGDCMImageWriter.h:123
Definition: vtkGDCMImageWriter.h:126
Definition: vtkGDCMImageWriter.h:47
Definition: vtkGDCMImageWriter.h:125
virtual const char * GetFileExtensions()
Definition: vtkGDCMImageWriter.h:76
virtual const char * GetDescriptiveName()
Definition: vtkGDCMImageWriter.h:81

Generated on Fri Sep 25 2015 17:58:25 for GDCM by doxygen 1.8.9.1
SourceForge.net Logo