GDCM 3.2.1

vtkGDCMImageReader2.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 vtkGDCMImageReader2 - read DICOM Image files (Pixel Data)
15// .SECTION Description
16// vtkGDCMImageReader2 is a source object that reads some DICOM files
17// this reader is single threaded.
18// .SECTION Implementation note: when FileLowerLeft is set to on the image is not flipped
19// upside down as VTK would expect, use this option only if you know what you are doing.
20// .SECTION Implementation note: when reading a series of 2D slices, user is
21// expected to provide an ordered list of filenames. No sorting will be applied afterward.
22// .SECTION Implementation note: Although 99% of the time the Zspacing as read
23// from a tag in a 2D DICOM file should be correct, there has been reports that this
24// value can be missing, or incorrect, in which case users are advised to override this
25// value using the return value from gdcm::IPPSorter::GetZSpacing() and set it via
26// vtkImageChangeInformation on the reader itself.
27// .SECTION TODO
28// This reader does not handle a series of 3D images, only a single 3D (multi frame) or a
29// list of 2D files are supported for now.
30// .SECTION TODO
31// Did not implement SetFilePattern / SetFilePrefix API, move it to protected section for now.
32// .SECTION BUG
33// Overlay are assumed to have the same extent as image. Right now if overlay origin is not
34// 0,0 the overlay will have an offset...
35// Only the very first overlay is loaded at the VTK level, for now (even if there are more than one in the file)
36// .SECTION DataOrigin
37// When the reader is instantiated with FileLowerLeftOn the DataOrigin and Image Position (Patient) are
38// identical. But when FileLowerLeft is Off, we have to reorder the Y-line of the image, and thus the DataOrigin
39// is then translated to the other side of the image.
40// .SECTION Spacing
41// When reading a 3D volume, the spacing along the Z dimension might be negative (so as to respect up-side-down)
42// as specified in the Image Orientation (Patient) tag. When Z-spacing is 0, this means the multi-frame object
43// contains image which do not represent uniform volume.
44// .SECTION Warning
45// When using vtkGDCMPolyDataReader in conjunction with vtkGDCMImageReader2
46// it is *required* that FileLowerLeft is set to ON as coordinate system
47// would be inconsistent in between the two data structures.
48// .SECTION Color Space mapping:
49// * VTK_LUMINANCE <-> MONOCHROME2
50// * VTK_LUMINANCE_ALPHA <-> Not supported
51// * VTK_RGB <-> RGB
52// * VTK_RGBA <-> ARGB (deprecated, DICOM 2008)
53// * VTK_INVERSE_LUMINANCE <-> MONOCHROME1
54// * VTK_LOOKUP_TABLE <-> PALETTE COLOR
55// * VTK_YBR <-> YBR_FULL
56//
57// For detailed information on color space transformation and true lossless transformation see:
58// http://gdcm.sourceforge.net/wiki/index.php/Color_Space_Transformations
59
60// .SECTION See Also
61// vtkMedicalImageReader2 vtkMedicalImageProperties vtkGDCMPolyDataReader vtkGDCMImageWriter
62// vtkDICOMImageReader
63
64#ifndef VTKGDCMIMAGEREADER2_H
65#define VTKGDCMIMAGEREADER2_H
66
67#include "vtkgdcmModule.h"
68#include "vtkMedicalImageReader2.h"
69#include "vtkImageData.h"
70
71 class vtkPolyData;
72
73// vtkSystemIncludes.h defines:
74// #define VTK_LUMINANCE 1
75// #define VTK_LUMINANCE_ALPHA 2
76// #define VTK_RGB 3
77// #define VTK_RGBA 4
78#ifndef VTK_INVERSE_LUMINANCE
79#define VTK_INVERSE_LUMINANCE 5
80#endif
81#ifndef VTK_LOOKUP_TABLE
82#define VTK_LOOKUP_TABLE 6
83#endif
84#ifndef VTK_YBR
85#define VTK_YBR 7
86#endif
87#ifndef VTK_CMYK
88#define VTK_CMYK 8
89#endif
90
91//BTX
92 namespace gdcm { class ImageReader; }
93//ETX
94 class vtkMatrix4x4;
95 class VTKGDCM_EXPORT vtkGDCMImageReader2 : public vtkMedicalImageReader2
96{
97 public:
98 static vtkGDCMImageReader2 *New();
99 vtkTypeMacro(vtkGDCMImageReader2,vtkMedicalImageReader2);
100 virtual void PrintSelf(ostream& os, vtkIndent indent);
101
102 // Description: is the given file name a DICOM file containing an image ?
103 virtual int CanReadFile(const char* fname);
104
105 // Description:
106 // Valid extensions
107 virtual const char* GetFileExtensions()
108 {
109 // I would like to get rid of ACR/NEMA/IMA so only allow dcm extension for now
110 return ".dcm .DCM";
111 }
112
113 // Description:
114 // A descriptive name for this format
115 virtual const char* GetDescriptiveName()
116 {
117 return "DICOM";
118 }
119
120 // Description:
121 // Get the Image Position (Patient) as stored in the DICOM file
122 // This is a read-only data member
123 vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4);
124
125 virtual void SetMedicalImageProperties(vtkMedicalImageProperties *pd);
126
127 // Description:
128 // Specifically request to load the overlay into the gdcm-VTK layer (gdcm always loads them when found).
129 // If no overlay is found in the image, then the vtkImageData for the overlay will be empty.
130 vtkGetMacro(LoadOverlays,int);
131 vtkSetMacro(LoadOverlays,int);
132 vtkBooleanMacro(LoadOverlays,int);
133
134 // Description:
135 // Set/Get whether or not to load the Icon as vtkImageData (if found in the DICOM file)
136 vtkGetMacro(LoadIconImage,int);
137 vtkSetMacro(LoadIconImage,int);
138 vtkBooleanMacro(LoadIconImage,int);
139
140 // Description:
141 // Set/Get whether or not the image was compressed using a lossy compression algorithm
142 vtkGetMacro(LossyFlag,int);
143 vtkSetMacro(LossyFlag,int);
144 vtkBooleanMacro(LossyFlag,int);
145
146 // Description:
147 // Read only: number of overlays as found in this image (multiple overlays per slice is allowed)
148 // Only valid when LoadOverlays is true
149 vtkGetMacro(NumberOfOverlays,int);
150
151 // Description:
152 // Read only: number of icon image (there can only be zero or one icon per file)
153 // Only valid when LoadIconImage is true
154 vtkGetMacro(NumberOfIconImages,int);
155
156 // Description:
157 // Get Overlay/IconImage
158 // Remember to ALWAYS use those methods in your code, as the internal number for the output port
159 // is not guaranteed to remain the same, as features are added to the reader
160 vtkAlgorithmOutput* GetOverlayPort(int index);
161 vtkAlgorithmOutput* GetIconImagePort();
162 vtkImageData* GetOverlay(int i);
163 vtkImageData* GetIconImage();
164
165 // Description:
166 // Load image with its associated Lookup Table
167 vtkGetMacro(ApplyLookupTable,int);
168 vtkSetMacro(ApplyLookupTable,int);
169 vtkBooleanMacro(ApplyLookupTable,int);
170
171 // Description:
172 // Load image as YBR
173 vtkGetMacro(ApplyYBRToRGB,int)
174 vtkSetMacro(ApplyYBRToRGB,int)
175 vtkBooleanMacro(ApplyYBRToRGB,int);
176
177 // Description:
178 // Return VTK_LUMINANCE, VTK_INVERSE_LUMINANCE, VTK_RGB, VTK_RGBA, VTK_LOOKUP_TABLE, VTK_YBR or VTK_CMYK
179 // or 0 when ImageFormat is not handled.
180 // Warning: For color image, PlanarConfiguration need to be taken into account.
181 vtkGetMacro(ImageFormat,int);
182
183 // Description:
184 // Return the Planar Configuration. This simply means that the internal DICOM image was stored
185 // using a particular planar configuration (most of the time: 0)
186 // For monochrome image, PlanarConfiguration is always 0
187 vtkGetMacro(PlanarConfiguration,int);
188
189 // Description:
190 // Return the 'raw' information stored in the DICOM file:
191 // In case of a series of multiple files, only the first file is considered. The Image Orientation (Patient)
192 // is guaranteed to remain the same, and image Image Position (Patient) in other slice can be computed
193 // using the ZSpacing (3rd dimension)
194 // (0020,0032) DS [87.774866\-182.908510\168.629671] # 32, 3 ImagePositionPatient
195 // (0020,0037) DS [0.001479\0.999989\-0.004376\-0.002039\-0.004372\-0.999988] # 58, 6 ImageOrientationPatient
196 vtkGetVector3Macro(ImagePositionPatient,double);
197 vtkGetVector6Macro(ImageOrientationPatient,double);
198
199 // Description:
200 // Set/Get the first Curve Data:
201 vtkGetObjectMacro(Curve,vtkPolyData);
202 virtual void SetCurve(vtkPolyData *pd);
203
204 // Description:
205 // \DEPRECATED:
206 // Modality LUT
207 // Value returned by GetShift/GetScale might be inaccurate since Shift/Scale could be
208 // varying along the Series read. Therefore user are advices not to use those functions
209 // anymore
210 vtkGetMacro(Shift,double);
211 vtkGetMacro(Scale,double);
212
213protected:
214 vtkGDCMImageReader2();
215 ~vtkGDCMImageReader2();
216
217 vtkSetVector6Macro(ImageOrientationPatient,double);
218
219//BTX
220 void FillMedicalImageInformation(const gdcm::ImageReader &reader);
221//ETX
222 int RequestInformationCompat();
223 int RequestDataCompat();
224
225 int ProcessRequest(vtkInformation* request,
226 vtkInformationVector** inputVector,
227 vtkInformationVector* outputVector);
228 int RequestInformation(vtkInformation *request,
229 vtkInformationVector **inputVector,
230 vtkInformationVector *outputVector);
231 int RequestData(vtkInformation *request,
232 vtkInformationVector **inputVector,
233 vtkInformationVector *outputVector);
234
235protected:
236 vtkMatrix4x4 *DirectionCosines;
237 int LoadOverlays;
238 int NumberOfOverlays;
239 int LoadIconImage;
240 int NumberOfIconImages;
241 int IconImageDataExtent[6];
242 double ImagePositionPatient[3];
243 double ImageOrientationPatient[6];
244 vtkPolyData *Curve;
245
246 int ImageFormat;
247 // the following 3, should remain optional
248 int ApplyInverseVideo;
249 int ApplyLookupTable;
250 int ApplyYBRToRGB;
251 // I think that planar configuration need to always be applied as far as VTK is concerned
252 int ApplyPlanarConfiguration;
253 int ApplyShiftScale;
254
255 int LoadSingleFile(const char *filename, char *pointer, unsigned long &outlen);
256
257 double Shift;
258 double Scale;
259 int IconDataScalarType;
260 int IconNumberOfScalarComponents;
261 int PlanarConfiguration;
262 int LossyFlag;
263 int ForceRescale;
264
265protected:
266 // TODO / FIXME
267 void SetFilePrefix(const char *) {}
268 vtkGetStringMacro(FilePrefix);
269 void SetFilePattern(const char *) {}
270 vtkGetStringMacro(FilePattern);
271
272 private:
273 vtkGDCMImageReader2(const vtkGDCMImageReader2&); // Not implemented.
274 void operator=(const vtkGDCMImageReader2&); // Not implemented.
275};
276#endif
vtkGDCMImageReader2::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkGDCMImageReader2::ForceRescale
int ForceRescale
Definition vtkGDCMImageReader2.h:263
vtkGDCMImageReader2::ApplyShiftScale
int ApplyShiftScale
Definition vtkGDCMImageReader2.h:253
vtkGDCMImageReader2::IconDataScalarType
int IconDataScalarType
Definition vtkGDCMImageReader2.h:259
vtkGDCMImageReader2::vtkGetMacro
vtkGetMacro(ApplyYBRToRGB, int) vtkSetMacro(ApplyYBRToRGB
vtkGDCMImageReader2::vtkSetVector6Macro
vtkSetVector6Macro(ImageOrientationPatient, double)
vtkGDCMImageReader2::DirectionCosines
vtkMatrix4x4 * DirectionCosines
Definition vtkGDCMImageReader2.h:236
vtkGDCMImageReader2::vtkGetMacro
vtkGetMacro(NumberOfIconImages, int)
vtkGDCMImageReader2::CanReadFile
virtual int CanReadFile(const char *fname)
vtkGDCMImageReader2::vtkGetStringMacro
vtkGetStringMacro(FilePrefix)
vtkGDCMImageReader2::vtkSetMacro
vtkSetMacro(LoadOverlays, int)
vtkGDCMImageReader2::LoadSingleFile
int LoadSingleFile(const char *filename, char *pointer, unsigned long &outlen)
vtkGDCMImageReader2::SetMedicalImageProperties
virtual void SetMedicalImageProperties(vtkMedicalImageProperties *pd)
vtkGDCMImageReader2::New
static vtkGDCMImageReader2 * New()
vtkGDCMImageReader2::IconImageDataExtent
int IconImageDataExtent[6]
Definition vtkGDCMImageReader2.h:241
vtkGDCMImageReader2::NumberOfIconImages
int NumberOfIconImages
Definition vtkGDCMImageReader2.h:240
vtkGDCMImageReader2::SetCurve
virtual void SetCurve(vtkPolyData *pd)
vtkGDCMImageReader2::ProcessRequest
int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkGDCMImageReader2::vtkGDCMImageReader2
vtkGDCMImageReader2()
vtkGDCMImageReader2::vtkSetMacro
vtkSetMacro(LoadIconImage, int)
vtkGDCMImageReader2::ImagePositionPatient
double ImagePositionPatient[3]
Definition vtkGDCMImageReader2.h:242
vtkGDCMImageReader2::IconNumberOfScalarComponents
int IconNumberOfScalarComponents
Definition vtkGDCMImageReader2.h:260
vtkGDCMImageReader2::Scale
double Scale
Definition vtkGDCMImageReader2.h:258
vtkGDCMImageReader2::ImageFormat
int ImageFormat
Definition vtkGDCMImageReader2.h:246
vtkGDCMImageReader2::GetFileExtensions
virtual const char * GetFileExtensions()
Definition vtkGDCMImageReader2.h:107
vtkGDCMImageReader2::GetOverlay
vtkImageData * GetOverlay(int i)
vtkGDCMImageReader2::ApplyInverseVideo
int ApplyInverseVideo
Definition vtkGDCMImageReader2.h:248
vtkGDCMImageReader2::RequestDataCompat
int RequestDataCompat()
vtkGDCMImageReader2::SetFilePattern
void SetFilePattern(const char *)
Definition vtkGDCMImageReader2.h:269
vtkGDCMImageReader2::ImageOrientationPatient
double ImageOrientationPatient[6]
Definition vtkGDCMImageReader2.h:243
vtkGDCMImageReader2::vtkBooleanMacro
vtkBooleanMacro(LossyFlag, int)
vtkGDCMImageReader2::vtkGetMacro
vtkGetMacro(LoadOverlays, int)
vtkGDCMImageReader2::vtkBooleanMacro
vtkBooleanMacro(LoadIconImage, int)
vtkGDCMImageReader2::GetDescriptiveName
virtual const char * GetDescriptiveName()
Definition vtkGDCMImageReader2.h:115
vtkGDCMImageReader2::Shift
double Shift
Definition vtkGDCMImageReader2.h:257
vtkGDCMImageReader2::vtkGetVector6Macro
vtkGetVector6Macro(ImageOrientationPatient, double)
vtkGDCMImageReader2::vtkTypeMacro
vtkTypeMacro(vtkGDCMImageReader2, vtkMedicalImageReader2)
vtkGDCMImageReader2::vtkBooleanMacro
vtkBooleanMacro(ApplyLookupTable, int)
vtkGDCMImageReader2::GetOverlayPort
vtkAlgorithmOutput * GetOverlayPort(int index)
vtkGDCMImageReader2::vtkGetMacro
vtkGetMacro(LoadIconImage, int)
vtkGDCMImageReader2::Curve
vtkPolyData * Curve
Definition vtkGDCMImageReader2.h:244
vtkGDCMImageReader2::vtkSetMacro
vtkSetMacro(ApplyLookupTable, int)
vtkGDCMImageReader2::LoadIconImage
int LoadIconImage
Definition vtkGDCMImageReader2.h:239
vtkGDCMImageReader2::vtkGetMacro
vtkGetMacro(NumberOfOverlays, int)
vtkGDCMImageReader2::FillMedicalImageInformation
void FillMedicalImageInformation(const gdcm::ImageReader &reader)
vtkGDCMImageReader2::LossyFlag
int LossyFlag
Definition vtkGDCMImageReader2.h:262
vtkGDCMImageReader2::vtkSetMacro
vtkSetMacro(LossyFlag, int)
vtkGDCMImageReader2::PlanarConfiguration
int PlanarConfiguration
Definition vtkGDCMImageReader2.h:261
vtkGDCMImageReader2::vtkGetMacro
vtkGetMacro(LossyFlag, int)
vtkGDCMImageReader2::ApplyPlanarConfiguration
int ApplyPlanarConfiguration
Definition vtkGDCMImageReader2.h:252
vtkGDCMImageReader2::SetFilePrefix
void SetFilePrefix(const char *)
Definition vtkGDCMImageReader2.h:267
vtkGDCMImageReader2::vtkGetObjectMacro
vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4)
vtkGDCMImageReader2::ApplyYBRToRGB
int ApplyYBRToRGB
Definition vtkGDCMImageReader2.h:250
vtkGDCMImageReader2::LoadOverlays
int LoadOverlays
Definition vtkGDCMImageReader2.h:237
vtkGDCMImageReader2::RequestInformationCompat
int RequestInformationCompat()
vtkGDCMImageReader2::RequestInformation
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkGDCMImageReader2::vtkGetVector3Macro
vtkGetVector3Macro(ImagePositionPatient, double)
vtkGDCMImageReader2::GetIconImage
vtkImageData * GetIconImage()
vtkGDCMImageReader2::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkGDCMImageReader2::ApplyLookupTable
int ApplyLookupTable
Definition vtkGDCMImageReader2.h:249
vtkGDCMImageReader2::vtkGetStringMacro
vtkGetStringMacro(FilePattern)
vtkGDCMImageReader2::vtkBooleanMacro
vtkBooleanMacro(LoadOverlays, int)
vtkGDCMImageReader2::vtkGetMacro
vtkGetMacro(ApplyLookupTable, int)
vtkGDCMImageReader2::GetIconImagePort
vtkAlgorithmOutput * GetIconImagePort()
vtkGDCMImageReader2::NumberOfOverlays
int NumberOfOverlays
Definition vtkGDCMImageReader2.h:238
gdcm
Definition gdcmASN1.h:21