aimstil  5.0.5
ImageBase.h
Go to the documentation of this file.
1 #ifndef TIL_IMAGE_BASE_H
2 #define TIL_IMAGE_BASE_H
3 
4 // include from TIL library
5 #include "til/til_common.h"
6 #include "til/labels.h"
7 #include "til/numeric_array.h"
8 
9 namespace til
10 {
11 
13  typedef float t_voxsize;
14 
15 
19  class ImageBase : public Image_label
20  {
21 
22  public: // set & get
23 
24  // Get image dimensions
25  /*
26  INLINE int dim()[0] const { return m_dim.getX();} ///< get X dimension
27  INLINE int dim()[1] const { return m_dim.getY();} ///< get Y dimension
28  INLINE int dim()[2] const { return m_dim.getZ();} ///< get Z dimension
29 
30  int getDim(int i) const { return m_dim.get(i); } ///< get i-th dimension
31  const Vector<int,3> & getDim() const { return m_dim; } ///< get image dimension
32  */
33 
34  const numeric_array<int,3> & dim() const { return m_dim; }
35 
36 
38  int size() const { return this->dim()[0]*this->dim()[1]*this->dim()[2]; }
39 
40 
41  // Get voxel size
42  /*
43  t_voxsize vdim()[0] const { return m_vDim.getX(); } ///< get X voxel size
44  t_voxsize vdim()[1] const { return m_vDim.getY(); } ///< get Y voxel size
45  t_voxsize vdim()[2] const { return m_vDim.getZ(); } ///< get Z voxel size
46 
47  t_voxsize vdim(int i) const { return m_vDim.get(i); } ///< get i-th voxel size
48  */
49  const numeric_array<t_voxsize,3> & vdim() const { return m_vDim; }
50 
51 
52  // space origin
53  //const Vector<double,3> & origin() const { return m_ori; } ///< Get space origin.
54  //Vector<double,3> & origin() { return m_ori; } ///< Get space origin.
55 
56  // TODO: shouldn't this be private?
59  {
60  assert(all_greater_equal(vdim, t_voxsize(0)));
61  m_vDim = vdim;
62  }
63 
64  protected: // methods
65 
67  {
68  assert(all_greater_equal(dim,0));
69  m_dim = dim;
70  }
71 
72  // Test whether these coordinates fall into image range
73  /*
74  bool contains(int i, int j, int k) const
75  {
76  return (
77  i >= 0 &&
78  j >= 0 &&
79  k >= 0 &&
80  i < m_dim[0] &&
81  j < m_dim[1] &&
82  k < m_dim[2]
83  );
84  }
85  */
86  bool contains(const numeric_array<int,3> & p) const
87  {
88  return all_greater_equal(p, 0) && all_less(p, m_dim);
89  }
90 
91  private: // data
92 
93  // Image dimensions
95 
96  // Voxel size
98 
99  // TODO: this is crap actually. I mean, either you have a full matrix, that combines
100  // voxel size and orientation and everything, or you don't. This half-assed origin
101  // is useless because it doesn't account for axes flipping.
102  // Origin
103  //Vector<double,3> m_ori;
104  };
105 
106 
108  template < class TImage >
109  struct Iterator {};
110 
111 } // namespace
112 
113 
114 #endif
115 
A trait class to assign iterators to image types.
bool contains(const numeric_array< int, 3 > &p) const
Definition: ImageBase.h:86
void set_dim(const numeric_array< int, 3 > &dim)
Definition: ImageBase.h:66
const numeric_array< t_voxsize, 3 > & vdim() const
get voxel size
Definition: ImageBase.h:49
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
General macros, definitions and functions.
Defines empty classes that serves as labels.
void set_vdim(const numeric_array< t_voxsize, 3 > &vdim)
Set the voxel coordinates.
Definition: ImageBase.h:58
const numeric_array< int, 3 > & dim() const
get image dimension
Definition: ImageBase.h:34
Collects common code accross all image classes.
Definition: ImageBase.h:19
int size() const
Get total number of elements in image.
Definition: ImageBase.h:38
float t_voxsize
type of voxel size
Definition: ImageBase.h:13