]> Creatis software - clitk.git/blob - common/vvImage.h
The lower and upper options can be tuned for all type of region growing algorithm
[clitk.git] / common / vvImage.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
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 copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef VVIMAGE_H
19 #define VVIMAGE_H
20
21 #include <iostream>
22 #include <vector>
23 #include <itkObjectFactory.h>
24 #include <itkProcessObject.h>
25 #include <itkMinimumMaximumImageCalculator.h>
26 #include <itkCastImageFilter.h>
27
28 #define VTK_EXCLUDE_STRSTREAM_HEADERS
29 #include <vtkSmartPointer.h>
30 #include <vtkTransform.h>
31
32 class vtkImageData;
33
34 //------------------------------------------------------------------------------
35 class vvImage : public itk::LightObject
36 {
37 public :
38   typedef vvImage Self;
39   typedef itk::SmartPointer<Self> Pointer;
40   typedef itk::ProcessObject::Pointer ConverterPointer;
41   itkNewMacro(Self);
42   
43   struct DimensionDispatchBase {};
44   template< unsigned int VDimension >
45   struct DimensionDispatch:public DimensionDispatchBase {};
46
47   void Init();
48   void Reset();
49   template<class TItkImageType> void AddItkImage(TItkImageType *input);
50   void AddVtkImage(vtkImageData* input);
51   const std::vector<vtkImageData*>& GetVTKImages();
52   vtkImageData* GetFirstVTKImageData();
53   int GetNumberOfDimensions() const;
54   int GetNumberOfSpatialDimensions();
55   void GetScalarRange(double* range);
56   template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRangeBase(itk::Image<TPixelType,VImageDimension> *input);
57   template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRange(DimensionDispatchBase, itk::Image<TPixelType,VImageDimension> *input);
58   template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRange(DimensionDispatch< 1 >, itk::Image<TPixelType,VImageDimension> *input);
59   unsigned long GetActualMemorySize();
60   std::vector<double> GetSpacing();
61   std::vector<double> GetOrigin() const;
62   std::vector<int> GetSize();
63   std::vector< std::vector<double> > GetDirection();
64   std::string GetScalarTypeAsITKString();
65   int GetNumberOfScalarComponents();
66   int GetScalarSize();
67   bool IsTimeSequence() const;
68   bool IsScalarTypeInteger();
69   bool IsScalarTypeInteger(int t);
70   const std::vector< vtkSmartPointer<vtkTransform> >& GetTransform();
71   void InitializeTransform();
72   void SetTimeSpacing(double s) { mTimeSpacing = s; }
73   void SetTimeOrigin(double o) { mTimeOrigin = o; }
74   bool HaveSameSizeAndSpacingThan(vvImage * other);
75   //META DATA
76   itk::MetaDataDictionary* GetFirstMetaDataDictionary();
77
78 private:
79   vvImage();
80   ~vvImage();
81
82   std::vector< ConverterPointer > mItkToVtkConverters;
83   std::vector< vtkImageData* > mVtkImages;
84   std::vector< vtkSmartPointer<vtkTransform> > mTransform;
85   //META DATA
86   std::vector< itk::MetaDataDictionary* > mDictionary;
87
88   double mTimeOrigin;
89   double mTimeSpacing;
90   unsigned int mImageDimension;
91   double mrange[2];
92 };
93 //------------------------------------------------------------------------------
94
95 #include "vvImage.txx"
96
97 #endif