$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
win_chamfer.hh
1 // Copyright (C) 2006, 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_MAKE_WIN_CHAMFER_HH
27 # define MLN_MAKE_WIN_CHAMFER_HH
28 
34 
35 # include <cmath>
36 
37 # include <mln/core/alias/w_window2d_int.hh>
38 # include <mln/core/alias/w_window2d_float.hh>
39 
40 
41 namespace mln
42 {
43 
44  namespace make
45  {
46 
47  template<int d10, int d11>
50 
51  template<int d10, int d11, int d21>
54 
56  mk_chamfer_3x3_float(float d10, float d11);
57 
59  mk_chamfer_5x5_float(float d10, float d11, float d21);
60 
63 
64 
65 # ifndef MLN_INCLUDE_ONLY
66 
67  template<int d10, int d11>
68  inline
71  {
72  int ws[] = { d11, d10, d11,
73  d10, 0, 0,
74  0, 0, 0 };
75 
76  return make::w_window2d(ws);
77  }
78 
79  template<int d10, int d11, int d21>
80  inline
83  {
84  int ws[] = { 0, d21, 0, d21, 0,
85  d21, d11, d10, d11, d21,
86  0, d10, 0, 0, 0,
87  0, 0, 0, 0, 0,
88  0, 0, 0, 0, 0 };
89 
90  return make::w_window2d(ws);
91  }
92 
93  inline
95  mk_chamfer_3x3_float(float d10, float d11)
96  {
97  float ws[] = { d11, d10, d11,
98  d10, 0, 0,
99  0, 0, 0 };
100 
101  return make::w_window2d(ws);
102  }
103 
104  inline
106  mk_chamfer_5x5_float(float d10, float d11, float d21)
107  {
108  float ws[] = { 0, d21, 0, d21, 0,
109  d21, d11, d10, d11, d21,
110  0, d10, 0, 0, 0,
111  0, 0, 0, 0, 0,
112  0, 0, 0, 0, 0 };
113 
114  return make::w_window2d(ws);
115  }
116 
117  inline
120  {
121  float r2 = std::sqrt(2.0f);
122  float ws[] = { r2, 1, r2,
123  1, 0, 0,
124  0, 0, 0 };
125 
126  return make::w_window2d(ws);
127  }
128 
129 # endif // ! MLN_INCLUDE_ONLY
130 
131  } // end of namespace mln::make
132 
133 } // end of namespace mln
134 
135 
136 #endif // ! MLN_MAKE_WIN_CHAMFER_HH