]> Creatis software - clitk.git/blob - common/clitkDicomRTStruct2ImageFilter.h
The lower and upper options can be tuned for all type of region growing algorithm
[clitk.git] / common / clitkDicomRTStruct2ImageFilter.h
1 /*=========================================================================
2   Program:         vv http://www.creatis.insa-lyon.fr/rio/vv
3   Main authors :   XX XX XX
4
5   Authors belongs to: 
6   - University of LYON           http://www.universite-lyon.fr/
7   - Léon Bérard cancer center    http://www.centreleonberard.fr
8   - CREATIS CNRS laboratory      http://www.creatis.insa-lyon.fr
9
10   This software is distributed WITHOUT ANY WARRANTY; without even
11   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12   PURPOSE.  See the copyright notices for more information.
13
14   It is distributed under dual licence
15   - BSD       http://www.opensource.org/licenses/bsd-license.php
16   - CeCILL-B  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17
18   =========================================================================*/
19
20 #ifndef CLITKDICOMRTSTRUCT2IMAGEFILTER_H
21 #define CLITKDICOMRTSTRUCT2IMAGEFILTER_H
22
23 #include "clitkDicomRT_ROI.h"
24 #include "clitkImageCommon.h"
25 #include <vtkImageData.h>
26 #include <vtkMatrix4x4.h>
27 #include <itkImage.h>
28 #include <itkVTKImageToImageFilter.h>
29
30 namespace clitk {
31
32   //--------------------------------------------------------------------
33   class DicomRTStruct2ImageFilter {
34     
35   public:
36     DicomRTStruct2ImageFilter();
37     ~DicomRTStruct2ImageFilter();
38
39     void SetROI(clitk::DicomRT_ROI * roi);
40     ///This is used to create a mask with the same characteristics as an input image
41     void SetImage(vvImage::Pointer image);
42     void SetImageFilename(std::string s);
43     void SetOutputOrigin(const double* origin);
44     void SetOutputSpacing(const double* spacing);
45     void SetOutputSize(const unsigned long* size);
46     void SetOutputImageFilename(std::string s);
47     void SetWriteMesh(bool b);
48     void Update();    
49     vtkImageData * GetOutput();
50     template <int Dimension> typename itk::Image<unsigned char,Dimension>::ConstPointer GetITKOutput();
51     void SetCropMaskEnabled(bool b);
52     void SetWriteOutputFlag(bool b);
53
54   protected:
55     bool ImageInfoIsSet() const;
56     bool mWriteOutput;
57     bool mWriteMesh;
58     bool mCropMask;
59     std::string mOutputFilename;
60     std::vector<double> mSpacing;
61     std::vector<double> mOrigin;
62     std::vector<unsigned long> mSize;
63     std::vector< std::vector< double> > mDirection;
64     vtkSmartPointer<vtkMatrix4x4> mTransformMatrix;
65     clitk::DicomRT_ROI * mROI;
66     vtkSmartPointer<vtkImageData> mBinaryImage;
67   };
68   //--------------------------------------------------------------------
69
70 } // end namespace clitk
71
72
73 //--------------------------------------------------------------------
74
75 template <int Dimension> 
76 typename itk::Image<unsigned char,Dimension>::ConstPointer clitk::DicomRTStruct2ImageFilter::GetITKOutput()
77 {
78   assert(mBinaryImage);
79   typedef itk::Image<unsigned char,Dimension> ConnectorImageType;
80   typedef itk::VTKImageToImageFilter <ConnectorImageType> ConnectorType;
81   typename ConnectorType::Pointer connector = ConnectorType::New();
82   connector->SetInput(mBinaryImage);
83   connector->Update();
84   return connector->GetOutput();
85 }
86 //--------------------------------------------------------------------
87 #endif // CLITKDICOMRT_TRUCT2IMAGEFILTER_H
88