# vtkGDCMImageWriter.h

Go to the documentation of this file.

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