$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
images.hh
1 // Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
2 // Development Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_TRAIT_IMAGES_HH
28 # define MLN_TRAIT_IMAGES_HH
29 
39 
40 # include <iostream>
41 # include <string>
42 
43 # include <mln/trait/undef.hh>
44 # include <mln/trait/image/props.hh>
45 # include <mln/trait/value_.hh>
46 
47 # include <mln/metal/bexpr.hh>
48 # include <mln/metal/equal.hh>
49 # include <mln/metal/if.hh>
50 # include <mln/metal/is_const.hh>
51 
52 
53 
54 # define mln_trait_image_category(I) typename mln::trait::image_< I >::category
55 # define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed
56 # define mln_trait_image_size(I) typename mln::trait::image_< I >::size
57 
58 # define mln_trait_image_value_access(I) typename mln::trait::image_< I >::value_access
59 # define mln_trait_image_value_storage(I) typename mln::trait::image_< I >::value_storage
60 # define mln_trait_image_value_browsing(I) typename mln::trait::image_< I >::value_browsing
61 # define mln_trait_image_value_io(I) typename mln::trait::image_< I >::value_io
62 # define mln_trait_image_pw_io(I) typename mln::trait::image_< I >::pw_io
63 # define mln_trait_image_vw_io(I) typename mln::trait::image_< I >::vw_io
64 # define mln_trait_image_vw_set(I) typename mln::trait::image_< I >::vw_set
65 # define mln_trait_image_value_alignment(I) typename mln::trait::image_< I>::value_alignment
66 
67 # define mln_trait_image_localization(I) typename mln::trait::image_< I >::localization
68 # define mln_trait_image_dimension(I) typename mln::trait::image_< I >::dimension
69 
70 # define mln_trait_image_ext_domain(I) typename mln::trait::image_< I >::ext_domain
71 # define mln_trait_image_ext_value(I) typename mln::trait::image_< I >::ext_value
72 # define mln_trait_image_ext_io(I) typename mln::trait::image_< I >::ext_io
73 
74 # define mln_trait_image_kind(I) typename mln::trait::image_< I >::kind
75 # define mln_trait_image_nature(I) typename mln::trait::image_< I >::nature
76 # define mln_trait_image_quant(I) typename mln::trait::image_< I >::quant
77 
78 
79 // For value_io: I const => read_only, otherwise like I
80 
81 # define mln_internal_trait_image_value_io_from(I) \
82  \
83  mlc_if( mlc_is_const(I), \
84  mln::trait::image::value_io::read_only, \
85  mln_trait_image_value_io(I) )
86 
87 # define mln_internal_trait_image_pw_io_from(I) \
88  \
89  mlc_if( mlc_is_const(I), \
90  mln::trait::image::pw_io::read, \
91  mln_trait_image_pw_io(I) )
92 
93 
94 # define mln_internal_trait_image_vw_io_from(I) \
95  \
96  mlc_if( mlc_is_const(I), \
97  mln::trait::image::vw_io::read, \
98  mln_trait_image_vw_io(I) )
99 
100 
101 # define mln_internal_trait_image_speed_from(I) \
102  \
103  mlc_if( mlc_equal( mln_trait_image_speed(I), mln::trait::image::speed::fastest ), \
104  mln::trait::image::speed::fast, \
105  mln_trait_image_speed(I) )
106 
107 
108 
109 namespace mln
110 {
111 
112  // Primitive types.
113  template <typename T> struct image1d;
114  template <typename T> class image2d;
115  template <typename T> struct image3d;
116  namespace pw { template <typename F, typename S> class image; }
117 
118  // Morphers.
119  template <typename I, typename F> struct image_if_base;
120  template <typename I, typename D> struct decorated_image;
121  template <typename I, typename S> class sub_image;
122  template <typename I> class safe_image;
123  template <typename T, typename I> struct cast_image_;
124  namespace value { template <unsigned n, typename I> struct stack_image; }
125 
126 
127  namespace trait
128  {
129 
130  template <typename I>
132  {
133  // misc
134  typedef undef category;
135  typedef undef speed;
136  typedef undef size;
137 
138  // value
139  typedef undef vw_io;
140  typedef undef vw_set;
145  typedef undef value_io;
146 
147  // site
148  typedef undef pw_io;
150  typedef undef dimension;
151 
152  // extended domain
153  typedef undef ext_domain;
154  typedef undef ext_value;
155  typedef undef ext_io;
156 
157  // data (I::value)
158  typedef undef kind;
159  typedef undef nature;
160  typedef undef quant;
161  };
162 
163 
164  template <typename I>
166  {
167  };
168 
169 
170  template <typename I>
171  struct image_<const I> : image_<I>
172  {
173  // FIXME: TODO: io cannot contain "write"...
174  };
175 
176 
177  template <typename T, typename I>
179  {
180  private:
181  typedef mlc_equal(mln_trait_value_quant(T),
182  trait::value::quant::high) is_high_quant_;
183  public:
184  typedef mln_trait_value_kind(T) kind;
185  typedef mlc_if( is_high_quant_,
186  trait::image::quant::high,
187  trait::image::quant::low ) quant;
188  // FIXME: typedef undef value; // scalar, vectorial, structed
189 
190  // speed is fast by default (neither "fastest" nor "slow")
191  typedef trait::image::speed::fast speed;
192  };
193 
194 
195  /* FIXME: Why `default_image_morpher' has no trailing underscore,
196  whereas `default_image_', `image_' and `undefined_image_' have
197  one? */
198  template <typename D, typename T, typename I>
200  {
201  // misc => delegation except for 'category'
202  typedef typename image_<D>::size size;
203  typedef mln_internal_trait_image_speed_from(D) speed; // un-fastest
204 
205  // Image geometry => delegation
206  typedef typename image_<D>::localization localization;
207  typedef typename image_<D>::dimension dimension;
208 
209  // Memory organization => delegation
210  typedef typename image_<D>::value_alignment value_alignment;
211  typedef typename image_<D>::value_access value_access;
212  typedef typename image_<D>::value_storage value_storage;
213  typedef typename image_<D>::value_browsing value_browsing;
214  // un-write when D is const
215  typedef mln_internal_trait_image_value_io_from(D) value_io;
216 
217  // value wise access => delegation
218  typedef mln_internal_trait_image_vw_io_from(D) vw_io;
219  typedef typename image_<D>::vw_set vw_set;
220 
221 
222  // site wise access => delegation
223  typedef mln_internal_trait_image_pw_io_from(D) pw_io;
224 
225  // extended domain => delegation
226  typedef typename image_<D>::ext_domain ext_domain;
227  typedef typename image_<D>::ext_value ext_value;
228  typedef typename image_<D>::ext_io ext_io;
229 
230  // data (I::value) => delegation
231  typedef typename image_<D>::nature nature;
232  typedef typename image_<D>::kind kind;
233  typedef typename image_<D>::quant quant;
234  };
235 
236 
237  } // end of namespace mln::trait
238 
239 } // end of namespace mln
240 
241 
242 # include <mln/trait/image/print.hh>
243 
244 
245 #endif // ! MLN_TRAIT_IMAGES_HH