GDCM  2.4.5
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 instanciated 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 conjonction 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 "vtkMedicalImageReader2.h"
68 #include "vtkImageData.h"
69 
70 class vtkPolyData;
71 
72 // vtkSystemIncludes.h defines:
73 // #define VTK_LUMINANCE 1
74 // #define VTK_LUMINANCE_ALPHA 2
75 // #define VTK_RGB 3
76 // #define VTK_RGBA 4
77 #ifndef VTK_INVERSE_LUMINANCE
78 #define VTK_INVERSE_LUMINANCE 5
79 #endif
80 #ifndef VTK_LOOKUP_TABLE
81 #define VTK_LOOKUP_TABLE 6
82 #endif
83 #ifndef VTK_YBR
84 #define VTK_YBR 7
85 #endif
86 #ifndef VTK_CMYK
87 #define VTK_CMYK 8
88 #endif
89 
90 //BTX
91 namespace gdcm { class ImageReader; }
92 //ETX
93 class vtkMatrix4x4;
94 class VTK_EXPORT vtkGDCMImageReader2 : public vtkMedicalImageReader2
95 {
96 public:
97  static vtkGDCMImageReader2 *New();
98  vtkTypeRevisionMacro(vtkGDCMImageReader2,vtkMedicalImageReader2);
99  virtual void PrintSelf(ostream& os, vtkIndent indent);
100 
101  // Description: is the given file name a DICOM file containing an image ?
102  virtual int CanReadFile(const char* fname);
103 
104  // Description:
105  // Valid extensions
106  virtual const char* GetFileExtensions()
107  {
108  // I would like to get rid of ACR/NEMA/IMA so only allow dcm extension for now
109  return ".dcm .DCM";
110  }
111 
112  // Description:
113  // A descriptive name for this format
114  virtual const char* GetDescriptiveName()
115  {
116  return "DICOM";
117  }
118 
119  // Description:
120  // Get the Image Position (Patient) as stored in the DICOM file
121  // This is a read-only data member
122  vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4);
123 
124  virtual void SetMedicalImageProperties(vtkMedicalImageProperties *pd);
125 
126  // Description:
127  // Specifically request to load the overlay into the gdcm-VTK layer (gdcm always loads them when found).
128  // If no overlay is found in the image, then the vtkImageData for the overlay will be empty.
129  vtkGetMacro(LoadOverlays,int);
130  vtkSetMacro(LoadOverlays,int);
131  vtkBooleanMacro(LoadOverlays,int);
132 
133  // Description:
134  // Set/Get whether or not to load the Icon as vtkImageData (if found in the DICOM file)
135  vtkGetMacro(LoadIconImage,int);
136  vtkSetMacro(LoadIconImage,int);
137  vtkBooleanMacro(LoadIconImage,int);
138 
139  // Description:
140  // Set/Get whether or not the image was compressed using a lossy compression algorithm
141  vtkGetMacro(LossyFlag,int);
142  vtkSetMacro(LossyFlag,int);
143  vtkBooleanMacro(LossyFlag,int);
144 
145  // Description:
146  // Read only: number of overlays as found in this image (multiple overlays per slice is allowed)
147  // Only valid when LoadOverlays is true
148  vtkGetMacro(NumberOfOverlays,int);
149 
150  // Description:
151  // Read only: number of icon image (there can only be zero or one icon per file)
152  // Only valid when LoadIconImage is true
153  vtkGetMacro(NumberOfIconImages,int);
154 
155  // Description:
156  // Get Overlay/IconImage
157  // Remember to ALWAYS use those methods in your code, as the internal number for the output port
158  // is not garantee to remain the same, as features are added to the reader
159  vtkAlgorithmOutput* GetOverlayPort(int index);
160  vtkAlgorithmOutput* GetIconImagePort();
161  vtkImageData* GetOverlay(int i);
162  vtkImageData* GetIconImage();
163 
164  // Description:
165  // Load image with its associated Lookup Table
166  vtkGetMacro(ApplyLookupTable,int);
167  vtkSetMacro(ApplyLookupTable,int);
168  vtkBooleanMacro(ApplyLookupTable,int);
169 
170  // Description:
171  // Load image as YBR
172  vtkGetMacro(ApplyYBRToRGB,int)
173  vtkSetMacro(ApplyYBRToRGB,int)
174  vtkBooleanMacro(ApplyYBRToRGB,int);
175 
176  // Description:
177  // Return VTK_LUMINANCE, VTK_INVERSE_LUMINANCE, VTK_RGB, VTK_RGBA, VTK_LOOKUP_TABLE, VTK_YBR or VTK_CMYK
178  // or 0 when ImageFormat is not handled.
179  // Warning: For color image, PlanarConfiguration need to be taken into account.
180  vtkGetMacro(ImageFormat,int);
181 
182  // Description:
183  // Return the Planar Configuration. This simply means that the internal DICOM image was stored
184  // using a particular planar configuration (most of the time: 0)
185  // For monochrome image, PlanarConfiguration is always 0
186  vtkGetMacro(PlanarConfiguration,int);
187 
188  // Description:
189  // Return the 'raw' information stored in the DICOM file:
190  // In case of a series of multiple files, only the first file is considered. The Image Orientation (Patient)
191  // is garantee to remain the same, and image Image Position (Patient) in other slice can be computed
192  // using the ZSpacing (3rd dimension)
193  // (0020,0032) DS [87.774866\-182.908510\168.629671] # 32, 3 ImagePositionPatient
194  // (0020,0037) DS [0.001479\0.999989\-0.004376\-0.002039\-0.004372\-0.999988] # 58, 6 ImageOrientationPatient
195  vtkGetVector3Macro(ImagePositionPatient,double);
196  vtkGetVector6Macro(ImageOrientationPatient,double);
197 
198  // Description:
199  // Set/Get the first Curve Data:
200  vtkGetObjectMacro(Curve,vtkPolyData);
201  virtual void SetCurve(vtkPolyData *pd);
202 
203  // Description:
204  // \DEPRECATED:
205  // Modality LUT
206  // Value returned by GetShift/GetScale might be innacurate since Shift/Scale could be
207  // varying along the Series read. Therefore user are advices not to use those functions
208  // anymore
209  vtkGetMacro(Shift,double);
210  vtkGetMacro(Scale,double);
211 
212 protected:
214  ~vtkGDCMImageReader2();
215 
216  vtkSetVector6Macro(ImageOrientationPatient,double);
217 
218 //BTX
219  void FillMedicalImageInformation(const gdcm::ImageReader &reader);
220 //ETX
221  int RequestInformationCompat();
222  int RequestDataCompat();
223 
224  int ProcessRequest(vtkInformation* request,
225  vtkInformationVector** inputVector,
226  vtkInformationVector* outputVector);
227  int RequestInformation(vtkInformation *request,
228  vtkInformationVector **inputVector,
229  vtkInformationVector *outputVector);
230  int RequestData(vtkInformation *request,
231  vtkInformationVector **inputVector,
232  vtkInformationVector *outputVector);
233 
234 protected:
235  vtkMatrix4x4 *DirectionCosines;
236  int LoadOverlays;
237  int NumberOfOverlays;
238  int LoadIconImage;
239  int NumberOfIconImages;
240  int IconImageDataExtent[6];
241  double ImagePositionPatient[3];
242  double ImageOrientationPatient[6];
243  vtkPolyData *Curve;
244 
245  int ImageFormat;
246  // the following 3, should remain optional
247  int ApplyInverseVideo;
248  int ApplyLookupTable;
249  int ApplyYBRToRGB;
250  // I think that planar configuration need to always be applied as far as VTK is concerned
251  int ApplyPlanarConfiguration;
252  int ApplyShiftScale;
253 
254  int LoadSingleFile(const char *filename, char *pointer, unsigned long &outlen);
255 
256  double Shift;
257  double Scale;
258  int IconDataScalarType;
259  int IconNumberOfScalarComponents;
260  int PlanarConfiguration;
261  int LossyFlag;
262  int ForceRescale;
263 
264 protected:
265  // TODO / FIXME
266  void SetFilePrefix(const char *) {}
267  vtkGetStringMacro(FilePrefix);
268  void SetFilePattern(const char *) {}
269  vtkGetStringMacro(FilePattern);
270 
271 private:
272  vtkGDCMImageReader2(const vtkGDCMImageReader2&); // Not implemented.
273  void operator=(const vtkGDCMImageReader2&); // Not implemented.
274 };
275 #endif
virtual const char * GetFileExtensions()
Definition: vtkGDCMImageReader2.h:106
virtual const char * GetDescriptiveName()
Definition: vtkGDCMImageReader2.h:114
void SetFilePattern(const char *)
Definition: vtkGDCMImageReader2.h:268
Definition: vtkGDCMImageReader2.h:94
Definition: gdcmASN1.h:20

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