GDCM 3.0.24
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 "vtkgdcmModule.h"
42#include "vtkImageWriter.h"
43#include "vtkVersion.h"
44
45class vtkLookupTable;
46class vtkMedicalImageProperties;
47class vtkMatrix4x4;
48class vtkStringArray;
49class VTKGDCM_EXPORT vtkGDCMImageWriter : public vtkImageWriter
50{
51public:
54 virtual void PrintSelf(ostream& os, vtkIndent indent);
55
56 // Description:
57 // Pass in the vtkmedicalimageproperties object for medical information
58 // to be mapped to DICOM attributes.
59 vtkGetObjectMacro(MedicalImageProperties, vtkMedicalImageProperties);
60 virtual void SetMedicalImageProperties(vtkMedicalImageProperties*);
61
62 // Description:
63 // Pass in the list of filename to be used to write out the DICOM file(s)
64 virtual void SetFileNames(vtkStringArray*);
65 vtkGetObjectMacro(FileNames, vtkStringArray);
66
67 // Description:
68 // Set/Get whether or not the image was compressed using a lossy compression algorithm
69 vtkGetMacro(LossyFlag,int);
70 vtkSetMacro(LossyFlag,int);
71 vtkBooleanMacro(LossyFlag,int);
72
73 // I need that...
74 virtual void Write();
75
76 // Description:
77 // Get the extension for this file format.
78 virtual const char* GetFileExtensions() {
79 return ".dcm .DCM"; }
80
81 // Description:
82 // Get the name of this file format.
83 virtual const char* GetDescriptiveName() {
84 return "DICOM"; }
85
86 // Description:
87 // You need to manually specify the direction the image is in to write a valid DICOM file
88 // since vtkImageData do not contains one (eg. MR Image Storage, CT Image Storage...)
89 virtual void SetDirectionCosines(vtkMatrix4x4 *matrix);
90 vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4);
91 virtual void SetDirectionCosinesFromImageOrientationPatient(const double dircos[6]);
92
93 // Description:
94 // Modality LUT
95 vtkSetMacro(Shift, double);
96 vtkGetMacro(Shift, double);
97 vtkSetMacro(Scale, double);
98 vtkGetMacro(Scale, double);
99
100 // Description:
101 // See vtkGDCMImageReader for list of ImageFormat
102 vtkGetMacro(ImageFormat,int);
103 vtkSetMacro(ImageFormat,int);
104
105 // Description:
106 // Set/Get whether the data comes from the file starting in the lower left
107 // corner or upper left corner.
108 vtkBooleanMacro(FileLowerLeft, int);
109 vtkGetMacro(FileLowerLeft, int);
110 vtkSetMacro(FileLowerLeft, int);
111
112 // Description:
113 // For color image (more than a single comp) you can specify the planar configuration you prefer
114 vtkSetMacro(PlanarConfiguration,int);
115 vtkGetMacro(PlanarConfiguration,int);
116
117 // Description:
118 // Set/Get specific StudyUID / SeriesUID
123
124//BTX
126 NO_COMPRESSION = 0, // raw (default)
130 RLE_COMPRESSION // RLE
131 };
132//ETX
133 // Set/Get the compression type
134 vtkSetMacro(CompressionType, int);
135 vtkGetMacro(CompressionType, int);
136
137 //void SetCompressionTypeFromString(const char *);
138 //const char *GetCompressionTypeAsString();
139
140protected:
143
144#if (VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 5 )
145 int FillInputPortInformation(int port, vtkInformation *info);
146 int RequestInformation(
147 vtkInformation *request,
148 vtkInformationVector **inputVector,
149 vtkInformationVector *outputVector);
150 int RequestUpdateExtent(
151 vtkInformation *request,
152 vtkInformationVector **inputVector,
153 vtkInformationVector *outputVector);
154 int RequestData(
155 vtkInformation *request,
156 vtkInformationVector **inputVector,
157 vtkInformationVector *outputVector);
158#else
159 void WriteSlice(vtkImageData *data);
160#endif /*(VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 5 )*/
161 int WriteGDCMData(vtkImageData *data, int timeStep);
162
163protected:
164 virtual /*const*/ char *GetFileName();
165
166private:
167 vtkGDCMImageWriter(const vtkGDCMImageWriter&); // Not implemented.
168 void operator=(const vtkGDCMImageWriter&); // Not implemented.
169
170 // VTK structs:
171 //vtkLookupTable *LookupTable;
172 vtkMedicalImageProperties *MedicalImageProperties;
173 char *StudyUID;
174 char *SeriesUID;
175
176 int DataUpdateExtent[6];
177 int ImageFormat;
178
179 vtkStringArray *FileNames;
180 vtkMatrix4x4 *DirectionCosines;
181
182 double Shift;
183 double Scale;
184 int FileLowerLeft;
185 int PlanarConfiguration;
186 int LossyFlag;
187 int CompressionType;
188};
189
190#endif
Definition vtkGDCMImageWriter.h:50
vtkGetStringMacro(SeriesUID)
vtkGetObjectMacro(FileNames, vtkStringArray)
virtual void Write()
static vtkGDCMImageWriter * New()
vtkGetMacro(LossyFlag, int)
vtkSetMacro(Scale, double)
vtkSetStringMacro(SeriesUID)
vtkGetMacro(ImageFormat, int)
virtual void SetMedicalImageProperties(vtkMedicalImageProperties *)
vtkGetMacro(PlanarConfiguration, int)
vtkGetStringMacro(StudyUID)
virtual void SetFileNames(vtkStringArray *)
void WriteSlice(vtkImageData *data)
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkSetMacro(PlanarConfiguration, int)
vtkGetMacro(Scale, double)
virtual const char * GetDescriptiveName()
Definition vtkGDCMImageWriter.h:83
virtual const char * GetFileExtensions()
Definition vtkGDCMImageWriter.h:78
virtual void SetDirectionCosines(vtkMatrix4x4 *matrix)
virtual void SetDirectionCosinesFromImageOrientationPatient(const double dircos[6])
vtkGetMacro(Shift, double)
vtkSetMacro(Shift, double)
vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4)
vtkSetMacro(CompressionType, int)
vtkBooleanMacro(FileLowerLeft, int)
virtual char * GetFileName()
vtkSetMacro(FileLowerLeft, int)
vtkGetMacro(CompressionType, int)
vtkGetObjectMacro(MedicalImageProperties, vtkMedicalImageProperties)
vtkBooleanMacro(LossyFlag, int)
vtkSetStringMacro(StudyUID)
vtkGetMacro(FileLowerLeft, int)
CompressionTypes
Definition vtkGDCMImageWriter.h:125
@ JPEG2000_COMPRESSION
Definition vtkGDCMImageWriter.h:128
@ JPEGLS_COMPRESSION
Definition vtkGDCMImageWriter.h:129
@ JPEG_COMPRESSION
Definition vtkGDCMImageWriter.h:127
vtkTypeMacro(vtkGDCMImageWriter, vtkImageWriter)
vtkSetMacro(LossyFlag, int)
vtkSetMacro(ImageFormat, int)
int WriteGDCMData(vtkImageData *data, int timeStep)