GDCM 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

vtkGDCMImageWriter.h
Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004
    00005   Copyright (c) 2006-2011 Mathieu Malaterre
    00006   All rights reserved.
    00007   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00008
    00009      This software is distributed WITHOUT ANY WARRANTY; without even
    00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00011      PURPOSE.  See the above copyright notice for more information.
    00012
    00013 =========================================================================*/
    00014 // .NAME vtkGDCMImageWriter - write DICOM files
    00015 // .SECTION Description
    00016 // vtkGDCMImageWriter is a sink object that write DICOM files
    00017 // this writer is single threaded (see vtkGDCMThreadedImageReader2 for multi-thread)
    00018 //
    00019 // .SECTION Warning: vtkLookupTable from the vtkImageData object taken into account
    00020 // only if ImageFormat is set to VTK_LOOKUP_TABLE
    00021 //
    00022 // .SECTION NOTE We are not using the usual API SetFilePrefix / SetFilePattern,
    00023 // but instead a list of filenames: see SetFileNames and class gdcm::FilenameGenerator
    00024 //
    00025 // .SECTION Warning
    00026 // You need to specify the correct ImageFormat (taken from the reader)
    00027 // You need to explicitely specify the DirectionCosines (taken from the reader)
    00028 // Since VTK 5.4 vtkMedicalImageProperties has its own DirectionCosine (no 's')
    00029 // user need to make sure the vtkMatrix4x4 is compatible with the 6-vector DirectionCosine.
    00030 //
    00031 // .SECTION NOTE Shift/Scale are global to all DICOM frames (=files) written
    00032 // as 2D slice, therefore the shift/scale operation might not be optimized for
    00033 // all slices. This is not recommended for image with a large dynamic range.
    00034 //
    00035 // .SECTION See Also
    00036 // vtkImageWriter vtkMedicalImageProperties vtkGDCMImageReader
    00037
    00038 #ifndef VTKGDCMIMAGEWRITER_H
    00039 #define VTKGDCMIMAGEWRITER_H
    00040
    00041 #include "vtkImageWriter.h"
    00042
    00043 class vtkLookupTable;
    00044 class vtkMedicalImageProperties;
    00045 class vtkMatrix4x4;
    00046 class vtkStringArray;
    00047 class VTK_EXPORT vtkGDCMImageWriter : public vtkImageWriter
    00048 {
    00049 public:
    00050   static vtkGDCMImageWriter *New();
    00051   vtkTypeRevisionMacro(vtkGDCMImageWriter,vtkImageWriter);
    00052   virtual void PrintSelf(ostream& os, vtkIndent indent);
    00053
    00054   // Description:
    00055   // Pass in the vtkmedicalimageproperties object for medical information
    00056   // to be mapped to DICOM attributes.
    00057   vtkGetObjectMacro(MedicalImageProperties, vtkMedicalImageProperties);
    00058   virtual void SetMedicalImageProperties(vtkMedicalImageProperties*);
    00059
    00060   // Description:
    00061   // Pass in the list of filename to be used to write out the DICOM file(s)
    00062   virtual void SetFileNames(vtkStringArray*);
    00063   vtkGetObjectMacro(FileNames, vtkStringArray);
    00064
    00065   // Description:
    00066   // Set/Get whether or not the image was compressed using a lossy compression algorithm
    00067   vtkGetMacro(LossyFlag,int);
    00068   vtkSetMacro(LossyFlag,int);
    00069   vtkBooleanMacro(LossyFlag,int);
    00070
    00071   // I need that...
    00072   virtual void Write();
    00073
    00074   // Description:
    00075   // Get the entension for this file format.
    00076   virtual const char* GetFileExtensions() {
    00077     return ".dcm .DCM"; }
    00078
    00079   // Description:
    00080   // Get the name of this file format.
    00081   virtual const char* GetDescriptiveName() {
    00082     return "DICOM"; }
    00083
    00084   // Description:
    00085   // You need to manually specify the direction the image is in to write a valid DICOM file
    00086   // since vtkImageData do not contains one (eg. MR Image Storage, CT Image Storage...)
    00087   virtual void SetDirectionCosines(vtkMatrix4x4 *matrix);
    00088   vtkGetObjectMacro(DirectionCosines, vtkMatrix4x4);
    00089   virtual void SetDirectionCosinesFromImageOrientationPatient(const double dircos[6]);
    00090
    00091   // Description:
    00092   // Modality LUT
    00093   vtkSetMacro(Shift, double);
    00094   vtkGetMacro(Shift, double);
    00095   vtkSetMacro(Scale, double);
    00096   vtkGetMacro(Scale, double);
    00097
    00098   // Description:
    00099   // See vtkGDCMImageReader for list of ImageFormat
    00100   vtkGetMacro(ImageFormat,int);
    00101   vtkSetMacro(ImageFormat,int);
    00102
    00103   // Description:
    00104   // Set/Get whether the data comes from the file starting in the lower left
    00105   // corner or upper left corner.
    00106   vtkBooleanMacro(FileLowerLeft, int);
    00107   vtkGetMacro(FileLowerLeft, int);
    00108   vtkSetMacro(FileLowerLeft, int);
    00109
    00110   // Description:
    00111   // For color image (more than a single comp) you can specify the planar configuration you prefer
    00112   vtkSetMacro(PlanarConfiguration,int);
    00113   vtkGetMacro(PlanarConfiguration,int);
    00114
    00115   // Description:
    00116   // Set/Get specific StudyUID / SeriesUID
    00117   vtkSetStringMacro(StudyUID);
    00118   vtkGetStringMacro(StudyUID);
    00119   vtkSetStringMacro(SeriesUID);
    00120   vtkGetStringMacro(SeriesUID);
    00121
    00122 //BTX
    00123   enum CompressionTypes {
    00124     NO_COMPRESSION = 0,   // raw (default)
    00125     JPEG_COMPRESSION,     // JPEG
    00126     JPEG2000_COMPRESSION, // J2K
    00127     JPEGLS_COMPRESSION,   // JPEG-LS
    00128     RLE_COMPRESSION       // RLE
    00129   };
    00130 //ETX
    00131   // Set/Get the compression type
    00132   vtkSetMacro(CompressionType, int);
    00133   vtkGetMacro(CompressionType, int);
    00134
    00135   //void SetCompressionTypeFromString(const char *);
    00136   //const char *GetCompressionTypeAsString();
    00137
    00138 protected:
    00139   vtkGDCMImageWriter();
    00140   ~vtkGDCMImageWriter();
    00141
    00142 #if (VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 5 )
    00143   int FillInputPortInformation(int port, vtkInformation *info);
    00144   int RequestInformation(
    00145     vtkInformation *request,
    00146     vtkInformationVector **inputVector,
    00147     vtkInformationVector *outputVector);
    00148   int RequestUpdateExtent(
    00149     vtkInformation *request,
    00150     vtkInformationVector **inputVector,
    00151     vtkInformationVector *outputVector);
    00152   int RequestData(
    00153     vtkInformation *request,
    00154     vtkInformationVector **inputVector,
    00155     vtkInformationVector *outputVector);
    00156 #else
    00157   void WriteSlice(vtkImageData *data);
    00158 #endif /*(VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 5 )*/
    00159   int WriteGDCMData(vtkImageData *data, int timeStep);
    00160
    00161 protected:
    00162   virtual /*const*/ char *GetFileName();
    00163
    00164 private:
    00165   vtkGDCMImageWriter(const vtkGDCMImageWriter&);  // Not implemented.
    00166   void operator=(const vtkGDCMImageWriter&);  // Not implemented.
    00167
    00168   // VTK structs:
    00169   //vtkLookupTable *LookupTable;
    00170   vtkMedicalImageProperties *MedicalImageProperties;
    00171   char *StudyUID;
    00172   char *SeriesUID;
    00173
    00174   int DataUpdateExtent[6];
    00175   int ImageFormat;
    00176
    00177   vtkStringArray *FileNames;
    00178   vtkMatrix4x4 *DirectionCosines;
    00179
    00180   double Shift;
    00181   double Scale;
    00182   int FileLowerLeft;
    00183   int PlanarConfiguration;
    00184   int LossyFlag;
    00185   int CompressionType;
    00186 };
    00187
    00188 #endif