aimstil  5.0.5
BasicPixelActions.h
Go to the documentation of this file.
1 #ifndef TIL_BASIC_PIXEL_ACTIONS_H
2 #define TIL_BASIC_PIXEL_ACTIONS_H
3 
4 // Local includes
5 #include "til/til_common.h"
6 #include "til/numeric_array.h"
7 
8 
9 // Namespace
10 
11 namespace til {
12 
13  // predeclaration
14  template < class TImage > struct Iterator;
15 
16 template < class _TImage >
18 {
19 
20 public: // typedefs
21 
22  typedef _TImage TImage;
23  typedef typename TImage::value_type value_type;
25 
26 public: // constuctors & destructor
27 
28  PA_SingleValue() { this->setValue(0); }
29  PA_SingleValue(value_type value) { this->setValue(value); }
30 
31 public: // set & get
32 
33  void setValue(value_type value) { m_value = value; }
34  void setImage(const TImage &im) { m_im.shallowCopy(im); }
35 
36  value_type getValue() const { return m_value; }
37  TImage & image() const { return m_im; }
38 
39 public: // functions
40 
41  static void next() {}
42 
43 private: // data
44 
45  TImage m_im;
46  value_type m_value;
47 };
48 
49 
50 
51 
52 template < class TImage >
53 class PA_SetValue : public PA_SingleValue<TImage>
54 {
55 public:
56  typedef typename TImage::value_type value_type;
58 
59 public: // constuctors & destructor
60 
61  PA_SetValue(value_type value) : PA_SingleValue<TImage>(value) {}
62 
63 
64 public: // function
65 
66 
67  INLINE void apply(const VolumetricIterator &iIm) const
68  {
69  *iIm = this->getValue();
70  }
71 
72 
73  void apply(const numeric_array<int,3> &pos) const
74  {
75  (*(this->image()))(pos) = this->getValue();
76  }
77 };
78 
79 
80 template < class TImage >
82 {
83 
84 public: // typedefs
85 
87  typedef typename TImage::value_type value_type;
88 
89 public: // constuctors & destructor
90 
91  PA_CopyImage(TImage &im) : m_iIm(im) {}
92 
93 public: // functions
94 
95  void next() { ++m_iIm; }
96 
97  void apply(const VolumetricIterator &iIm)
98  {
99  *iIm = *m_iIm;
100  }
101 
102  void apply(const numeric_array<int,3> &pos)
103  {
104  (*(this->image()))(pos) = m_im.getValue(pos);
105  }
106 
107 private: // data
108 
109  TImage m_im;
110  typename Iterator<TImage>::Linear m_iIm;
111 };
112 
113 
114 } // namespace
115 
116 
117 #endif
118 
A trait class to assign iterators to image types.
void setImage(const TImage &im)
value_type getValue() const
PA_SingleValue(value_type value)
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
Iterator< TImage >::Volumetric VolumetricIterator
PA_CopyImage(TImage &im)
INLINE void apply(const VolumetricIterator &iIm) const
General macros, definitions and functions.
void setValue(value_type value)
TImage::value_type value_type
#define INLINE
Definition: til_common.h:26
void apply(const VolumetricIterator &iIm)
PA_SetValue(value_type value)
Iterator< TImage >::Volumetric VolumetricIterator
void apply(const numeric_array< int, 3 > &pos)
TImage::value_type value_type
Iterator< TImage >::Volumetric VolumetricIterator
void apply(const numeric_array< int, 3 > &pos) const
TImage::value_type value_type
TImage & image() const