iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageOperators.H
Go to the documentation of this file.
1 /*! @file
2  @author David J. Berg
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 
36 
37 namespace nrt
38 {
39 
40  /*! \defgroup ImageOperators Image Operators
41  Operator overloads for performing arithmetic operations on entire Images.
42 
43  The idea with the image operators is to defer everything to the pixel level operators. Consequently, as long as
44  the two pixels or pixel and pod type have arithmetic operators then we can enable the function. We can query these
45  properties through nrt_traits. Not we use a lambda instead of std binary functions (eg. std::plus) because those
46  calls will use some implict casts and we want our promotion mechanism in pixel to handle any type changes.
47 
48  \todo Clean up the enable_ifs, as this makes the doxygen generated documentation unreadable. Check out
49  http://stackoverflow.com/questions/3435225/c-meta-programming-doxygen-documentation for some ideas.
50 
51  \ingroup image */
52 
53  /*! @{ */ // **********************************************************************
54 
55  //! Operator to compute Image += Image
56  template <class PixType1, class PixType2> inline
57  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_assign_arithmetic, Image<PixType1> >::type &
58  operator+=(Image<PixType1>& lhs, Image<PixType2> const& rhs);
59 
60  //! Operator to compute Image += constant
61  template <class PixType1, class T> inline
62  typename std::enable_if<nrt_traits<PixType1, T>::has_assign_arithmetic, Image<PixType1> >::type &
63  operator+=(Image<PixType1>& lhs, T const& rhs);
64 
65  //! Operator to compute Image + Image
66  template <class PixType1, class PixType2> inline
67  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_arithmetic,
68  Image<typename nrt_traits<PixType1, PixType2>::promote_type> >::type
69  operator+(Image<PixType1> const& lhs, Image<PixType2> const& rhs);
70 
71  //! Operator to compute Image + constant
72  template <class PixType1, class T> inline
73  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
74  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
75  operator+(Image<PixType1> const& lhs, T const& rhs) ;
76 
77  //! Operator to compute constant + Image
78  template <class PixType1, class T> inline
79  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
80  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
81  operator+(T const& lhs, Image<PixType1> const& rhs);
82 
83 
84 
85 
86  //! Operator to compute Image -= Image
87  template <class PixType1, class PixType2> inline
88  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_assign_arithmetic, Image<PixType1> >::type &
89  operator-=(Image<PixType1>& lhs, Image<PixType2> const& rhs);
90 
91  //! Operator to compute Image -= constant
92  template <class PixType1, class T> inline
93  typename std::enable_if<nrt_traits<PixType1, T>::has_assign_arithmetic, Image<PixType1> >::type &
94  operator-=(Image<PixType1>& lhs, T const& rhs);
95 
96  //! Operator to compute Image - Image
97  template <class PixType1, class PixType2> inline
98  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_arithmetic,
99  Image<typename nrt_traits<PixType1, PixType2>::promote_type> >::type
100  operator-(Image<PixType1> const& lhs, Image<PixType2> const& rhs);
101 
102  //! Operator to compute Image - constant
103  template <class PixType1, class T> inline
104  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
105  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
106  operator-(Image<PixType1> const& lhs, T const& rhs) ;
107 
108  //! Operator to compute constant - Image
109  template <class PixType1, class T> inline
110  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
111  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
112  operator-(T const& lhs, Image<PixType1> const& rhs);
113 
114 
115 
116  //! Operator to compute Image *= Image
117  template <class PixType1, class PixType2> inline
118  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_assign_arithmetic, Image<PixType1> >::type &
119  operator*=(Image<PixType1>& lhs, Image<PixType2> const& rhs);
120 
121  //! Operator to compute Image *= constant
122  template <class PixType1, class T> inline
123  typename std::enable_if<nrt_traits<PixType1, T>::has_assign_arithmetic, Image<PixType1> >::type &
124  operator*=(Image<PixType1>& lhs, T const& rhs);
125 
126  //! Operator to compute Image * Image
127  template <class PixType1, class PixType2> inline
128  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_arithmetic,
129  Image<typename nrt_traits<PixType1, PixType2>::promote_type> >::type
130  operator*(Image<PixType1> const& lhs, Image<PixType2> const& rhs);
131 
132  //! Operator to compute Image * constant
133  template <class PixType1, class T> inline
134  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
135  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
136  operator*(Image<PixType1> const& lhs, T const& rhs) ;
137 
138  //! Operator to compute constant * Image
139  template <class PixType1, class T> inline
140  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
141  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
142  operator*(T const& lhs, Image<PixType1> const& rhs);
143 
144 
145 
146  //! Operator to compute Image /= Image
147  template <class PixType1, class PixType2> inline
148  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_assign_arithmetic, Image<PixType1> >::type &
149  operator/=(Image<PixType1>& lhs, Image<PixType2> const& rhs);
150 
151  //! Operator to compute Image /= constant
152  template <class PixType1, class T> inline
153  typename std::enable_if<nrt_traits<PixType1, T>::has_assign_arithmetic, Image<PixType1> >::type &
154  operator/=(Image<PixType1>& lhs, T const& rhs);
155 
156  //! Operator to compute Image / Image
157  template <class PixType1, class PixType2> inline
158  typename std::enable_if<nrt_traits<PixType1, PixType2>::has_arithmetic,
159  Image<typename nrt_traits<PixType1, PixType2>::promote_type> >::type
160  operator/(Image<PixType1> const& lhs, Image<PixType2> const& rhs);
161 
162  //! Operator to compute Image / constant
163  template <class PixType1, class T> inline
164  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
165  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
166  operator/(Image<PixType1> const& lhs, T const& rhs) ;
167 
168  //! Operator to compute constant / Image
169  template <class PixType1, class T> inline
170  typename std::enable_if<nrt_traits<PixType1, T>::has_arithmetic,
171  Image<typename nrt_traits<PixType1, T>::promote_type> >::type
172  operator/(T const& lhs, Image<PixType1> const& rhs);
173 
174  /*! @} */ // **********************************************************************
175 
176 }
177