GDCM 3.2.1

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
45 class vtkLookupTable;
46 class vtkMedicalImageProperties;
47 class vtkMatrix4x4;
48 class vtkStringArray;
49 class VTKGDCM_EXPORT vtkGDCMImageWriter : public vtkImageWriter
50{
51 public:
52 static vtkGDCMImageWriter *New();
53 vtkTypeMacro(vtkGDCMImageWriter,vtkImageWriter);
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
119 vtkSetStringMacro(StudyUID);
120 vtkGetStringMacro(StudyUID);
121 vtkSetStringMacro(SeriesUID);
122 vtkGetStringMacro(SeriesUID);
123
124//BTX
125 enum CompressionTypes {
126 NO_COMPRESSION = 0, // raw (default)
127 JPEG_COMPRESSION, // JPEG
128 JPEG2000_COMPRESSION, // J2K
129 JPEGLS_COMPRESSION, // JPEG-LS
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
140 protected:
141 vtkGDCMImageWriter();
142 ~vtkGDCMImageWriter();
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
163 protected:
164 virtual /*const*/ char *GetFileName();
165
166 private:
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
vtkGDCMImageWriter::vtkGetStringMacro
vtkGetStringMacro(SeriesUID)
vtkGDCMImageWriter::~vtkGDCMImageWriter
~vtkGDCMImageWriter()
vtkGDCMImageWriter::vtkGetObjectMacro
vtkGetObjectMacro(FileNames, vtkStringArray)
vtkGDCMImageWriter::Write
virtual void Write()
vtkGDCMImageWriter::New
static vtkGDCMImageWriter * New()
vtkGDCMImageWriter::vtkGetMacro
vtkGetMacro(LossyFlag, int)
vtkGDCMImageWriter::vtkSetMacro
vtkSetMacro(Scale, double)
vtkGDCMImageWriter::vtkSetStringMacro
vtkSetStringMacro(SeriesUID)
vtkGDCMImageWriter::vtkGetMacro
vtkGetMacro(ImageFormat, int)
vtkGDCMImageWriter::SetMedicalImageProperties
virtual void SetMedicalImageProperties(vtkMedicalImageProperties *)
vtkGDCMImageWriter::vtkGetMacro
vtkGetMacro(PlanarConfiguration, int)
vtkGDCMImageWriter::vtkGetStringMacro
vtkGetStringMacro(StudyUID)
vtkGDCMImageWriter::SetFileNames
virtual void SetFileNames(vtkStringArray *)
vtkGDCMImageWriter::WriteSlice
void WriteSlice(vtkImageData *data)
vtkGDCMImageWriter::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkGDCMImageWriter::vtkSetMacro
vtkSetMacro(PlanarConfiguration, int)
vtkGDCMImageWriter::vtkGetMacro
vtkGetMacro(Scale, double)
vtkGDCMImageWriter::vtkGDCMImageWriter
vtkGDCMImageWriter()
vtkGDCMImageWriter::GetDescriptiveName
virtual const char * GetDescriptiveName()
Definition vtkGDCMImageWriter.h:83
vtkGDCMImageWriter::GetFileExtensions
virtual const char * GetFileExtensions()
Definition vtkGDCMImageWriter.h:78
vtkGDCMImageWriter::SetDirectionCosines
virtual void SetDirectionCosines(vtkMatrix4x4 *matrix)
vtkGDCMImageWriter::SetDirectionCosinesFromImageOrientationPatient
virtual void SetDirectionCosinesFromImageOrientationPatient(const double dircos[6])
vtkGDCMImageWriter::vtkGetMacro
vtkGetMacro(Shift, double)
vtkGDCMImageWriter::vtkSetMacro
vtkSetMacro(Shift, double)
vtkGDCMImageWriter::vtkGetObjectMacro
vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4)
vtkGDCMImageWriter::vtkSetMacro
vtkSetMacro(CompressionType, int)
vtkGDCMImageWriter::vtkBooleanMacro
vtkBooleanMacro(FileLowerLeft, int)
vtkGDCMImageWriter::GetFileName
virtual char * GetFileName()
vtkGDCMImageWriter::vtkSetMacro
vtkSetMacro(FileLowerLeft, int)
vtkGDCMImageWriter::vtkGetMacro
vtkGetMacro(CompressionType, int)
vtkGDCMImageWriter::vtkGetObjectMacro
vtkGetObjectMacro(MedicalImageProperties, vtkMedicalImageProperties)
vtkGDCMImageWriter::vtkBooleanMacro
vtkBooleanMacro(LossyFlag, int)
vtkGDCMImageWriter::vtkSetStringMacro
vtkSetStringMacro(StudyUID)
vtkGDCMImageWriter::vtkGetMacro
vtkGetMacro(FileLowerLeft, int)
vtkGDCMImageWriter::CompressionTypes
CompressionTypes
Definition vtkGDCMImageWriter.h:125
vtkGDCMImageWriter::NO_COMPRESSION
@ NO_COMPRESSION
Definition vtkGDCMImageWriter.h:126
vtkGDCMImageWriter::RLE_COMPRESSION
@ RLE_COMPRESSION
Definition vtkGDCMImageWriter.h:130
vtkGDCMImageWriter::JPEG2000_COMPRESSION
@ JPEG2000_COMPRESSION
Definition vtkGDCMImageWriter.h:128
vtkGDCMImageWriter::JPEGLS_COMPRESSION
@ JPEGLS_COMPRESSION
Definition vtkGDCMImageWriter.h:129
vtkGDCMImageWriter::JPEG_COMPRESSION
@ JPEG_COMPRESSION
Definition vtkGDCMImageWriter.h:127
vtkGDCMImageWriter::vtkTypeMacro
vtkTypeMacro(vtkGDCMImageWriter, vtkImageWriter)
vtkGDCMImageWriter::vtkSetMacro
vtkSetMacro(LossyFlag, int)
vtkGDCMImageWriter::vtkSetMacro
vtkSetMacro(ImageFormat, int)
vtkGDCMImageWriter::WriteGDCMData
int WriteGDCMData(vtkImageData *data, int timeStep)